From 0e1f580370db6a54f169c0b74ff21942e7a9f495 Mon Sep 17 00:00:00 2001 From: Bill Leoutsakos Date: Sat, 22 Aug 2026 15:17:46 -0700 Subject: [PATCH] fix(terminal): keep running-command tooltips concise --- .../terminal-session/terminal-session.test.ts | 37 +++++++++++++++++++ .../terminal-session/terminal-session.tsx | 10 ++--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.test.ts b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.test.ts index ea0a4eae4b9..58769251e92 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.test.ts +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.test.ts @@ -9,8 +9,45 @@ import { terminalFontSizeForZoom, terminalSelectionLabel, terminalSelectionSnapshot, + terminalTooltip, } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session' +describe('terminal tab tooltips', () => { + it('summarizes a long compound heredoc command by its foreground program', () => { + const running = `mkdir -p ~/.doordash-bot/bin && cat > ~/.doordash-bot/bin/dd-cli-mock <<'EOF' +#!/usr/bin/env node +const carts = new Map() +process.stdout.write(JSON.stringify([...carts])) +EOF +chmod +x ~/.doordash-bot/bin/dd-cli-mock && echo '--- smoke test ---' && ~/.doordash-bot/bin/dd-cli-mock submit mock_123` + const tooltip = terminalTooltip({ + terminalId: 'terminal-1', + title: 'mkdir', + cwd: '/Users/emirkarabeg', + running, + interactive: false, + active: false, + }) + + expect(tooltip).toBe('/Users/emirkarabeg — dd-cli-mock') + expect(tooltip).not.toContain('const carts') + }) + + it('preserves the working-directory tooltip for idle terminals', () => { + const idleTab = { + terminalId: 'terminal-1', + title: 'sim', + cwd: '/Users/emirkarabeg/sim', + running: null, + interactive: false, + active: true, + } + + expect(terminalTooltip(idleTab)).toBe('/Users/emirkarabeg/sim') + expect(terminalTooltip({ ...idleTab, cwd: null })).toBe('Terminal') + }) +}) + describe('suspended terminal resource lifecycle', () => { it('does not remove a resource when administrative suspension clears its PTYs', () => { expect(shouldRemoveTerminalResource(0, true, true)).toBe(false) diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.tsx index badaa075443..cb124f6e479 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/terminal-session/terminal-session.tsx @@ -114,10 +114,10 @@ function hideMountedMenuSurfaces(): void { */ const COMMAND_SETTLE_MS = 1_000 -/** Full working directory, plus whatever the shell is running in it. */ -function terminalTooltip(tab: TerminalTabState): string { +/** Full working directory, plus a concise name for whatever the shell is running. */ +export function terminalTooltip(tab: TerminalTabState): string { const where = tab.cwd ?? 'Terminal' - return tab.running ? `${where} — ${tab.running}` : where + return tab.running ? `${where} — ${describeRunningCommand(tab.running)}` : where } function sameIds(a: ReadonlySet, b: ReadonlySet): boolean { @@ -902,8 +902,8 @@ export function TerminalSession({ visible, scopeId }: TerminalSessionProps) { id: tab.terminalId, title: counts.get(label) === 1 ? label : `${label} ${occurrence}`, // The label is a basename, and the tab may be running something it - // is not naming yet, so hovering gives the whole picture: where the - // shell is, and what it is doing there. + // is not naming yet, so hovering identifies the working directory and + // foreground program without exposing the literal command. tooltip: terminalTooltip(tab), icon: (