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