From 5efdbb0d4c601dd6fe984e8e0d9a921f025bc548 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 5 Apr 2026 18:41:48 -0700 Subject: [PATCH] Restore branch selector state after checkout failures - Revert optimistic branch selection when checkout fails - Co-authored-by: codex --- apps/web/src/components/BranchToolbarBranchSelector.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx index bf96b89f93..0d3ed6a659 100644 --- a/apps/web/src/components/BranchToolbarBranchSelector.tsx +++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx @@ -224,6 +224,7 @@ export function BranchToolbarBranchSelector({ onComposerFocusRequest?.(); runBranchAction(async () => { + const previousBranch = resolvedActiveBranch; setOptimisticBranch(selectedBranchName); try { const checkoutResult = await api.git.checkout({ @@ -236,6 +237,7 @@ export function BranchToolbarBranchSelector({ setOptimisticBranch(nextBranchName); onSetThreadBranch(nextBranchName, selectionTarget.nextWorktreePath); } catch (error) { + setOptimisticBranch(previousBranch); toastManager.add({ type: "error", title: "Failed to checkout branch.",