From 43f4e0d15daaa61789f45114881cf30e50a65a61 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 13 Nov 2025 10:24:36 +0000 Subject: [PATCH] Auto-switch to newly crated branch --- src/components/GitDialog.tsx | 16 +++++++++++++--- src/components/git/BranchManager.tsx | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/GitDialog.tsx b/src/components/GitDialog.tsx index 0e2421cc..77534d43 100644 --- a/src/components/GitDialog.tsx +++ b/src/components/GitDialog.tsx @@ -243,13 +243,23 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog object: currentRef, }); - toast({ - title: 'Branch created', - description: `Created branch "${newBranchName}"`, + // Automatically check out the new branch + await git.checkout({ + dir: projectPath, + ref: newBranchName.trim(), + force: true, }); + // Close the dialog before showing the toast setNewBranchName(''); setIsCreateBranchDialogOpen(false); + + // Show success toast indicating the branch was created and checked out + toast({ + title: 'Branch created and checked out', + description: `Switched to new branch "${newBranchName.trim()}"`, + }); + await loadBranches(); await refetchGitStatus(); } catch (error) { diff --git a/src/components/git/BranchManager.tsx b/src/components/git/BranchManager.tsx index ecb085cf..c36ec0b5 100644 --- a/src/components/git/BranchManager.tsx +++ b/src/components/git/BranchManager.tsx @@ -187,13 +187,23 @@ export function BranchManager({ projectId, currentBranch, onBranchChange }: Bran object: currentRef, }); - toast({ - title: 'Branch created', - description: `Created branch "${newBranchName}"`, + // Automatically check out the new branch + await git.checkout({ + dir: projectPath, + ref: newBranchName.trim(), + force: true, }); + // Close the dialog before showing the toast setNewBranchName(''); setIsCreateDialogOpen(false); + + // Show success toast indicating the branch was created and checked out + toast({ + title: 'Branch created and checked out', + description: `Switched to new branch "${newBranchName.trim()}"`, + }); + await loadBranches(); onBranchChange?.(); } catch (error) {