|
| 1 | +import { createNativeHeaderMenu } from "../../components/nativeHeaderMenu.ios"; |
| 2 | +import type { ScreenHeaderMenu } from "../../components/ScreenHeader.types"; |
1 | 3 | import { |
2 | 4 | EnvironmentId, |
3 | 5 | type GitRunStackedActionResult, |
@@ -500,43 +502,51 @@ export function ThreadGitControls(props: ThreadGitControlsProps) { |
500 | 502 | * chat header and the review screen's toolbar. |
501 | 503 | */ |
502 | 504 | export function ThreadGitMenu(props: ThreadGitMenuProps) { |
503 | | - const model = useThreadGitControlModel(props); |
| 505 | + const menu = useThreadGitMenuDefinition(props); |
| 506 | + return menu ? createNativeHeaderMenu(menu) : null; |
| 507 | +} |
504 | 508 |
|
505 | | - return ( |
506 | | - <NativeHeaderToolbar.Menu icon="point.topleft.down.curvedto.point.bottomright.up"> |
507 | | - <NativeHeaderToolbar.MenuAction |
508 | | - icon="point.topleft.down.curvedto.point.bottomright.up" |
509 | | - disabled |
510 | | - onPress={() => {}} |
511 | | - subtitle={compactMenuStatus(props.gitStatus)} |
512 | | - > |
513 | | - <NativeHeaderToolbar.Label> |
514 | | - {compactMenuBranchLabel(model.currentBranchLabel)} |
515 | | - </NativeHeaderToolbar.Label> |
516 | | - </NativeHeaderToolbar.MenuAction> |
517 | | - <NativeHeaderToolbar.MenuAction |
518 | | - icon={model.quickActionIcon} |
519 | | - disabled={model.quickAction.disabled} |
520 | | - onPress={() => void model.runQuickAction()} |
521 | | - subtitle={model.quickActionHint ?? undefined} |
522 | | - > |
523 | | - <NativeHeaderToolbar.Label>{model.quickAction.label}</NativeHeaderToolbar.Label> |
524 | | - </NativeHeaderToolbar.MenuAction> |
525 | | - <NativeHeaderToolbar.MenuAction |
526 | | - icon="text.bubble" |
527 | | - disabled={!model.isRepo} |
528 | | - onPress={model.openReview} |
529 | | - subtitle="Turn diffs and worktree changes" |
530 | | - > |
531 | | - <NativeHeaderToolbar.Label>Review changes</NativeHeaderToolbar.Label> |
532 | | - </NativeHeaderToolbar.MenuAction> |
533 | | - <NativeHeaderToolbar.MenuAction |
534 | | - icon="ellipsis" |
535 | | - onPress={model.openGitInspector} |
536 | | - subtitle="Commit, files, branches" |
537 | | - > |
538 | | - <NativeHeaderToolbar.Label>More</NativeHeaderToolbar.Label> |
539 | | - </NativeHeaderToolbar.MenuAction> |
540 | | - </NativeHeaderToolbar.Menu> |
541 | | - ); |
| 509 | +/** Returns menu data because native toolbars serialize direct items rather than rendering component children. */ |
| 510 | +export function useThreadGitMenuDefinition(props: ThreadGitMenuProps): ScreenHeaderMenu | null { |
| 511 | + const model = useThreadGitControlModel(props); |
| 512 | + return { |
| 513 | + title: "Git controls", |
| 514 | + icon: "point.topleft.down.curvedto.point.bottomright.up", |
| 515 | + separateBackground: false, |
| 516 | + items: [ |
| 517 | + { |
| 518 | + id: "git-status", |
| 519 | + title: compactMenuBranchLabel(model.currentBranchLabel), |
| 520 | + icon: "point.topleft.down.curvedto.point.bottomright.up", |
| 521 | + disabled: true, |
| 522 | + subtitle: compactMenuStatus(props.gitStatus), |
| 523 | + onPress: () => {}, |
| 524 | + }, |
| 525 | + { |
| 526 | + id: "git-quick-action", |
| 527 | + title: model.quickAction.label, |
| 528 | + icon: model.quickActionIcon, |
| 529 | + disabled: model.quickAction.disabled, |
| 530 | + subtitle: model.quickActionHint ?? undefined, |
| 531 | + onPress: () => { |
| 532 | + void model.runQuickAction(); |
| 533 | + }, |
| 534 | + }, |
| 535 | + { |
| 536 | + id: "git-review", |
| 537 | + title: "Review changes", |
| 538 | + icon: "text.bubble", |
| 539 | + disabled: !model.isRepo, |
| 540 | + subtitle: "Turn diffs and worktree changes", |
| 541 | + onPress: model.openReview, |
| 542 | + }, |
| 543 | + { |
| 544 | + id: "git-more", |
| 545 | + title: "More", |
| 546 | + icon: "ellipsis", |
| 547 | + subtitle: "Commit, files, branches", |
| 548 | + onPress: model.openGitInspector, |
| 549 | + }, |
| 550 | + ], |
| 551 | + }; |
542 | 552 | } |
0 commit comments