Skip to content

Commit aa5f566

Browse files
fix(client-runtime): instance badges ignore punctuation
Badge initials took the first character of each word, so "Codex (hub)" became C(. Punctuation now separates words, so it reads CH. An apostrophe between letters stays inside its word ("Theo's Codex" is TC); a quoting one does not ("Codex 'hub'" is CH). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 05696c6 commit aa5f566

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎packages/client-runtime/src/state/providerInstanceDisplay.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ const codex = ProviderDriverKind.make("codex");
1212
const acpRegistry = ProviderDriverKind.make("acpRegistry");
1313

1414
describe("providerInstanceInitials", () => {
15+
it("treats punctuation as a word break but keeps apostrophes between letters", () => {
16+
expect(providerInstanceInitials("Codex (hub)")).toBe("CH");
17+
expect(providerInstanceInitials("work_codex")).toBe("WC");
18+
expect(providerInstanceInitials("Theo's Codex")).toBe("TC");
19+
expect(providerInstanceInitials("Codex 'hub'")).toBe("CH");
20+
expect(providerInstanceInitials("‘hub’")).toBe("HU");
21+
expect(providerInstanceInitials("(hub)")).toBe("HU");
22+
});
23+
1524
it("keeps an emoji whole instead of splitting its surrogate pair", () => {
1625
expect(providerInstanceInitials("😀 Work")).toBe("😀W");
1726
expect(providerInstanceInitials("😀")).toBe("😀");

‎packages/client-runtime/src/state/providerInstanceDisplay.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ export function resolveProviderInstanceDisplayName(
2727
}
2828

2929
export function providerInstanceInitials(label: string): string {
30-
const words = label.replace(/[_-]+/g, " ").split(/\s+/u).filter(Boolean);
30+
// Punctuation separates words so "Codex (hub)" reads CH, not C(. An apostrophe
31+
// between letters stays inside its word ("Theo's Codex" is TC); a quoting one
32+
// does not ("Codex 'hub'" is CH).
33+
const words = label
34+
.replace(/(?:[^\P{P}'’]|(?<![\p{L}\p{N}])['’]|['’](?![\p{L}\p{N}]))+/gu, " ")
35+
.split(/\s+/u)
36+
.filter(Boolean);
3137
if (words.length === 0) return "";
3238
if (words.length === 1) return Array.from(words[0]!).slice(0, 2).join("").toUpperCase();
3339
return words

0 commit comments

Comments
 (0)