From 931cc7c440043e5486b2bb7dbeadd22e3a7eb92c Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 10 Aug 2026 03:14:16 +0200 Subject: [PATCH] fix(web): show Git action success inline in panel - Keep success feedback visible in the Git action control for 10 seconds - Move the running elapsed timer into the panel menu slot --- .../src/components/GitActionsControl.logic.ts | 4 +- apps/web/src/components/GitActionsControl.tsx | 362 +++++++++++------- 2 files changed, 235 insertions(+), 131 deletions(-) diff --git a/apps/web/src/components/GitActionsControl.logic.ts b/apps/web/src/components/GitActionsControl.logic.ts index c8831fb2c1..8d3b7bc305 100644 --- a/apps/web/src/components/GitActionsControl.logic.ts +++ b/apps/web/src/components/GitActionsControl.logic.ts @@ -54,14 +54,14 @@ export type DefaultBranchConfirmableAction = | "commit_push" | "commit_push_pr"; -const GIT_ACTION_SUCCESS_TOAST_VISIBLE_MS = 10_000; +export const GIT_ACTION_SUCCESS_VISIBLE_MS = 10_000; export function resolveGitActionResultToastTiming( type: "error" | "success", ): GitActionResultToastTiming { return { timeout: 0, - dismissAfterVisibleMs: type === "success" ? GIT_ACTION_SUCCESS_TOAST_VISIBLE_MS : null, + dismissAfterVisibleMs: type === "success" ? GIT_ACTION_SUCCESS_VISIBLE_MS : null, }; } diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx index b7fc7d695e..4c1623f351 100644 --- a/apps/web/src/components/GitActionsControl.tsx +++ b/apps/web/src/components/GitActionsControl.tsx @@ -39,6 +39,7 @@ import { cn } from "~/lib/utils"; import { buildMenuItems, formatGitActionElapsed, + GIT_ACTION_SUCCESS_VISIBLE_MS, type GitActionProgressPresentation, type GitActionIconName, type GitActionMenuItem, @@ -143,6 +144,12 @@ interface RunGitActionWithToastInput { filePaths?: string[]; } +interface InlineGitActionSuccess { + readonly title: string; + readonly description: string | null; + readonly scopeKey: string; +} + const GIT_STATUS_WINDOW_REFRESH_DEBOUNCE_MS = 250; type RefreshVcsStatus = (target: { @@ -349,17 +356,17 @@ function GitQuickActionIcon({ return ; } -function GitActionProgressButtonContent({ - progress, - isPanel, +function GitActionElapsedTime({ + startedAtMs, + className, }: { - progress: GitActionProgressPresentation; - isPanel: boolean; + startedAtMs: number | null; + className?: string; }) { const [nowMs, setNowMs] = useState(() => Date.now()); useEffect(() => { - if (progress.startedAtMs === null) { + if (startedAtMs === null) { return; } @@ -367,9 +374,23 @@ function GitActionProgressButtonContent({ setNowMs(Date.now()); }, 1_000); return () => window.clearInterval(intervalId); - }, [progress.startedAtMs]); + }, [startedAtMs]); - const elapsed = formatGitActionElapsed(progress.startedAtMs, nowMs); + const elapsed = formatGitActionElapsed(startedAtMs, nowMs); + if (!elapsed) { + return null; + } + + return

{elapsed}

; +} + +function GitActionProgressButtonContent({ + progress, + isPanel, +}: { + progress: GitActionProgressPresentation; + isPanel: boolean; +}) { const hasOutput = progress.output !== null; return ( @@ -377,17 +398,19 @@ function GitActionProgressButtonContent({ aria-atomic="false" aria-live="polite" className={cn( - "grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)_auto] items-center", + "grid min-w-0 flex-1 items-center", // Pin the title row to the button's minimum content height (min-height // minus vertical padding and border) so revealing the output row // extends the button downward without re-centering — the title must // not shift. No row gap: the collapsed output row must contribute zero // height so the single-line running button matches the static button // exactly. The panel column gap matches the static row's icon-to-label - // distance (gap-2.5 plus the label's ml-0.5). + // distance (gap-2.5 plus the label's ml-0.5). In the panel the elapsed + // counter renders outside the button (in the menu-chevron slot), so + // there is no trailing column. isPanel - ? "grid-rows-[1.75rem] gap-x-3" - : "grid-rows-[1.25rem] gap-x-2.5 sm:grid-rows-[1rem]", + ? "grid-cols-[auto_minmax(0,1fr)] grid-rows-[1.75rem] gap-x-3" + : "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[1.25rem] gap-x-2.5 sm:grid-rows-[1rem]", )} role="status" > @@ -396,14 +419,16 @@ function GitActionProgressButtonContent({ className="row-start-1 -mx-0.5 size-4 shrink-0 text-muted-foreground" />

{progress.status}

- {elapsed ? ( -

- {elapsed} -

+ {!isPanel ? ( + ) : null}
@@ -420,6 +445,36 @@ function GitActionProgressButtonContent({ ); } +function GitActionSuccessButtonContent({ success }: { success: InlineGitActionSuccess }) { + const hasDescription = success.description !== null; + + return ( +
+
+ ); +} + interface PublishRepositoryDialogProps { readonly open: boolean; readonly onOpenChange: (open: boolean) => void; @@ -1039,6 +1094,7 @@ export default function GitActionsControl({ "thread branch metadata update", ); const activeEnvironmentId = activeThreadRef?.environmentId ?? null; + const successScopeKey = `${activeEnvironmentId ?? ""}\u0000${gitCwd ?? ""}`; const serverConfig = useAtomValue(serverEnvironment.configValueAtom(activeEnvironmentId)); const openInPreferredEditor = useOpenInPreferredEditor( activeEnvironmentId, @@ -1062,6 +1118,7 @@ export default function GitActionsControl({ const [excludedFiles, setExcludedFiles] = useState>(new Set()); const [isEditingFiles, setIsEditingFiles] = useState(false); const [isPublishDialogOpen, setIsPublishDialogOpen] = useState(false); + const [inlineSuccess, setInlineSuccess] = useState(null); const [pendingDefaultBranchAction, setPendingDefaultBranchAction] = useState(null); const sourceControlScope = useMemo( @@ -1069,8 +1126,17 @@ export default function GitActionsControl({ [activeEnvironmentId, gitCwd], ); const vcsActionState = useAtomValue(vcsActionManager.stateAtom(sourceControlScope)); + const visibleInlineSuccess = inlineSuccess?.scopeKey === successScopeKey ? inlineSuccess : null; let runGitActionWithToast: (input: RunGitActionWithToastInput) => Promise; + useEffect(() => { + if (!inlineSuccess) return; + const timeoutId = window.setTimeout(() => { + setInlineSuccess(null); + }, GIT_ACTION_SUCCESS_VISIBLE_MS); + return () => window.clearTimeout(timeoutId); + }, [inlineSuccess]); + const persistThreadBranchSync = useCallback( (branch: string | null) => { if (!activeThreadRef) { @@ -1327,6 +1393,7 @@ export default function GitActionsControl({ return; } onConfirmed?.(); + setInlineSuccess(null); const scopedToastData = threadToastData ? { ...threadToastData } : undefined; const actionId = randomUUID(); @@ -1360,6 +1427,14 @@ export default function GitActionsControl({ const actionResult = result.value; syncThreadBranchAfterGitAction(actionResult); + if (isPanel) { + setInlineSuccess({ + title: actionResult.toast.title, + description: actionResult.toast.description ?? null, + scopeKey: successScopeKey, + }); + return; + } let resultToastId: GitActionToastId | null = null; const closeResultToast = () => { if (resultToastId !== null) { @@ -1477,6 +1552,7 @@ export default function GitActionsControl({ } if (quickAction.kind === "run_pull") { void (async () => { + setInlineSuccess(null); const result = await pullAction.run(); if (result._tag === "Failure") { if (isAtomCommandInterrupted(result)) { @@ -1497,14 +1573,20 @@ export default function GitActionsControl({ } const pullResult = result.value; + const title = pullResult.status === "pulled" ? "Pulled" : "Already up to date"; + const description = + pullResult.status === "pulled" + ? `Updated ${pullResult.refName} from ${pullResult.upstreamRef ?? "upstream"}` + : `${pullResult.refName} is already synchronized.`; + if (isPanel) { + setInlineSuccess({ title, description, scopeKey: successScopeKey }); + return; + } const successToastTiming = resolveGitActionResultToastTiming("success"); toastManager.add({ type: "success", - title: pullResult.status === "pulled" ? "Pulled" : "Already up to date", - description: - pullResult.status === "pulled" - ? `Updated ${pullResult.refName} from ${pullResult.upstreamRef ?? "upstream"}` - : `${pullResult.refName} is already synchronized.`, + title, + description, timeout: successToastTiming.timeout, data: { ...threadToastData, @@ -1658,6 +1740,18 @@ export default function GitActionsControl({ > + ) : isPanel && visibleInlineSuccess ? ( + ) : quickActionDisabledReason ? ( )} - {isPanel ? ( -