fix(agent-status): reject cwd path titles

This commit is contained in:
Brennan Benson
2026-08-24 11:26:25 -07:00
parent cab0287057
commit 64f8ea9b0b
2 changed files with 20 additions and 6 deletions
+12
View File
@@ -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([])
+8 -6
View File
@@ -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 (