Skip to content

Commit 15d481d

Browse files
fix(web): keep live-follow scrolling in sync with deferred reasoning text
Deferring each entry's text inside a child let WorkLogDetails run its scroll effect before the deferred text committed, leaving readers above the newest trace text. Defer the entries list in ReasoningTraceContent so the commit that grows the content also reruns live-follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6e7dc2d commit 15d481d

1 file changed

Lines changed: 14 additions & 23 deletions

File tree

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

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,41 +118,32 @@ const stopRowToggle = (e: { stopPropagation: () => void }) => e.stopPropagation(
118118
export function ReasoningTraceContent({ entries }: { entries: ReadonlyArray<TimelineWorkEntry> }) {
119119
const ctx = use(TimelineRowCtx);
120120
const { isWorking, latestRunId } = use(TimelineRowActivityCtx);
121+
// Long traces re-parse on every delta; deferring lets newer deltas interrupt a stale render.
122+
// Defer the whole list so the commit that grows the text also reruns live-follow scrolling.
123+
const deferredEntries = useDeferredValue(entries);
121124
const isStreaming = (entry: TimelineWorkEntry) =>
122125
isWorking && entry.runId === latestRunId && entry.toolLifecycleStatus === "inProgress";
123126
return (
124-
<WorkLogDetails followLive={entries.some(isStreaming)}>
125-
{entries.map((entry) => (
126-
<ReasoningTraceMarkdown
127+
<WorkLogDetails followLive={deferredEntries.some(isStreaming)}>
128+
{deferredEntries.map((entry) => (
129+
<ChatMarkdown
127130
key={entry.id}
131+
className="text-foreground"
128132
text={entry.detail ?? ""}
133+
cwd={ctx.markdownCwd}
134+
threadRef={ctx.threadRef ?? undefined}
135+
skills={ctx.skills}
129136
isStreaming={isStreaming(entry)}
137+
headingLevelOffset={MESSAGE_HEADING_LEVEL}
138+
onUseArtifactTemplate={ctx.onUseArtifactTemplate}
139+
onImageExpand={ctx.onImageExpand}
140+
lineBreaks
130141
/>
131142
))}
132143
</WorkLogDetails>
133144
);
134145
}
135146

136-
function ReasoningTraceMarkdown({ text, isStreaming }: { text: string; isStreaming: boolean }) {
137-
const ctx = use(TimelineRowCtx);
138-
// Long traces re-parse on every delta; deferring lets newer deltas interrupt a stale render.
139-
const deferredText = useDeferredValue(text);
140-
return (
141-
<ChatMarkdown
142-
className="text-foreground"
143-
text={deferredText}
144-
cwd={ctx.markdownCwd}
145-
threadRef={ctx.threadRef ?? undefined}
146-
skills={ctx.skills}
147-
isStreaming={isStreaming}
148-
headingLevelOffset={MESSAGE_HEADING_LEVEL}
149-
onUseArtifactTemplate={ctx.onUseArtifactTemplate}
150-
onImageExpand={ctx.onImageExpand}
151-
lineBreaks
152-
/>
153-
);
154-
}
155-
156147
type WorkEntryRowProps = {
157148
workEntry: TimelineWorkEntry;
158149
workspaceRoot: string | undefined;

0 commit comments

Comments
 (0)