fix: address code review feedback

- Display actual shell name instead of hardcoded "bash"
- Fix type assertion by making findFirstTerminal accept null

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
SuperComboGamer
2025-12-13 01:05:12 -05:00
parent 272905b884
commit 18494547bc
2 changed files with 10 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ export function TerminalPanel({
const wsRef = useRef<WebSocket | null>(null);
const reconnectTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const [isTerminalReady, setIsTerminalReady] = useState(false);
const [shellName, setShellName] = useState("shell");
// Get effective theme from store
const getEffectiveTheme = useAppStore((state) => state.getEffectiveTheme);
@@ -223,6 +224,11 @@ export function TerminalPanel({
break;
case "connected":
console.log(`[Terminal] Session connected: ${msg.shell} in ${msg.cwd}`);
if (msg.shell) {
// Extract shell name from path (e.g., "/bin/bash" -> "bash")
const name = msg.shell.split("/").pop() || msg.shell;
setShellName(name);
}
break;
case "exit":
terminal.write(`\r\n\x1b[33m[Process exited with code ${msg.exitCode}]\x1b[0m\r\n`);
@@ -462,7 +468,7 @@ export function TerminalPanel({
<div className="flex items-center gap-1.5 flex-1 min-w-0">
<Terminal className="h-3 w-3 shrink-0 text-muted-foreground" />
<span className="text-xs truncate text-foreground">
bash
{shellName}
</span>
{/* Font size indicator - only show when not default */}
{fontSize !== DEFAULT_FONT_SIZE && (

View File

@@ -1605,7 +1605,8 @@ export const useAppStore = create<AppState & AppActions>()(
if (current.tabs.length === 0) return;
// Find which tab contains this session
const findFirstTerminal = (node: TerminalPanelContent): string | null => {
const findFirstTerminal = (node: TerminalPanelContent | null): string | null => {
if (!node) return null;
if (node.type === "terminal") return node.sessionId;
for (const panel of node.panels) {
const found = findFirstTerminal(panel);
@@ -1640,7 +1641,7 @@ export const useAppStore = create<AppState & AppActions>()(
// Determine new active session
const newActiveTabId = newTabs.length > 0 ? (current.activeTabId && newTabs.find(t => t.id === current.activeTabId) ? current.activeTabId : newTabs[0].id) : null;
const newActiveSessionId = newActiveTabId
? findFirstTerminal(newTabs.find(t => t.id === newActiveTabId)?.layout || null as unknown as TerminalPanelContent)
? findFirstTerminal(newTabs.find(t => t.id === newActiveTabId)?.layout || null)
: null;
set({