@devries-cameron20 / t3code-1 / commits / 4eb20e4d38
Fork 0

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

fix(shared): clicked HTML images keep whole emoji in capped names (#33829)

Co-authored-by: johan vaz <johanvaz@Nathalines-MacBook-Pro.local> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Johan Vaz committed Nov 12, 2026 at 07:14 UTC 4eb20e4d38a69c32a6e4bf9e9bfdfc2636a256a7
2 files changed +10 -1
packages/shared/src/htmlRender.test.ts
+5
@@ -112,6 +112,11 @@ describe("readHtmlRenderImageRequest", () => {
112 src: "https://example.com/a.png",
113 name: "Image",
114 });
115 + const boundaryImage = readHtmlRenderImageRequest(
116 + image({ src: "https://example.com/a.png", name: "a".repeat(199) + "😀" }),
117 + );
118 + expect(boundaryImage?.name.isWellFormed()).toBe(true);
119 + expect(boundaryImage?.name).toBe("a".repeat(199));
120 expect(readHtmlRenderImageRequest(image({ src: "javascript:alert(1)" }))).toBeUndefined();
121 expect(readHtmlRenderImageRequest(image({ src: "data:text/html,<p>" }))).toBeUndefined();
122 expect(readHtmlRenderImageRequest(image({ src: "blob:null/1" }))).toBeUndefined();
packages/shared/src/htmlRender.ts
+5 -1
@@ -285,7 +285,11 @@ export function readHtmlRenderImageRequest(
285 if (typeof params !== "object" || params === null) return undefined;
286 const { src, name } = params as Record<string, unknown>;
287 if (typeof src !== "string" || !/^(?:https?:\/\/|data:image\/)/i.test(src)) return undefined;
288 - const label = typeof name === "string" ? name.trim().slice(0, HTML_RENDER_MAX_TITLE_LENGTH) : "";
288 + const trimmed = typeof name === "string" ? name.trim() : "";
289 + // The page sends any alt text; never end the label on half an emoji.
290 + const last = trimmed.charCodeAt(HTML_RENDER_MAX_TITLE_LENGTH - 1);
291 + const end = HTML_RENDER_MAX_TITLE_LENGTH - (last >= 0xd800 && last <= 0xdbff ? 1 : 0);
292 + const label = trimmed.slice(0, end);
293 return { src, name: label || "Image" };
294 }
295