@devries-cameron20 / t3code Mirror · read-only / commits / 5bdc2afc23
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 05:45 UTC

fix(server): preview snapshots no longer cut an emoji in half (#29600)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 23:08 UTC 5bdc2afc230370ee225b75c21671f26e2560cdc2
2 files changed +12 -6
apps/server/src/mcp/McpHttpServer.test.ts
+6 -4
@@ -692,9 +692,9 @@ it.effect("bounds the snapshot text even when nothing but logs and the title are
692 Effect.gen(function* () {
693 const oversized = {
694 ...snapshotResult,
695 - title: "t".repeat(70_000),
695 + title: `t${"😀".repeat(35_000)}`,
696 interactiveElements: [],
697 - consoleEntries: [{ level: "log", text: "x".repeat(70_000), timestamp: "t" }],
697 + consoleEntries: [{ level: "log", text: `x${"😀".repeat(35_000)}`, timestamp: "t" }],
698 };
699 yield* serveSnapshots("mcp-bounded-logs-client", oversized);
700
@@ -709,8 +709,10 @@ it.effect("bounds the snapshot text even when nothing but logs and the title are
709 readonly title: string;
710 readonly consoleEntries: ReadonlyArray<{ readonly text: string }>;
711 };
712 - expect(parsed.title.length).toBe(2_049);
713 - expect(parsed.consoleEntries[0]?.text.length).toBe(501);
712 + expect(parsed.title.isWellFormed()).toBe(true);
713 + expect(parsed.title.length).toBe(2_048);
714 + expect(parsed.consoleEntries[0]?.text.isWellFormed()).toBe(true);
715 + expect(parsed.consoleEntries[0]?.text.length).toBe(500);
716 const notice = snapshot.content[2];
717 const noticeText = notice?.type === "text" ? notice.text : "";
718 expect(noticeText).toContain("url or title after 2048 characters");
apps/server/src/mcp/McpHttpServer.ts
+6 -2
@@ -258,8 +258,12 @@ const MAX_SNAPSHOT_IDENTIFIER_CHARS = 2_048;
258
259 const encodeJsonText = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
260 const utf8Length = (text: string) => Buffer.byteLength(text, "utf8");
261 -const cutText = (text: string, max: number) =>
262 - text.length > max ? `${text.slice(0, max)}…` : text;
261 +const cutText = (text: string, max: number) => {
262 + if (text.length <= max) return text;
263 + // Half an emoji serializes to a lone surrogate escape, which provider JSON parsers reject.
264 + const last = text.charCodeAt(max - 1);
265 + return `${text.slice(0, last >= 0xd800 && last <= 0xdbff ? max - 1 : max)}…`;
266 +};
267
268 const cutEntryStrings = <A>(entry: A): A =>
269 typeof entry === "object" && entry !== null