Skip to content

Commit 448c1ac

Browse files
saphidclaude
andauthored
fix(server): create_threads titles no longer end in a broken character (pingdotgg#29163)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent d1e5044 commit 448c1ac

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/server/src/mcp/OrchestratorMcpService.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,14 @@ describe("OrchestratorMcpService provider resolution", () => {
21492149
...request,
21502150
clientRequestId: "empty",
21512151
});
2152+
const emojiAtLimit = yield* service.createThreads(scope, {
2153+
threads: [{ ...request.threads[0]!, prompt: `${"a".repeat(76)}😀 and more work.` }],
2154+
clientRequestId: "emoji-title",
2155+
});
2156+
const titled = yield* orchestrator.getThreadProjection(
2157+
emojiAtLimit.threads[0]!.threadId,
2158+
);
2159+
assert.equal(titled.thread.title, `${"a".repeat(76)}...`);
21522160

21532161
yield* settings.updateSettings({
21542162
projectSettingsOverrides: {

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,14 @@ function threadTitle(input: {
746746
}): string {
747747
const detail = input.title?.trim() || input.prompt?.trim();
748748
if (!detail) return `${input.parentTitle} thread ${input.index + 1}`;
749-
return detail.length > 80 ? `${detail.slice(0, 77)}...` : detail;
749+
if (detail.length <= 80) return detail;
750+
let end = 77;
751+
const previous = detail.charCodeAt(end - 1);
752+
const next = detail.charCodeAt(end);
753+
if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
754+
end -= 1;
755+
}
756+
return `${detail.slice(0, end)}...`;
750757
}
751758

752759
function threadSettlement(

0 commit comments

Comments
 (0)