@devries-cameron20 / t3code-1 / commits / e179cefe7a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): collapsed reasoning previews no longer split an emoji (#35677)

Julius Marminge committed Nov 12, 2026 at 15:46 UTC e179cefe7af97cf17d4d68a5f8e0c16202cd9123
2 files changed +12 -5
apps/web/src/components/chat/MessagesTimeline.browser.test.tsx
+4
@@ -1801,6 +1801,10 @@ describe("compact reasoning math", () => {
1801 "line one\r\nline two\r\n\r\nnext  nbsp wide 😀𝑥
end",
1802 [["text", "line one line two next nbsp wide 😀𝑥 end"]],
1803 ],
1804 + [
1805 + `${"x".repeat(THOUGHT_PREVIEW_MAX_LENGTH - 1)}😀 tail`,
1806 + [["text", "x".repeat(THOUGHT_PREVIEW_MAX_LENGTH - 1)]],
1807 + ],
1808 ["\\$5 and \\$6, \\*not em\\*", [["text", "$5 and $6, *not em*"]]],
1809 ["hard \nbreak\\\nagain", [["text", "hard break again"]]],
1810 ["<div>only html</div>", [["text", "Reasoning"]]],
apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts
+8 -5
@@ -209,17 +209,20 @@ export function remarkThoughtPreview(fallback: string) {
209 children.push({ type: "text", value: fragments.join("").replace(/\s+/g, " ") });
210 fragments = [];
211 };
212 - const append = (value: string) => {
212 + const take = (value: string) => {
213 const text = value.slice(0, remaining);
214 - remaining -= text.length;
215 - fragments.push(text);
214 + remaining = text.length < value.length ? 0 : remaining - text.length;
215 + // A cut here or at the source limit must not leave half a surrogate pair.
216 + return text.replace(/[\uD800-\uDBFF]$/, "");
217 + };
218 + const append = (value: string) => {
219 + fragments.push(take(value));
220 };
221 const visit = (node: Root | RootContent) => {
222 if (remaining === 0 || node.type === "html" || node.type === "definition") return;
223 if (node.type === "math" || node.type === "inlineMath") {
224 flush();
221 - const value = node.value.slice(0, remaining);
222 - remaining -= value.length;
225 + const value = take(node.value);
226 children.push({
227 type: "inlineMath",
228 value,