Skip to content

Commit d3532ee

Browse files
saphidclaude
authored andcommitted
fix(server): restart notes no longer split an emoji in a long background task label
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 30084f0 commit d3532ee

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/RestartBackgroundNote.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ it("names a lost subagent by the id the agent resumes it with", () => {
113113
parentTaskId: "a".repeat(400),
114114
}).label;
115115
assert.lengthOf(longId, 160);
116+
assert.isTrue(
117+
cancelledRosterTaskWork({
118+
kind: "command",
119+
taskId: "shell-1",
120+
description: `${"d".repeat(158)}🚀 deploy`,
121+
}).label.isWellFormed(),
122+
);
116123
assert.isFalse(isAwaitedWork(cancelledRosterTaskWork({ kind: "command", taskId: "shell-2" })));
117124
assert.isTrue(
118125
isAwaitedWork(cancelledRosterTaskWork({ kind: "command", taskId: "tests", awaited: true })),

‎apps/server/src/orchestration-v2/RestartBackgroundNote.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ function compactLabel(value: unknown, maxLength = MAX_LABEL_LENGTH): string | un
1717
if (typeof value !== "string") return undefined;
1818
const text = value.replaceAll(/\s+/g, " ").trim();
1919
if (text.length === 0) return undefined;
20-
return text.length > maxLength ? `${text.slice(0, maxLength - 1)}…` : text;
20+
if (text.length <= maxLength) return text;
21+
// Half an emoji serializes to a lone surrogate escape, which provider JSON parsers reject.
22+
const last = text.charCodeAt(maxLength - 2);
23+
const end = last >= 0xd800 && last <= 0xdbff ? maxLength - 2 : maxLength - 1;
24+
return `${text.slice(0, end)}…`;
2125
}
2226

2327
/** A bounded label that keeps its id suffix whole whenever it fits. */

0 commit comments

Comments
 (0)