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) {