From d4495e17356341237ac247e71ffb70761a6b586d Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 11 Sep 2026 23:30:20 -0700 Subject: [PATCH] perf: normalize title evidence once per label search --- src/shared/agent-title-evidence.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/shared/agent-title-evidence.ts b/src/shared/agent-title-evidence.ts index 8f212b5c75d..01b8c82f014 100644 --- a/src/shared/agent-title-evidence.ts +++ b/src/shared/agent-title-evidence.ts @@ -165,7 +165,8 @@ function agentForBareName(text: string): TuiAgent | null { 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()) + const normalized = stripped.toLowerCase() + const label = DISPLAY_LABELS.find(([text]) => text === normalized) if (label) { return label[1] } @@ -182,7 +183,8 @@ function agentForWholeTitle(text: string): TuiAgent | null { return null } const stripped = stripBareNameDecoration(trimmed) - const label = DISPLAY_LABELS.find(([text]) => text === stripped.toLowerCase()) + const normalized = stripped.toLowerCase() + const label = DISPLAY_LABELS.find(([text]) => text === normalized) if (label) { return label[1] } @@ -255,9 +257,8 @@ function namesConsumedByAnchoredLabels( ): Set { const consumed = new Set() for (const segment of segments) { - const label = DISPLAY_LABELS.find( - ([text]) => text === stripBareNameDecoration(segment).toLowerCase() - ) + const normalized = stripBareNameDecoration(segment).toLowerCase() + const label = DISPLAY_LABELS.find(([text]) => text === normalized) if (label && anchoredNames.has(label[1])) { for (const name of namesIn(label[0])) { consumed.add(name)