Skip to content

Commit b27f069

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 (apostrophes stay inside a word), so it reads CH and "Theo's Codex" stays TC. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f5c1142 commit b27f069

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ describe("providerInstanceInitials", () => {
5656
expect(providerInstanceInitials("Codex Personal Backup Account")).toBe("CP");
5757
});
5858

59+
it("treats punctuation as a word break but keeps apostrophes inside a word", () => {
60+
expect(providerInstanceInitials("Codex (hub)")).toBe("CH");
61+
expect(providerInstanceInitials("work_codex")).toBe("WC");
62+
expect(providerInstanceInitials("Theo's Codex")).toBe("TC");
63+
expect(providerInstanceInitials("(hub)")).toBe("HU");
64+
});
65+
5966
it("returns an empty string for an empty label", () => {
6067
expect(providerInstanceInitials("")).toBe("");
6168
});

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ 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(. Apostrophes
31+
// stay inside their word: "Theo's Codex" is TC.
32+
const words = label
33+
.replace(/[^\P{P}'’]+/gu, " ")
34+
.split(/\s+/u)
35+
.filter(Boolean);
3136
if (words.length === 0) return "";
3237
if (words.length === 1) return Array.from(words[0]!).slice(0, 2).join("").toUpperCase();
3338
return words

0 commit comments

Comments
 (0)