GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): reasoning previews no longer cut emojis in half (#42755) · patroza/t3code@f99eceb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/chat
    • MessagesTimeline.browser.test.tsx
    • TimelineWorkEntryRow.logic.ts
    • TimelineWorkEntryRow.tsx
    • TimelineWorkGroupRows.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/chat/MessagesTimeline.browser.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/MessagesTimeline.browser.test.tsx
+27-1Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ import {
4343
deriveTimelineEntriesFromVisibleTurnItems,
4444
} from "../../session-logic";
4545
import { ViewedImagesTimelineRow } from "./TimelineWorkEntryRow";
46-
import { THOUGHT_PREVIEW_MAX_LENGTH, thoughtPreviewMarkdown } from "./TimelineWorkEntryRow.logic";
46+
import {
47+
THOUGHT_PREVIEW_MAX_LENGTH,
48+
THOUGHT_PREVIEW_SOURCE_MAX_LENGTH,
49+
thoughtPreviewMarkdown,
50+
} from "./TimelineWorkEntryRow.logic";
4751
import { wordsHast } from "~/markdown/wordsHast";
4852
import { TimelineRowCtx } from "./timelineRowContext";
4953
import { searchableMessageSegments } from "@t3tools/shared/threadFindText";
@@ -2302,6 +2306,28 @@ describe("compact reasoning math", () => {
23022306
),
23032307
).toEqual(expected);
23042308
});
2309+
2310+
it("does not split a surrogate pair at the reasoning preview source limit", async () => {
2311+
setup();
2312+
const prefix = `[l](${"u".repeat(8_100)}) `;
2313+
const filler = "c".repeat(THOUGHT_PREVIEW_SOURCE_MAX_LENGTH - 1 - prefix.length);
2314+
await using screen = await renderTimeline(
2315+
[
2316+
work("thought-1", {
2317+
label: "Thinking",
2318+
tone: "thinking",
2319+
itemType: "reasoning",
2320+
toolLifecycleStatus: "inProgress",
2321+
detail: `${prefix}${filler}😀 tail`,
2322+
}),
2323+
],
2324+
{ isWorking: true },
2325+
);
2326+
await vi.waitFor(() => {
2327+
expect(screen.text()).toContain(`l ${filler}`);
2328+
});
2329+
expect(screen.text()).not.toContain("\uFFFD");
2330+
});
23052331
});
23062332

23072333
it("renders automatic compaction as one live divider that finishes with its reason and token delta", async () => {
Collapse file

‎apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
resolveWorkEntryToolPresentation,
55
toolGroupAction,
66
} from "@t3tools/client-runtime/work-log/presentation";
7+
import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations";
78
import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
89
import { formatWorkspaceRelativePath } from "../../filePathDisplay";
910
import { m, type MessageResolver } from "../../i18n/messages";
@@ -208,6 +209,15 @@ export function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconNa
208209
export const THOUGHT_PREVIEW_SOURCE_MAX_LENGTH = 8_192;
209210
export const THOUGHT_PREVIEW_MAX_LENGTH = 2_048;
210211

212+
export function sliceThoughtPreviewSource(text: string): string {
213+
return text.slice(
214+
0,
215+
splitsSurrogatePair(text, THOUGHT_PREVIEW_SOURCE_MAX_LENGTH)
216+
? THOUGHT_PREVIEW_SOURCE_MAX_LENGTH - 1
217+
: THOUGHT_PREVIEW_SOURCE_MAX_LENGTH,
218+
);
219+
}
220+
211221
const thoughtPreviews = new Map<string, MarkdownExtensions>();
212222

213223
/** Compact reasoning keeps formulas while flattening other Markdown into label text. */
Collapse file

‎apps/web/src/components/chat/TimelineWorkEntryRow.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/TimelineWorkEntryRow.tsx
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ import {
7979
workEntryRawCommand,
8080
buildToolCallExpandedBody,
8181
workEntryIconName,
82+
sliceThoughtPreviewSource,
8283
thoughtPreviewMarkdown,
83-
THOUGHT_PREVIEW_SOURCE_MAX_LENGTH,
8484
} from "./TimelineWorkEntryRow.logic";
8585

8686
export function useThreadReadTarget(entry: TimelineWorkEntry, environmentId: EnvironmentId) {
@@ -603,10 +603,7 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
603603
{isReasoning && !expanded ? (
604604
<ChatMarkdown
605605
inline
606-
text={(workEntry.detail ?? previewText).slice(
607-
0,
608-
THOUGHT_PREVIEW_SOURCE_MAX_LENGTH,
609-
)}
606+
text={sliceThoughtPreviewSource(workEntry.detail ?? previewText)}
610607
cwd={ctx.markdownCwd}
611608
parseRawHtml={false}
612609
extensions={
Collapse file

‎apps/web/src/components/chat/TimelineWorkGroupRows.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/TimelineWorkGroupRows.tsx
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ import {
5757
SimpleWorkEntryRow,
5858
} from "./TimelineWorkEntryRow";
5959
import {
60+
sliceThoughtPreviewSource,
6061
thoughtPreviewMarkdown,
61-
THOUGHT_PREVIEW_SOURCE_MAX_LENGTH,
6262
toolGroupSummaryIconName,
6363
workEntryIconName,
6464
} from "./TimelineWorkEntryRow.logic";
@@ -631,7 +631,7 @@ export function LiveWorkEntryTimelineRow({
631631
const failed = workEntryDisplayIndicatesToolFailure(row.entry);
632632
const thoughtLine =
633633
row.thought && !row.expanded
634-
? liveThoughtLine((row.thought.detail ?? "").slice(0, THOUGHT_PREVIEW_SOURCE_MAX_LENGTH))
634+
? liveThoughtLine(sliceThoughtPreviewSource(row.thought.detail ?? ""))
635635
: "";
636636
const thoughtIsStatus = thoughtLine !== "" && row.entry === row.thought;
637637

@@ -689,7 +689,7 @@ export function LiveWorkEntryTimelineRow({
689689
) : row.entry.itemType === "reasoning" ? (
690690
<ChatMarkdown
691691
inline
692-
text={(row.entry.detail ?? label).slice(0, THOUGHT_PREVIEW_SOURCE_MAX_LENGTH)}
692+
text={sliceThoughtPreviewSource(row.entry.detail ?? label)}
693693
cwd={ctx.markdownCwd}
694694
parseRawHtml={false}
695695
extensions={

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.