| ... | ... | @@ -11,6 +11,7 @@ import { |
| 11 | 11 | type GitQuickAction, |
| 12 | 12 | requiresDefaultBranchConfirmation, |
| 13 | 13 | resolveAutoFeatureBranchName, |
| 14 | resolveDefaultBranchActionDialogCopy, |
| 14 | 15 | resolveQuickAction, |
| 15 | 16 | summarizeGitResult, |
| 16 | 17 | } from "./GitActionsControl.logic"; |
| ... | ... | @@ -50,6 +51,8 @@ interface GitActionsControlProps { |
| 50 | 51 | |
| 51 | 52 | interface PendingDefaultBranchAction { |
| 52 | 53 | action: GitStackedAction; |
| 54 | branchName: string; |
| 55 | includesCommit: boolean; |
| 53 | 56 | commitMessage?: string; |
| 54 | 57 | forcePushOnlyProgress: boolean; |
| 55 | 58 | onConfirmed?: () => void; |
| ... | ... | @@ -115,12 +118,6 @@ const COMMIT_DIALOG_TITLE = "Commit changes"; |
| 115 | 118 | const COMMIT_DIALOG_DESCRIPTION = |
| 116 | 119 | "Review and confirm your commit. Leave the message blank to auto-generate one."; |
| 117 | 120 | |
| 118 | | const DEFAULT_BRANCH_ACTION_DESCRIPTION: Record<GitStackedAction, string> = { |
| 119 | | commit: "commit changes", |
| 120 | | commit_push: "commit and push changes", |
| 121 | | commit_push_pr: "commit, push, and create a PR", |
| 122 | | }; |
| 123 | | |
| 124 | 121 | function GitActionItemIcon({ icon }: { icon: GitActionIconName }) { |
| 125 | 122 | if (icon === "commit") return <GitCommitIcon />; |
| 126 | 123 | if (icon === "push") return <CloudUploadIcon />; |
| ... | ... | @@ -202,6 +199,13 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 202 | 199 | const quickActionDisabledReason = quickAction.disabled |
| 203 | 200 | ? (quickAction.hint ?? "This action is currently unavailable.") |
| 204 | 201 | : null; |
| 202 | const pendingDefaultBranchActionCopy = pendingDefaultBranchAction |
| 203 | ? resolveDefaultBranchActionDialogCopy({ |
| 204 | action: pendingDefaultBranchAction.action, |
| 205 | branchName: pendingDefaultBranchAction.branchName, |
| 206 | includesCommit: pendingDefaultBranchAction.includesCommit, |
| 207 | }) |
| 208 | : null; |
| 205 | 209 | |
| 206 | 210 | const openExistingPr = useCallback(async () => { |
| 207 | 211 | const api = readNativeApi(); |
| ... | ... | @@ -253,6 +257,8 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 253 | 257 | const actionStatus = statusOverride ?? gitStatusForActions; |
| 254 | 258 | const actionIsDefaultBranch = isDefaultBranchOverride ?? isDefaultBranch; |
| 255 | 259 | const actionBranch = actionStatus?.branch ?? null; |
| 260 | const includesCommit = |
| 261 | !forcePushOnlyProgress && (action === "commit" || !!actionStatus?.hasWorkingTreeChanges); |
| 256 | 262 | if ( |
| 257 | 263 | !skipDefaultBranchPrompt && |
| 258 | 264 | requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) && |
| ... | ... | @@ -260,6 +266,8 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 260 | 266 | ) { |
| 261 | 267 | setPendingDefaultBranchAction({ |
| 262 | 268 | action, |
| 269 | branchName: actionBranch, |
| 270 | includesCommit, |
| 263 | 271 | ...(commitMessage ? { commitMessage } : {}), |
| 264 | 272 | forcePushOnlyProgress, |
| 265 | 273 | ...(onConfirmed ? { onConfirmed } : {}), |
| ... | ... | @@ -398,10 +406,13 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 398 | 406 | |
| 399 | 407 | const continuePendingDefaultBranchAction = useCallback(() => { |
| 400 | 408 | if (!pendingDefaultBranchAction) return; |
| 401 | | const pendingAction = pendingDefaultBranchAction; |
| 409 | const { action, commitMessage, forcePushOnlyProgress, onConfirmed } = pendingDefaultBranchAction; |
| 402 | 410 | setPendingDefaultBranchAction(null); |
| 403 | 411 | void runGitActionWithToast({ |
| 404 | | ...pendingAction, |
| 412 | action, |
| 413 | ...(commitMessage ? { commitMessage } : {}), |
| 414 | forcePushOnlyProgress, |
| 415 | ...(onConfirmed ? { onConfirmed } : {}), |
| 405 | 416 | skipDefaultBranchPrompt: true, |
| 406 | 417 | }); |
| 407 | 418 | }, [pendingDefaultBranchAction, runGitActionWithToast]); |
| ... | ... | @@ -456,9 +467,14 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 456 | 467 | |
| 457 | 468 | const checkoutFeatureBranchAndContinuePendingAction = useCallback(() => { |
| 458 | 469 | if (!pendingDefaultBranchAction) return; |
| 459 | | const pendingAction = pendingDefaultBranchAction; |
| 470 | const { action, commitMessage, forcePushOnlyProgress, onConfirmed } = pendingDefaultBranchAction; |
| 460 | 471 | setPendingDefaultBranchAction(null); |
| 461 | | checkoutNewBranchAndRunAction(pendingAction); |
| 472 | checkoutNewBranchAndRunAction({ |
| 473 | action, |
| 474 | ...(commitMessage ? { commitMessage } : {}), |
| 475 | forcePushOnlyProgress, |
| 476 | ...(onConfirmed ? { onConfirmed } : {}), |
| 477 | }); |
| 462 | 478 | }, [pendingDefaultBranchAction, checkoutNewBranchAndRunAction]); |
| 463 | 479 | |
| 464 | 480 | const runDialogActionOnNewBranch = useCallback(() => { |
| ... | ... | @@ -801,22 +817,17 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 801 | 817 | > |
| 802 | 818 | <DialogPopup> |
| 803 | 819 | <DialogHeader> |
| 804 | | <DialogTitle>Commit to default branch?</DialogTitle> |
| 805 | | <DialogDescription> |
| 806 | | This action will{" "} |
| 807 | | {pendingDefaultBranchAction |
| 808 | | ? DEFAULT_BRANCH_ACTION_DESCRIPTION[pendingDefaultBranchAction.action] |
| 809 | | : "push changes"}{" "} |
| 810 | | on "{gitStatusForActions?.branch ?? "default"}". You can continue on this branch or |
| 811 | | create a feature branch and run the same action there. |
| 812 | | </DialogDescription> |
| 820 | <DialogTitle> |
| 821 | {pendingDefaultBranchActionCopy?.title ?? "Run action on default branch?"} |
| 822 | </DialogTitle> |
| 823 | <DialogDescription>{pendingDefaultBranchActionCopy?.description}</DialogDescription> |
| 813 | 824 | </DialogHeader> |
| 814 | 825 | <DialogFooter> |
| 815 | 826 | <Button variant="outline" size="sm" onClick={() => setPendingDefaultBranchAction(null)}> |
| 816 | 827 | Abort |
| 817 | 828 | </Button> |
| 818 | 829 | <Button variant="outline" size="sm" onClick={continuePendingDefaultBranchAction}> |
| 819 | | Commit to {gitStatusForActions?.branch ?? "default"} |
| 830 | {pendingDefaultBranchActionCopy?.continueLabel ?? "Continue"} |
| 820 | 831 | </Button> |
| 821 | 832 | <Button size="sm" onClick={checkoutFeatureBranchAndContinuePendingAction}> |
| 822 | 833 | Checkout feature branch & continue |