GeezerVison is showing github.com — fix(client-runtime): "Codex (hub)" badges read CH instead of C( (#22918) · Pipyakas/t3code@2fd28bf
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/client-runtime/src/state
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/client-runtime/src/state/providerInstanceDisplay.test.ts +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,15 @@ const codex = ProviderDriverKind.make("codex"); |
12 | 12 | const acpRegistry = ProviderDriverKind.make("acpRegistry"); |
13 | 13 |
|
14 | 14 | 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 | + |
15 | 24 | it("keeps an emoji whole instead of splitting its surrogate pair", () => { |
16 | 25 | expect(providerInstanceInitials("😀 Work")).toBe("😀W"); |
17 | 26 | expect(providerInstanceInitials("😀")).toBe("😀"); |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/client-runtime/src/state/providerInstanceDisplay.ts +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,7 +27,14 @@ export function resolveProviderInstanceDisplayName( |
27 | 27 | } |
28 | 28 |
|
29 | 29 | 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 | + // inside a word stays ("Theo's Codex" is TC); a quoting one does not |
| 32 | + // ("Codex 'hub'" is CH). |
| 33 | + const words = label |
| 34 | + .replace(/[^\P{P}'’]+/gu, " ") |
| 35 | + .split(/\s+/u) |
| 36 | + .map((word) => word.replace(/^['’]+|['’]+$/gu, "")) |
| 37 | + .filter(Boolean); |
31 | 38 | if (words.length === 0) return ""; |
32 | 39 | if (words.length === 1) return Array.from(words[0]!).slice(0, 2).join("").toUpperCase(); |
33 | 40 | return words |
|