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 21, 12:15 UTC
fix(web): stashed prompt previews no longer end in a broken character (#32404)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Felix Laga committed
Nov 15, 2026 at 14:04 UTC
cc4160c8131278dcd114823c93b3d3b40781892b
2 files changed
+24
-2
apps/web/src/components/chat/ComposerStashMenu.test.ts
new
+18
@@ -0,0 +1,18 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+
3
+import { stashEntrySnippet } from "./ComposerStashMenu";
4
+
5
+const entry = (prompt: string) => ({
6
+ id: "stash-1",
7
+ createdAt: "2026-10-01T00:00:00.000Z",
8
+ prompt,
9
+ attachments: [],
10
+ droppedImageNames: [],
11
+});
12
+
13
+describe("stashEntrySnippet", () => {
14
+ it("cuts a long prompt on a whole character", () => {
15
+ expect(stashEntrySnippet(entry(`${"a".repeat(89)}😀 and more`))).toBe(`${"a".repeat(89)}…`);
16
+ expect(stashEntrySnippet(entry(`${"a".repeat(88)}😀 and more`))).toBe(`${"a".repeat(88)}😀…`);
17
+ });
18
+});
apps/web/src/components/chat/ComposerStashMenu.tsx
+6
-2
@@ -13,10 +13,14 @@ function missingImageCount(entry: PromptStashEntry): number {
13
return entry.droppedImageNames.length + (entry.unreadableImageNames?.length ?? 0);
14
}
15
16
-function stashEntrySnippet(entry: PromptStashEntry): string {
16
+export function stashEntrySnippet(entry: PromptStashEntry): string {
17
const trimmed = assistantCitationsToPlainText(entry.prompt).trim().replace(/\s+/g, " ");
18
if (trimmed.length > 0) {
19
- return trimmed.length > SNIPPET_MAX_CHARS ? `${trimmed.slice(0, SNIPPET_MAX_CHARS)}…` : trimmed;
19
+ if (trimmed.length <= SNIPPET_MAX_CHARS) return trimmed;
20
+ // Never end on a lone high surrogate, the first half of an emoji.
21
+ const last = trimmed.charCodeAt(SNIPPET_MAX_CHARS - 1);
22
+ const end = last >= 0xd800 && last <= 0xdbff ? SNIPPET_MAX_CHARS - 1 : SNIPPET_MAX_CHARS;
23
+ return `${trimmed.slice(0, end)}…`;
24
}
25
const imageCount = entry.attachments.length + entry.droppedImageNames.length;
26
const fileCount = entry.files?.length ?? 0;