diff --git a/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts b/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts index 1114dd9e1..b227cb37c 100644 --- a/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts +++ b/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts @@ -201,6 +201,60 @@ describe('buildTitleDerivedAgentRows', () => { } }) + it('attributes a spinner-only title to the launched agent when the title has no identity', () => { + const launchAgent: TuiAgent = 'codex' + const rows = buildWorktreeAgentRows({ + tabs: [makeTab('tab-1', { launchAgent })], + entries: [], + retained: [], + runtimePaneTitlesByTabId: { + // Codex over SSH emits spinner + cwd titles with no agent name (#8711). + 'tab-1': { 1: '⠼ demo-repo' } + }, + ptyIdsByTabId: { 'tab-1': ['pty-codex-remote'] }, + terminalLayoutsByTabId: { 'tab-1': makeSingleLayout(LEAF_ID_1) }, + now: 2000 + }) + + expect( + rows.map((row) => [row.agentType, row.state, row.entry.prompt, row.entry.terminalTitle]) + ).toEqual([['codex', 'working', 'Codex', '⠼ demo-repo']]) + }) + + it('keeps explicit title identity over the launched agent', () => { + const launchAgent: TuiAgent = 'claude' + const rows = buildWorktreeAgentRows({ + tabs: [makeTab('tab-1', { launchAgent })], + entries: [], + retained: [], + runtimePaneTitlesByTabId: { + 'tab-1': { 1: '⠋ Codex' } + }, + ptyIdsByTabId: { 'tab-1': ['pty-explicit'] }, + terminalLayoutsByTabId: { 'tab-1': makeSingleLayout(LEAF_ID_1) }, + now: 2000 + }) + + expect(rows.map((row) => [row.agentType, row.state])).toEqual([['codex', 'working']]) + }) + + it('produces no row for a spinner-only title when the tab has no launch identity', () => { + const rows = buildWorktreeAgentRows({ + tabs: [makeTab('tab-1')], + entries: [], + retained: [], + runtimePaneTitlesByTabId: { + // Spinner activity but no identity and no launchAgent to attribute it to. + 'tab-1': { 1: '⠼ demo-repo' } + }, + ptyIdsByTabId: { 'tab-1': ['pty-anon'] }, + terminalLayoutsByTabId: { 'tab-1': makeSingleLayout(LEAF_ID_1) }, + now: 2000 + }) + + expect(rows).toHaveLength(0) + }) + it('does not turn generic Codex-launched task titles into Claude Code rows', () => { const launchAgent: TuiAgent = 'codex' const rows = buildWorktreeAgentRows({ diff --git a/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts b/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts index 1c862b705..068bdd599 100644 --- a/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts +++ b/src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts @@ -1,5 +1,6 @@ import type { DashboardAgentRow } from '@/components/dashboard/useDashboardData' -import { isClaudeManagementTitle } from '@/lib/agent-status' +import { formatAgentTypeLabel, isClaudeManagementTitle } from '@/lib/agent-status' +import { containsBrailleSpinner } from '../../../../shared/agent-title-core' import { classifyTitleActivity, resolveTitleActivityLabel } from '@/lib/pane-agent-evidence' import { tabHasLivePty } from '@/lib/tab-has-live-pty' import type { @@ -142,10 +143,20 @@ function buildTitleDerivedAgentRow(args: { } const paneKey = makePaneKey(args.tab.id, args.leafId) const orchestration = args.runtimeAgentOrchestrationByPaneKey?.[paneKey] - const agentType = isClaudeAgentsTitle ? 'claude' : resolveTitleDerivedAgentType(title, label) + const titleAgentType = isClaudeAgentsTitle ? 'claude' : resolveTitleDerivedAgentType(title, label) + // Why: a braille spinner proves activity, not identity, so the resolver drops + // it. Hook-less agents over SSH (Codex, #8711) surface only spinner+cwd titles; + // fall back to the tab's launch identity instead of hiding the pane. Gated on + // the spinner on purpose — unlike the hook path's unconditional launchAgent + // fallback (resolveRowAgentType), this path manufactures agent-ness from a + // title alone, so a non-agent title must never become a row. Residual: a split + // pane whose own title carries a braille glyph is still attributed to launchAgent. + const agentType = + titleAgentType ?? (containsBrailleSpinner(title) ? (args.tab.launchAgent ?? null) : null) if (!agentType) { return null } + const rowLabel = titleAgentType ? label : formatAgentTypeLabel(agentType) const rowState = titleStatusToRowState(status) const secondary = status === 'permission' ? 'Needs input' : status === 'working' ? 'Running' : 'Idle' @@ -153,7 +164,7 @@ function buildTitleDerivedAgentRow(args: { const entry: AgentStatusEntry = { paneKey, state: entryState, - prompt: label, + prompt: rowLabel, updatedAt: args.now, stateStartedAt: args.now, stateHistory: [],