GeezerVison is showing github.com — perf(web): an expanded thinking row no longer re-parses the whole rea… · pingdotgg/t3code@caea7c4
File treeExpand file treeCollapse file tree Open diff view settings apps/web/src/components/chat
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/MessagesTimeline.browser.test.tsx +35Lines changed: 35 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -368,6 +368,41 @@ describe("MessagesTimeline agent messages", () => { | 368 | 368 | }); | 369 | 369 | }); | 370 | 370 |
| | 371 | +describe("MessagesTimeline live reasoning", () => { | | 372 | + it("labels an expanded live thought from its opening instead of the whole trace", async () => { | | 373 | + const runId = RunId.make("thinking-run"); | | 374 | + const trace = `Checking the **parser** first. ${"Then the next file. ".repeat(1_000)}`; | | 375 | + await using screen = await renderTimeline( | | 376 | + [ | | 377 | + { | | 378 | + kind: "work", | | 379 | + id: "thought", | | 380 | + createdAt: CREATED_AT, | | 381 | + entry: { | | 382 | + id: "thought", | | 383 | + runId, | | 384 | + createdAt: CREATED_AT, | | 385 | + label: "Thinking", | | 386 | + tone: "thinking", | | 387 | + itemType: "reasoning", | | 388 | + detail: trace, | | 389 | + toolLifecycleStatus: "inProgress", | | 390 | + }, | | 391 | + }, | | 392 | + ], | | 393 | + { isWorking: true, activeTurnInProgress: true, runningRunId: runId }, | | 394 | + ); | | 395 | + const row = () => screen.container.querySelector<HTMLElement>("button[aria-expanded]")!; | | 396 | + await click(row()); | | 397 | + await vi.waitFor(() => expect(row().getAttribute("aria-expanded")).toBe("true")); | | 398 | + | | 399 | + const label = row().textContent ?? ""; | | 400 | + expect(label.startsWith("Checking the parser first. Then the next file.")).toBe(true); | | 401 | + // The label is one truncated line, so streaming a long trace must not flatten all of it. | | 402 | + expect(label.length).toBeLessThan(trace.length / 4); | | 403 | + }); | | 404 | +}); | | 405 | + | 371 | 406 | describe("compact reasoning math", () => { | 372 | 407 | it("keeps formulas while flattening compact reasoning previews", () => { | 373 | 408 | const tree = parseMarkdownWithMath("## Reasoning\n\nUse **norm** $|x|$ and \\[x^2\\]"); | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -188,6 +188,11 @@ export function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconNa | 188 | 188 | return workToneIcon(workEntry.tone).iconName; | 189 | 189 | } | 190 | 190 |
| | 191 | +/** The preview is one truncated line; bound parsing work while long traces stream. */ | | 192 | +export function thoughtPreviewSource(markdown: string): string { | | 193 | + return markdown.slice(0, 1_500); | | 194 | +} | | 195 | + | 191 | 196 | /** Compact reasoning keeps formulas while flattening other Markdown into label text. */ | 192 | 197 | export function remarkThoughtPreview(fallback: string) { | 193 | 198 | return (tree: Root) => { | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/TimelineWorkEntryRow.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -64,6 +64,7 @@ import { | 64 | 64 | buildToolCallExpandedBody, | 65 | 65 | workEntryIconName, | 66 | 66 | remarkThoughtPreview, | | 67 | + thoughtPreviewSource, | 67 | 68 | } from "./TimelineWorkEntryRow.logic"; | 68 | 69 |
| 69 | 70 | export function useThreadReadTarget(entry: TimelineWorkEntry, environmentId: EnvironmentId) { | @@ -411,7 +412,7 @@ function WorkEntryLogRow(props: WorkEntryRowProps) { | 411 | 412 | {isReasoning && !expanded ? ( | 412 | 413 | <ChatMarkdown | 413 | 414 | inline | 414 | | - text={workEntry.detail ?? previewText} | | 415 | + text={thoughtPreviewSource(workEntry.detail ?? previewText)} | 415 | 416 | cwd={ctx.markdownCwd} | 416 | 417 | parseRawHtml={false} | 417 | 418 | extraRemarkPlugins={[ | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/TimelineWorkGroupRows.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,6 +52,7 @@ import { | 52 | 52 | } from "./TimelineWorkEntryRow"; | 53 | 53 | import { | 54 | 54 | remarkThoughtPreview, | | 55 | + thoughtPreviewSource, | 55 | 56 | toolGroupSummaryIconName, | 56 | 57 | workEntryIconName, | 57 | 58 | } from "./TimelineWorkEntryRow.logic"; | @@ -558,7 +559,7 @@ export function LiveWorkEntryTimelineRow({ | 558 | 559 | ) : row.entry.itemType === "reasoning" ? ( | 559 | 560 | <ChatMarkdown | 560 | 561 | inline | 561 | | - text={row.entry.detail ?? label} | | 562 | + text={thoughtPreviewSource(row.entry.detail ?? label)} | 562 | 563 | cwd={ctx.markdownCwd} | 563 | 564 | parseRawHtml={false} | 564 | 565 | extraRemarkPlugins={[[remarkThoughtPreview, row.active ? "Thinking" : "Thought"]]} | |
|