From 502361fc7c4c1c3a444c3cc39d899fd1241a02ae Mon Sep 17 00:00:00 2001 From: Stefan de Vogelaere Date: Sat, 17 Jan 2026 20:43:23 +0100 Subject: [PATCH] feat(ui): display branch name in terminal header with git icon - Move branch name display from tab name to terminal header - Show full branch name (no truncation) with GitBranch icon - Display branch name for both 'new tab' and 'split' modes - Persist openTerminalMode setting to server and include in import/export - Update settings dropdown to simplified "New Tab" label --- .../terminal/terminal-section.tsx | 2 +- .../ui/src/components/views/terminal-view.tsx | 21 ++++++++++++------- .../views/terminal-view/terminal-panel.tsx | 10 +++++++++ apps/ui/src/hooks/use-settings-sync.ts | 18 +++++++++++++--- apps/ui/src/lib/http-api-client.ts | 2 -- apps/ui/src/store/app-store.ts | 14 ++++++++----- libs/types/src/settings.ts | 4 ++++ 7 files changed, 53 insertions(+), 18 deletions(-) diff --git a/apps/ui/src/components/views/settings-view/terminal/terminal-section.tsx b/apps/ui/src/components/views/settings-view/terminal/terminal-section.tsx index 67e4cad1..e7092000 100644 --- a/apps/ui/src/components/views/settings-view/terminal/terminal-section.tsx +++ b/apps/ui/src/components/views/settings-view/terminal/terminal-section.tsx @@ -181,7 +181,7 @@ export function TerminalSection() { - New Tab (named after branch) + New Tab Split Current Tab diff --git a/apps/ui/src/components/views/terminal-view.tsx b/apps/ui/src/components/views/terminal-view.tsx index 0f7d65b0..88075747 100644 --- a/apps/ui/src/components/views/terminal-view.tsx +++ b/apps/ui/src/components/views/terminal-view.tsx @@ -596,22 +596,27 @@ export function TerminalView() { pendingTerminalCreatedRef.current = true; if (openMode === 'newTab') { - // Create a new tab named after the branch - const newTabId = addTerminalTab(pending.branchName); + // Create a new tab with default naming + const newTabId = addTerminalTab(); - // Set the tab's layout to the new terminal + // Set the tab's layout to the new terminal with branch name for display in header useAppStore .getState() .setTerminalTabLayout( newTabId, - { type: 'terminal', sessionId: data.data.id, size: 100 }, + { + type: 'terminal', + sessionId: data.data.id, + size: 100, + branchName: pending.branchName, + }, data.data.id ); toast.success(`Opened terminal for ${pending.branchName}`); } else { - // Split mode: add to current tab layout - addTerminalToLayout(data.data.id); - toast.success(`Opened terminal in ${pending.cwd.split('/').pop() || pending.cwd}`); + // Split mode: add to current tab layout with branch name + addTerminalToLayout(data.data.id, 'horizontal', undefined, pending.branchName); + toast.success(`Opened terminal for ${pending.branchName}`); } // Mark this session as new for running initial command @@ -789,6 +794,7 @@ export function TerminalView() { sessionId, size: persisted.size, fontSize: persisted.fontSize, + branchName: persisted.branchName, }; } @@ -1347,6 +1353,7 @@ export function TerminalView() { onCommandRan={() => handleCommandRan(content.sessionId)} isMaximized={terminalState.maximizedSessionId === content.sessionId} onToggleMaximize={() => toggleTerminalMaximized(content.sessionId)} + branchName={content.branchName} /> ); diff --git a/apps/ui/src/components/views/terminal-view/terminal-panel.tsx b/apps/ui/src/components/views/terminal-view/terminal-panel.tsx index 88f02591..ce6359c8 100644 --- a/apps/ui/src/components/views/terminal-view/terminal-panel.tsx +++ b/apps/ui/src/components/views/terminal-view/terminal-panel.tsx @@ -21,6 +21,7 @@ import { Maximize2, Minimize2, ArrowDown, + GitBranch, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Spinner } from '@/components/ui/spinner'; @@ -94,6 +95,7 @@ interface TerminalPanelProps { onCommandRan?: () => void; // Callback when the initial command has been sent isMaximized?: boolean; onToggleMaximize?: () => void; + branchName?: string; // Branch name to display in header (from "Open in Terminal" action) } // Type for xterm Terminal - we'll use any since we're dynamically importing @@ -124,6 +126,7 @@ export function TerminalPanel({ onCommandRan, isMaximized = false, onToggleMaximize, + branchName, }: TerminalPanelProps) { const terminalRef = useRef(null); const containerRef = useRef(null); @@ -1776,6 +1779,13 @@ export function TerminalPanel({
{shellName} + {/* Branch name indicator - show when terminal was opened from worktree */} + {branchName && ( + + + {branchName} + + )} {/* Font size indicator - only show when not default */} {fontSize !== DEFAULT_FONT_SIZE && (