From 64f8ea9b0b1ae089e8aac32e81fd2145b6058911 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:17:47 -0700 Subject: [PATCH] fix(agent-status): reject cwd path titles --- src/shared/agent-title-evidence.test.ts | 12 ++++++++++++ src/shared/agent-title-evidence.ts | 14 ++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/shared/agent-title-evidence.test.ts b/src/shared/agent-title-evidence.test.ts index 7b91400472b..68735fa996f 100644 --- a/src/shared/agent-title-evidence.test.ts +++ b/src/shared/agent-title-evidence.test.ts @@ -161,6 +161,18 @@ describe('collectAgentTitleEvidence', () => { } ) + it.each([ + '~/codex', + '/grok', + '.\\openclaude', + 'C:\\codex', + 'C:/codex', + '~/Codex ready', + '.\\Cursor ready' + ])('does not treat the cwd path %s as identity', (title) => { + expect(agentFor(title)).toBeNull() + }) + it('does not duplicate an anchored token as free text', () => { expect(collectAgentTitleEvidence('Codex').freeTextNames).toEqual([]) expect(collectAgentTitleEvidence('Claude Agent Teams').freeTextNames).toEqual([]) diff --git a/src/shared/agent-title-evidence.ts b/src/shared/agent-title-evidence.ts index 015ead70c14..c74aa7aaff9 100644 --- a/src/shared/agent-title-evidence.ts +++ b/src/shared/agent-title-evidence.ts @@ -147,10 +147,11 @@ function stripBareNameDecoration(text: string): string { } function agentForBareName(text: string): TuiAgent | null { - if (!text.trim()) { + const trimmed = text.trim() + if (!trimmed || /[\\/]/.test(trimmed)) { return null } - const stripped = stripBareNameDecoration(text) + const stripped = stripBareNameDecoration(trimmed) // Why labels too: an agent may write its own display name as the entire title (`⠐ Claude Code`). // That is the same claim as a bare token, just spelled the way the vendor spells it. const label = DISPLAY_LABELS.find(([text]) => text === stripped.toLowerCase()) @@ -170,10 +171,11 @@ function agentForOwnerSuffix(text: string): TuiAgent | null { } function agentForSyntheticTitle(text: string): TuiAgent | null { - const normalized = text - .trim() - .replace(/^[^\p{L}\p{N}]+/u, '') - .toLowerCase() + const trimmed = text.trim() + if (/[\\/]/.test(trimmed)) { + return null + } + const normalized = trimmed.replace(/^[^\p{L}\p{N}]+/u, '').toLowerCase() for (const agent of SYNTHETIC_AGENT_TITLE_AGENTS) { const profile = SYNTHETIC_AGENT_TITLE_PROFILES[agent] if (