diff --git a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-agent-rows.ts b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-agent-rows.ts index 21572a2c9d2..97db8a57b2a 100644 --- a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-agent-rows.ts +++ b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-agent-rows.ts @@ -183,7 +183,8 @@ function buildTitleDerivedAgentRow(args: { return null } // Why: the title sets activity only; a plain title on a process-identified pane is idle. - const status = titleStatus ?? jcodePaneTitleStatus(title, agentType) ?? 'idle' + // Jcode's own tail outranks agent names its conversation title happens to mention. + const status = jcodePaneTitleStatus(title, agentType) ?? titleStatus ?? 'idle' const rowLabel = agentType === titleAgentType && label && diff --git a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-jcode-rows.test.ts b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-jcode-rows.test.ts new file mode 100644 index 00000000000..854f0eac2c0 --- /dev/null +++ b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-title-derived-jcode-rows.test.ts @@ -0,0 +1,46 @@ +import { describe, expect, it } from 'vitest' +import type { TerminalTab } from '../../../../../../shared/workspace-layout/terminal-tab-types' +import { makePaneKey } from '../../../../../../shared/workspace-layout/stable-pane-id' +import { buildTitleDerivedAgentRows } from './worktree-title-derived-agent-rows' + +const LEAF_ID = '11111111-1111-4111-8111-111111111111' +const PANE_KEY = makePaneKey('tab-1', LEAF_ID) + +function jcodeRow(title: string) { + const tab: TerminalTab = { + id: 'tab-1', + ptyId: 'pty-1', + worktreeId: 'wt-1', + title, + customTitle: null, + color: null, + sortOrder: 0, + createdAt: 0 + } + const rows = buildTitleDerivedAgentRows({ + tabs: [tab], + ptyIdsByTabId: { 'tab-1': ['pty-1'] }, + terminalLayoutsByTabId: { + 'tab-1': { root: null, activeLeafId: LEAF_ID, expandedLeafId: null } + }, + // Linux reads jcode-linux-x86_64.bin; the foreground tracker publishes it as jcode. + paneForegroundAgentByPaneKey: { + [PANE_KEY]: { agent: 'jcode', agentEvidence: 'process-read', shellForeground: false } + }, + seenPaneKeys: new Set(), + now: 0 + }) + return rows.map((row) => ({ agentType: row.agentType, state: row.state })) +} + +describe('title-derived Jcode rows', () => { + it('keeps the row through Jcode titles and follows its turn tail', () => { + expect(jcodeRow('🐩 jcode/marsh Poodle')).toEqual([{ agentType: 'jcode', state: 'idle' }]) + expect(jcodeRow('🦊 Fix codex hooks · +3 -1 · work ~12s')).toEqual([ + { agentType: 'jcode', state: 'working' } + ]) + expect(jcodeRow('🦊 Fix codex hooks · last ~2m05s')).toEqual([ + { agentType: 'jcode', state: 'idle' } + ]) + }) +}) diff --git a/src/shared/agent-status/title/agent-title-status.ts b/src/shared/agent-status/title/agent-title-status.ts index 3e6c362b1fd..16a93a7c99e 100644 --- a/src/shared/agent-status/title/agent-title-status.ts +++ b/src/shared/agent-status/title/agent-title-status.ts @@ -1,6 +1,6 @@ import { getDeepSeekBuildTitleStatus } from './providers/dsb-terminal-title' import { qoderTitleStatus } from './providers/qoder-terminal-title' -import { jcodeIdentityTitleStatus } from './providers/jcode-terminal-title' +import { isJcodeIdentityTerminalTitle } from './providers/jcode-terminal-title' import { cursorTitleStatus } from './providers/cursor-terminal-title' import { AGY_AGENT_NAME_RE, @@ -280,9 +280,9 @@ function computeAgentStatusFromTitle(title: string): AgentStatus | null { if (title.startsWith(`${CLAUDE_IDLE} `) || title === CLAUDE_IDLE) { return 'idle' } - const jcodeStatus = jcodeIdentityTitleStatus(title) - if (jcodeStatus) { - return jcodeStatus + // Activity comes from jcodePaneTitleStatus; the identity alone says Jcode is at rest. + if (isJcodeIdentityTerminalTitle(title)) { + return 'idle' } // Read π ! as blocked before generic idle or OMP user waits disappear. const piCompatibleSeparatorStatus = getPiCompatibleTitleSeparatorStatus(title) diff --git a/src/shared/agent-status/title/providers/jcode-terminal-title.ts b/src/shared/agent-status/title/providers/jcode-terminal-title.ts index 23bda185bb5..f3094197222 100644 --- a/src/shared/agent-status/title/providers/jcode-terminal-title.ts +++ b/src/shared/agent-status/title/providers/jcode-terminal-title.ts @@ -11,8 +11,8 @@ export function stripJcodeTitleStatus(title: string): string { return title.replace(JCODE_TITLE_STATUS_RE, '').trim() } -// jcode, jcode Puppy and jcode/marsh Puppy (server name) are identity; user work labels contain more. -const JCODE_IDENTITY_TITLE_RE = /^jcode(?:\/[\w-]+)?(?:\s+[^\s·]+)?$/iu +// jcode, jcode Puppy and jcode/marsh Puppy (server name) are identity; a bare jcode/