Skip to content

Commit 0904016

Browse files
fix(client-runtime): quoting apostrophes no longer reach badge initials
Only an apostrophe between letters stays inside a word, so "Codex 'hub'" reads CH instead of C'. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b27f069 commit 0904016

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ 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", () => {
59+
it("treats punctuation as a word break but keeps apostrophes between letters", () => {
6060
expect(providerInstanceInitials("Codex (hub)")).toBe("CH");
6161
expect(providerInstanceInitials("work_codex")).toBe("WC");
6262
expect(providerInstanceInitials("Theo's Codex")).toBe("TC");
63+
expect(providerInstanceInitials("Codex 'hub'")).toBe("CH");
64+
expect(providerInstanceInitials("‘hub’")).toBe("HU");
6365
expect(providerInstanceInitials("(hub)")).toBe("HU");
6466
});
6567

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ export function resolveProviderInstanceDisplayName(
2727
}
2828

2929
export function providerInstanceInitials(label: string): string {
30-
// Punctuation separates words so "Codex (hub)" reads CH, not C(. Apostrophes
31-
// stay inside their word: "Theo's Codex" is TC.
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).
3233
const words = label
33-
.replace(/[^\P{P}'’]+/gu, " ")
34+
.replace(/(?:[^\P{P}'’]|(?<![\p{L}\p{N}])['’]|['’](?![\p{L}\p{N}]))+/gu, " ")
3435
.split(/\s+/u)
3536
.filter(Boolean);
3637
if (words.length === 0) return "";

0 commit comments

Comments
 (0)