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, 07:00 UTC
fix(cli): t3 thread start titles no longer end in a broken character (#29563)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex Southwell committed
Nov 3, 2026 at 01:37 UTC
a565d8953ed9c435c1602bde2952a665258f3a5c
2 files changed
+15
-5
apps/server/src/cli/thread.test.ts
+6
-1
@@ -2,7 +2,7 @@ import { assert, it } from "@effect/vitest";
2
import { RunId, ThreadId } from "@t3tools/contracts";
3
import * as Effect from "effect/Effect";
4
5
-import { readLatestMessages, type ThreadTools, waitForRun } from "./thread.ts";
5
+import { readLatestMessages, type ThreadTools, titleFromMessage, waitForRun } from "./thread.ts";
6
7
const threadId = ThreadId.make("thread-1");
8
const runId = RunId.make("run-1");
@@ -160,3 +160,8 @@ it.effect("show returns a --messages count larger than one call can spread", ()
160
);
161
}),
162
);
163
+
164
+it("titles from a long first line without splitting an emoji", () => {
165
+ const title = titleFromMessage(`${"a".repeat(78)}😀 and the rest of a long first line`);
166
+ assert.strictEqual(title, `${"a".repeat(78)}…`);
167
+});
apps/server/src/cli/thread.ts
+9
-4
@@ -508,11 +508,16 @@ const finishRun = Effect.fn("cli.thread.finishRun")(function* (
508
}
509
});
510
511
-const titleFromMessage = (message: string) => {
511
+export const titleFromMessage = (message: string) => {
512
const firstLine = message.trim().split("\n")[0]?.trim() ?? "";
513
- return firstLine.length > TITLE_MAX_CHARS
514
- ? `${firstLine.slice(0, TITLE_MAX_CHARS - 1).trimEnd()}…`
515
- : firstLine;
513
+ if (firstLine.length <= TITLE_MAX_CHARS) return firstLine;
514
+ let end = TITLE_MAX_CHARS - 1;
515
+ const previous = firstLine.charCodeAt(end - 1);
516
+ const next = firstLine.charCodeAt(end);
517
+ if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
518
+ end -= 1;
519
+ }
520
+ return `${firstLine.slice(0, end).trimEnd()}…`;
521
};
522
523
const launchWorkspaceStrategy = (input: {