@devries-cameron20 / t3code-1 / commits / f8372d1baf
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): long screen-reader announcements keep emoji whole at the cutoff (#35681)

Julius Marminge committed Nov 12, 2026 at 16:09 UTC f8372d1bafc3cd9f0bbf2a9ac169693291a691c0
2 files changed +26 -6
apps/web/src/components/chat/turnDetailAnnouncement.test.ts
+11
@@ -133,6 +133,11 @@ describe("turnDetail", () => {
133 expect(turnDetail(entries, undefined, null).activity).toBe(activity);
134 });
135
136 + it("cuts a long step without splitting an emoji", () => {
137 + const edit = work("edit", { itemType: "file_change", changedFiles: [`${"a".repeat(111)}😀z`] });
138 + expect(turnDetail([prompt, edit], undefined, null).activity).not.toMatch(/[\uD800-\uDFFF]/u);
139 + });
140 +
141 it.each<{
142 name: string;
143 entries: ReadonlyArray<TimelineEntry>;
@@ -297,6 +302,12 @@ describe("nextTurnDetailAnnouncement", () => {
302 ).toEqual(["T3 Code: Tests pass in web. See the docs"]);
303 });
304
305 + it("cuts a long message without splitting an emoji", () => {
306 + const long = { ...said("long", true, true), text: `${"a".repeat(1999)}😀z` };
307 + const [spoken] = speak("messages", [frame(null), frame(null, [long])]);
308 + expect(spoken).not.toMatch(/[\uD800-\uDFFF]/u);
309 + });
310 +
311 it("says a step again after waiting on the user", () => {
312 expect(
313 speak("everything", [
apps/web/src/components/chat/turnDetailAnnouncement.ts
+15 -6
@@ -34,6 +34,13 @@ const ACTIVITY_MAX_LENGTH = 120;
34 // Parsing is synchronous, and nobody listens to a longer message through a live region.
35 const MESSAGE_MAX_LENGTH = 2_000;
36
37 +/** The first `maxLength` code points of `text`, or null when it has no more than that. */
38 +function cutText(text: string, maxLength: number): string | null {
39 + if (text.length <= maxLength) return null;
40 + const characters = Array.from(text);
41 + return characters.length > maxLength ? characters.slice(0, maxLength).join("") : null;
42 +}
43 +
44 // On screen these labels are a path or a query beside an icon.
45 function withVerb(work: WorkLogEntry, label: string) {
46 if (work.itemType === "file_change") return `Editing ${label}`;
@@ -66,7 +73,8 @@ function stepLabel(work: WorkLogEntry, workspaceRoot: string | undefined): strin
73 const label = liveWorkEntryLabel(work, workspaceRoot, true).replace(/\s+/g, " ").trim();
74 if (label === "") return null;
75 const spoken = withVerb(work, label);
69 - return spoken.length > ACTIVITY_MAX_LENGTH ? `${spoken.slice(0, ACTIVITY_MAX_LENGTH)}…` : spoken;
76 + const cut = cutText(spoken, ACTIVITY_MAX_LENGTH);
77 + return cut === null ? spoken : `${cut}…`;
78 }
79
80 /**
@@ -189,11 +197,12 @@ export function nextTurnDetailAnnouncement(
197 previous.messages.get(message.id) !== true &&
198 (message.fresh || previous.messages.has(message.id)),
199 )
192 - .map((message) =>
193 - message.text.length > MESSAGE_MAX_LENGTH
194 - ? `${markdownPlainText(message.text.slice(0, MESSAGE_MAX_LENGTH))} More in the thread.`
195 - : markdownPlainText(message.text),
196 - )
200 + .map((message) => {
201 + const cut = cutText(message.text, MESSAGE_MAX_LENGTH);
202 + return cut === null
203 + ? markdownPlainText(message.text)
204 + : `${markdownPlainText(cut)} More in the thread.`;
205 + })
206 .filter((text) => text !== "")
207 .map((text) => `${MESSAGE_AUTHOR}: ${text}`),
208 activity: