Skip to content

Commit 0a67f22

Browse files
saphidclaude
andcommitted
fix(server): create_threads titles no longer end in a broken character
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d01b92c commit 0a67f22

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
@@ -2037,6 +2037,14 @@ describe("OrchestratorMcpService provider resolution", () => {
20372037
...request,
20382038
clientRequestId: "empty",
20392039
});
2040+
const emojiAtLimit = yield* service.createThreads(scope, {
2041+
threads: [{ ...request.threads[0]!, prompt: `${"a".repeat(76)}😀 and more work.` }],
2042+
clientRequestId: "emoji-title",
2043+
});
2044+
const titled = yield* orchestrator.getThreadProjection(
2045+
emojiAtLimit.threads[0]!.threadId,
2046+
);
2047+
assert.equal(titled.thread.title, `${"a".repeat(76)}...`);
20402048

20412049
yield* settings.updateSettings({
20422050
projectSettingsOverrides: {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,14 @@ function threadTitle(input: {
742742
}): string {
743743
const detail = input.title?.trim() || input.prompt?.trim();
744744
if (!detail) return `${input.parentTitle} thread ${input.index + 1}`;
745-
return detail.length > 80 ? `${detail.slice(0, 77)}...` : detail;
745+
if (detail.length <= 80) return detail;
746+
let end = 77;
747+
const previous = detail.charCodeAt(end - 1);
748+
const next = detail.charCodeAt(end);
749+
if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
750+
end -= 1;
751+
}
752+
return `${detail.slice(0, end)}...`;
746753
}
747754

748755
function threadSettlement(

0 commit comments

Comments
 (0)