@@ -12,13 +12,15 @@ import {
1212 ActionMenu ,
1313 ActionList ,
1414 Checkbox ,
15+ ButtonGroup ,
1516} from "@primer/react" ;
1617import {
1718 GitPullRequestIcon ,
1819 CheckCircleIcon ,
1920 RepoIcon ,
2021 LockIcon ,
2122 GitBranchIcon ,
23+ TriangleDownIcon ,
2224} from "@primer/octicons-react" ;
2325import { AppProvider } from "../../components/AppProvider" ;
2426import { useMcpApp } from "../../hooks/useMcpApp" ;
@@ -199,8 +201,8 @@ function CreatePRApp() {
199201 try {
200202 const result = await callTool ( "search_repositories" , { query : repoFilter , perPage : 10 } ) ;
201203 if ( result && ! result . isError && result . content ) {
202- const textContent = result . content . find ( ( c : { type : string } ) => c . type === "text" ) ;
203- if ( textContent ? .text ) {
204+ const textContent = result . content . find ( ( c ) => c . type === "text" ) ;
205+ if ( textContent && textContent . type === "text" && textContent . text ) {
204206 const data = JSON . parse ( textContent . text ) ;
205207 const repos = ( data . repositories || data . items || [ ] ) . map (
206208 ( r : { id ?: number ; owner ?: { login ?: string } | string ; name ?: string ; full_name ?: string ; private ?: boolean } ) => ( {
@@ -291,11 +293,12 @@ function CreatePRApp() {
291293 } ) ;
292294
293295 if ( result . isError ) {
294- const errorText = result . content ?. find ( ( c : { type : string } ) => c . type === "text" ) ;
295- setError ( errorText ?. text || "Failed to create pull request" ) ;
296+ const errorText = result . content ?. find ( ( c ) => c . type === "text" ) ;
297+ const errorMessage = errorText && errorText . type === "text" ? errorText . text : "Failed to create pull request" ;
298+ setError ( errorMessage ) ;
296299 } else {
297- const textContent = result . content ?. find ( ( c : { type : string } ) => c . type === "text" ) ;
298- if ( textContent ? .text ) {
300+ const textContent = result . content ?. find ( ( c ) => c . type === "text" ) ;
301+ if ( textContent && textContent . type === "text" && textContent . text ) {
299302 const prData = JSON . parse ( textContent . text ) ;
300303 setSuccessPR ( prData ) ;
301304 }
@@ -353,15 +356,18 @@ function CreatePRApp() {
353356 borderBottomWidth = { 1 }
354357 borderBottomStyle = "solid"
355358 borderBottomColor = "border.default"
359+ sx = { { minWidth : 0 , overflow : "hidden" } }
356360 >
357- < ActionMenu >
358- < ActionMenu . Button
359- size = "small"
360- leadingVisual = { selectedRepo ?. isPrivate ? LockIcon : RepoIcon }
361- >
362- { selectedRepo ? selectedRepo . fullName : "Select repository" }
363- </ ActionMenu . Button >
364- < ActionMenu . Overlay width = "large" >
361+ < Box sx = { { minWidth : 0 , maxWidth : "100%" } } >
362+ < ActionMenu >
363+ < ActionMenu . Button
364+ size = "small"
365+ leadingVisual = { selectedRepo ?. isPrivate ? LockIcon : RepoIcon }
366+ sx = { { maxWidth : "100%" , overflow : "hidden" , "& > span:last-child" : { overflow : "hidden" , textOverflow : "ellipsis" , whiteSpace : "nowrap" } } }
367+ >
368+ { selectedRepo ? selectedRepo . fullName : "Select repository" }
369+ </ ActionMenu . Button >
370+ < ActionMenu . Overlay width = "medium" >
365371 < ActionList selectionVariant = "single" >
366372 < Box px = { 3 } py = { 2 } >
367373 < TextInput
@@ -412,14 +418,15 @@ function CreatePRApp() {
412418 </ ActionList >
413419 </ ActionMenu . Overlay >
414420 </ ActionMenu >
421+ </ Box >
415422 </ Box >
416423
417424 { /* Branch selectors */ }
418- < Box display = "flex" gap = { 3 } mb = { 3 } alignItems = "flex-end" >
419- < Box flex = { 1 } >
425+ < Box display = "flex" gap = { 2 } mb = { 3 } alignItems = "flex-end" sx = { { minWidth : 0 , flexWrap : "wrap" } } >
426+ < Box sx = { { flex : "1 1 120px" , minWidth : 0 } } >
420427 < Text sx = { { fontSize : 0 , color : "fg.muted" , mb : 1 , display : "block" } } > base</ Text >
421428 < ActionMenu >
422- < ActionMenu . Button size = "small" leadingVisual = { GitBranchIcon } sx = { { width : "100%" } } >
429+ < ActionMenu . Button size = "small" leadingVisual = { GitBranchIcon } sx = { { width : "100%" , "& > span" : { overflow : "hidden" , textOverflow : "ellipsis" , whiteSpace : "nowrap" } } } >
423430 { baseBranch || "Select base" }
424431 </ ActionMenu . Button >
425432 < ActionMenu . Overlay width = "medium" >
@@ -455,12 +462,12 @@ function CreatePRApp() {
455462 </ ActionMenu >
456463 </ Box >
457464
458- < Text sx = { { color : "fg.muted" , pb : 1 , px : 1 } } > ←</ Text >
465+ < Text sx = { { color : "fg.muted" , pb : 1 , px : 1 , flexShrink : 0 } } > ←</ Text >
459466
460- < Box flex = { 1 } >
467+ < Box sx = { { flex : "1 1 120px" , minWidth : 0 } } >
461468 < Text sx = { { fontSize : 0 , color : "fg.muted" , mb : 1 , display : "block" } } > compare</ Text >
462469 < ActionMenu >
463- < ActionMenu . Button size = "small" leadingVisual = { GitBranchIcon } sx = { { width : "100%" } } >
470+ < ActionMenu . Button size = "small" leadingVisual = { GitBranchIcon } sx = { { width : "100%" , "& > span" : { overflow : "hidden" , textOverflow : "ellipsis" , whiteSpace : "nowrap" } } } >
464471 { headBranch || "Select head" }
465472 </ ActionMenu . Button >
466473 < ActionMenu . Overlay width = "medium" >
@@ -519,33 +526,62 @@ function CreatePRApp() {
519526 < MarkdownEditor value = { body } onChange = { setBody } placeholder = "Add a description..." />
520527 </ Box >
521528
522- { /* Options */ }
523- < Box mb = { 3 } display = "flex" gap = { 4 } >
524- < FormControl >
525- < Checkbox checked = { isDraft } onChange = { ( e ) => setIsDraft ( e . target . checked ) } />
526- < FormControl . Label sx = { { fontWeight : "normal" , ml : 1 } } > Create as draft</ FormControl . Label >
527- </ FormControl >
528- < FormControl >
529+ { /* Options and Submit */ }
530+ < Box display = "flex" justifyContent = "space-between" alignItems = "flex-end" flexWrap = "wrap" gap = { 3 } >
531+ < Box as = "label" display = "flex" alignItems = "center" sx = { { cursor : "pointer" , gap : 2 } } >
529532 < Checkbox checked = { maintainerCanModify } onChange = { ( e ) => setMaintainerCanModify ( e . target . checked ) } />
530- < FormControl . Label sx = { { fontWeight : "normal" , ml : 1 } } > Allow maintainer edits</ FormControl . Label >
531- </ FormControl >
532- </ Box >
533+ < Text sx = { { fontSize : 1 , color : "fg.muted" } } > Allow maintainer edits</ Text >
534+ </ Box >
533535
534- { /* Submit button */ }
535- < Box display = "flex" justifyContent = "flex-end" gap = { 2 } >
536- < Button
537- variant = "primary"
538- onClick = { handleSubmit }
539- disabled = { isSubmitting || ! owner || ! repo || ! baseBranch || ! headBranch }
540- >
541- { isSubmitting ? (
542- < > < Spinner size = "small" sx = { { mr : 1 } } /> Creating...</ >
543- ) : isDraft ? (
544- "Create draft pull request"
545- ) : (
546- "Create pull request"
547- ) }
548- </ Button >
536+ < ButtonGroup >
537+ < Button
538+ variant = "primary"
539+ onClick = { handleSubmit }
540+ disabled = { isSubmitting || ! owner || ! repo || ! baseBranch || ! headBranch }
541+ >
542+ { isSubmitting ? (
543+ < > < Spinner size = "small" sx = { { mr : 1 } } /> Creating...</ >
544+ ) : isDraft ? (
545+ "Draft pull request"
546+ ) : (
547+ "Create pull request"
548+ ) }
549+ </ Button >
550+ < ActionMenu >
551+ < ActionMenu . Anchor >
552+ < Button
553+ variant = "primary"
554+ disabled = { isSubmitting || ! owner || ! repo || ! baseBranch || ! headBranch }
555+ sx = { { px : 2 } }
556+ aria-label = "Select pull request type"
557+ >
558+ < TriangleDownIcon />
559+ </ Button >
560+ </ ActionMenu . Anchor >
561+ < ActionMenu . Overlay width = "medium" >
562+ < ActionList selectionVariant = "single" >
563+ < ActionList . Item selected = { ! isDraft } onSelect = { ( ) => setIsDraft ( false ) } >
564+ < ActionList . LeadingVisual >
565+ < GitPullRequestIcon />
566+ </ ActionList . LeadingVisual >
567+ Create pull request
568+ < ActionList . Description variant = "block" >
569+ Open a pull request that is ready for review
570+ </ ActionList . Description >
571+ </ ActionList . Item >
572+ < ActionList . Item selected = { isDraft } onSelect = { ( ) => setIsDraft ( true ) } >
573+ < ActionList . LeadingVisual >
574+ < GitPullRequestIcon />
575+ </ ActionList . LeadingVisual >
576+ Create draft pull request
577+ < ActionList . Description variant = "block" >
578+ Cannot be merged until marked ready for review
579+ </ ActionList . Description >
580+ </ ActionList . Item >
581+ </ ActionList >
582+ </ ActionMenu . Overlay >
583+ </ ActionMenu >
584+ </ ButtonGroup >
549585 </ Box >
550586 </ Box >
551587 </ AppProvider >
0 commit comments