TypeScript
fix(server): create_threads titles no longer end in a broken character (#29163)
Alex Southwell448c1ac390e1
diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.tsindex 94ed303fde5..3bd9439d308 100644--- a/apps/server/src/mcp/OrchestratorMcpService.test.ts+++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts@@ -2149,6 +2149,14 @@ describe("OrchestratorMcpService provider resolution", () => {...request,clientRequestId: "empty",});+ const emojiAtLimit = yield* service.createThreads(scope, {+ threads: [{ ...request.threads[0]!, prompt: `${"a".repeat(76)}😀 and more work.` }],+ clientRequestId: "emoji-title",+ });+ const titled = yield* orchestrator.getThreadProjection(+ emojiAtLimit.threads[0]!.threadId,+ );+ assert.equal(titled.thread.title, `${"a".repeat(76)}...`);yield* settings.updateSettings({projectSettingsOverrides: {diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.tsindex 66cecbf4ede..b937453f39b 100644--- a/apps/server/src/mcp/OrchestratorMcpService.ts+++ b/apps/server/src/mcp/OrchestratorMcpService.ts@@ -746,7 +746,14 @@ function threadTitle(input: {}): string {const detail = input.title?.trim() || input.prompt?.trim();if (!detail) return `${input.parentTitle} thread ${input.index + 1}`;- return detail.length > 80 ? `${detail.slice(0, 77)}...` : detail;+ if (detail.length <= 80) return detail;+ let end = 77;+ const previous = detail.charCodeAt(end - 1);+ const next = detail.charCodeAt(end);+ if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {+ end -= 1;+ }+ return `${detail.slice(0, end)}...`;}function threadSettlement(