diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx index 141e4e1c5b3d0f9facf04954d75d6e1d60303a02..bc7a3533f8add846a586fc418ec85d4ed19bfbaa 100644 --- a/apps/web/src/components/GitActionsControl.tsx +++ b/apps/web/src/components/GitActionsControl.tsx @@ -13,7 +13,6 @@ import { resolveQuickAction, summarizeGitResult, } from "./GitActionsControl.logic"; -import { Badge } from "~/components/ui/badge"; import { Button } from "~/components/ui/button"; import { Dialog, @@ -27,6 +26,7 @@ import { import { Group, GroupSeparator } from "~/components/ui/group"; import { Menu, MenuItem, MenuPopup, MenuTrigger } from "~/components/ui/menu"; import { Popover, PopoverPopup, PopoverTrigger } from "~/components/ui/popover"; +import { ScrollArea } from "~/components/ui/scroll-area"; import { Textarea } from "~/components/ui/textarea"; import { toastManager } from "~/components/ui/toast"; import { @@ -103,20 +103,6 @@ function getMenuActionDisabledReason( return "Create PR is currently unavailable."; } -function formatUpstreamStatus(input: { - hasUpstream: boolean; - aheadCount: number; - behindCount: number; -}): string { - if (!input.hasUpstream) return "No upstream configured"; - if (input.aheadCount === 0 && input.behindCount === 0) return "Up to date"; - if (input.aheadCount > 0 && input.behindCount > 0) { - return `Diverged (+${input.aheadCount} / -${input.behindCount})`; - } - if (input.aheadCount > 0) return `Ahead by ${input.aheadCount}`; - return `Behind by ${input.behindCount}`; -} - function GitActionItemIcon({ icon }: { icon: GitActionIconName }) { if (icon === "commit") return ; if (icon === "push") return ; @@ -207,7 +193,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp return true; } return api.dialogs.confirm( - `Push to default branch "${gitStatus.branch}"? This will update the shared base branch.`, + `You're about to push to the default branch "${gitStatus.branch}". Continue?`, ); }, [api, gitStatus?.branch, isDefaultBranch], @@ -290,7 +276,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp ? { actionProps: { children: "Push", - onClick: () => setActiveDialogAction("push"), + onClick: () => void runGitActionWithToast({ action: "commit_push" }), }, } : shouldOfferOpenPrCta @@ -371,11 +357,15 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp void openExistingPr(); return; } + if (item.dialogAction === "push") { + void runGitActionWithToast({ action: "commit_push" }); + return; + } if (item.dialogAction) { setActiveDialogAction(item.dialogAction); } }, - [openExistingPr], + [openExistingPr, runGitActionWithToast], ); const runDialogAction = useCallback(() => { @@ -425,10 +415,8 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp activeDialogAction === "commit" ? "Review and confirm your commit. Leave the message blank to auto-generate one." : activeDialogAction === "push" - ? "Push this branch now. If this is the default branch, you'll be asked to confirm." + ? "Push this branch now." : "Create a pull request using generated title/body content."; - const showCompactStatusCard = - !!gitStatus && gitStatus.hasWorkingTreeChanges && !gitStatus.hasUpstream; if (!gitCwd) return null; @@ -578,17 +566,19 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
Branch {gitStatus?.branch ?? "(detached HEAD)"} - {!showCompactStatusCard && ( + {activeDialogAction !== "commit" && ( <> Upstream - {gitStatus - ? formatUpstreamStatus({ - hasUpstream: gitStatus.hasUpstream, - aheadCount: gitStatus.aheadCount, - behindCount: gitStatus.behindCount, - }) - : "unknown"} + {!gitStatus || !gitStatus.hasUpstream + ? "No upstream configured" + : gitStatus.aheadCount === 0 && gitStatus.behindCount === 0 + ? "Up to date" + : gitStatus.aheadCount > 0 && gitStatus.behindCount > 0 + ? `Diverged (+${gitStatus.aheadCount} / -${gitStatus.behindCount})` + : gitStatus.aheadCount > 0 + ? `Ahead by ${gitStatus.aheadCount}` + : `Behind by ${gitStatus.behindCount}`} Working tree @@ -618,27 +608,31 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp {!gitStatus || gitStatus.workingTree.files.length === 0 ? (

none

) : ( -
- {gitStatus.workingTree.files.slice(0, 6).map((file) => ( - - ))} - {gitStatus.workingTree.files.length > 6 && ( - - +{gitStatus.workingTree.files.length - 6} more - - )} +
+ +
+ {gitStatus.workingTree.files.map((file) => ( + + ))} +
+
+
+ +{gitStatus.workingTree.insertions} + / + -{gitStatus.workingTree.deletions} +
)}