@devries-cameron20 / t3code Mirror · read-only / commits / a8059dc2c0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 16:00 UTC

fix: reuse git action toast after feature-branch checkout

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Mar 1, 2026 at 19:29 UTC a8059dc2c0341e72efab496c88b15b8dadac71e2
1 file changed +39 -22
apps/web/src/components/GitActionsControl.tsx
+39 -22
@@ -58,6 +58,8 @@ interface PendingDefaultBranchAction {
58 onConfirmed?: () => void;
59 }
60
61 +type GitActionToastId = ReturnType<typeof toastManager.add>;
62 +
63 function getMenuActionDisabledReason(
64 item: GitActionMenuItem,
65 gitStatus: GitStatusResult | null,
@@ -245,6 +247,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
247 skipDefaultBranchPrompt = false,
248 statusOverride,
249 isDefaultBranchOverride,
250 + progressToastId,
251 }: {
252 action: GitStackedAction;
253 commitMessage?: string;
@@ -253,6 +256,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
256 skipDefaultBranchPrompt?: boolean;
257 statusOverride?: GitStatusResult | null;
258 isDefaultBranchOverride?: boolean;
259 + progressToastId?: GitActionToastId;
260 }) => {
261 const actionStatus = statusOverride ?? gitStatusForActions;
262 const actionIsDefaultBranch = isDefaultBranchOverride ?? isDefaultBranch;
@@ -284,17 +288,28 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
288 forcePushOnly: forcePushOnlyProgress,
289 ...(pushTarget ? { pushTarget } : {}),
290 });
287 - const progressToastId = toastManager.add({
288 - type: "loading",
289 - title: progressStages[0] ?? "Running git action...",
290 - timeout: 0,
291 - data: threadToastData,
292 - });
291 + const resolvedProgressToastId =
292 + progressToastId ??
293 + toastManager.add({
294 + type: "loading",
295 + title: progressStages[0] ?? "Running git action...",
296 + timeout: 0,
297 + data: threadToastData,
298 + });
299 +
300 + if (progressToastId) {
301 + toastManager.update(progressToastId, {
302 + type: "loading",
303 + title: progressStages[0] ?? "Running git action...",
304 + timeout: 0,
305 + data: threadToastData,
306 + });
307 + }
308
309 let stageIndex = 0;
310 const stageInterval = setInterval(() => {
311 stageIndex = Math.min(stageIndex + 1, progressStages.length - 1);
297 - toastManager.update(progressToastId, {
312 + toastManager.update(resolvedProgressToastId, {
313 title: progressStages[stageIndex] ?? "Running git action...",
314 type: "loading",
315 timeout: 0,
@@ -329,10 +344,10 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
344 result.push.status === "pushed" &&
345 !actionIsDefaultBranch;
346 const closeResultToast = () => {
332 - toastManager.close(progressToastId);
347 + toastManager.close(resolvedProgressToastId);
348 };
349
335 - toastManager.update(progressToastId, {
350 + toastManager.update(resolvedProgressToastId, {
351 type: "success",
352 title: resultToast.title,
353 description: resultToast.description,
@@ -386,7 +401,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
401 });
402 } catch (err) {
403 stopProgressUpdates();
389 - toastManager.update(progressToastId, {
404 + toastManager.update(resolvedProgressToastId, {
405 type: "error",
406 title: "Action failed",
407 description: err instanceof Error ? err.message : "An error occurred.",
@@ -429,17 +444,11 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
444 );
445
446 const checkoutPromise = createBranchAndCheckoutMutation.mutateAsync(branchName);
432 - toastManager.promise(checkoutPromise, {
433 - loading: { title: `Creating ${branchName}...`, data: threadToastData },
434 - success: () => ({
435 - title: `Checked out ${branchName}`,
436 - data: threadToastData,
437 - }),
438 - error: (error) => ({
439 - title: "Failed to checkout feature branch",
440 - description: error instanceof Error ? error.message : "An error occurred.",
441 - data: threadToastData,
442 - }),
447 + const checkoutToastId = toastManager.add({
448 + type: "loading",
449 + title: `Creating ${branchName}...`,
450 + timeout: 0,
451 + data: threadToastData,
452 });
453
454 void checkoutPromise
@@ -459,9 +468,17 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
468 skipDefaultBranchPrompt: true,
469 statusOverride,
470 isDefaultBranchOverride: false,
471 + progressToastId: checkoutToastId,
472 });
473 })
464 - .catch(() => undefined);
474 + .catch((error) => {
475 + toastManager.update(checkoutToastId, {
476 + type: "error",
477 + title: "Failed to checkout feature branch",
478 + description: error instanceof Error ? error.message : "An error occurred.",
479 + data: threadToastData,
480 + });
481 + });
482 },
483 [
484 branchList?.branches,