The best way to control Claude Code, Codex and more from any computer or phone
fix(web): streaming replies no longer re-render every visible timeline row (#27420)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 30, 2026 at 02:10 UTC
5cbc207d8c8e92964b36e235740f22b49d938352
2 files changed
+28
-17
apps/web/src/components/chat/MessagesTimeline.tsx
+25
-17
@@ -659,12 +659,11 @@ const ConversationTimeline = memo(function ConversationTimeline({
659
? new Set(paintedExpandedAttemptIds).add(activeFindAttemptId)
660
: paintedExpandedAttemptIds;
661
662
- const pendingApprovalsByRequestId = new Map(
663
- pendingApprovals
664
- .filter((approval) => !heldApprovalRequestIds?.has(approval.requestId))
665
- .map((approval) => [approval.requestId, approval]),
662
+ const isVisiblePendingApproval = (approval: PendingApproval) =>
663
+ !heldApprovalRequestIds?.has(approval.requestId);
664
+ const pendingApprovalRequestIds = new Set(
665
+ pendingApprovals.filter(isVisiblePendingApproval).map((approval) => approval.requestId),
666
);
667
- const pendingApprovalRequestIds = new Set(pendingApprovalsByRequestId.keys());
667
const rawRows = useIncrementalTimelineRows(`${listIdentityKey}\0${workspaceRoot ?? ""}`, {
668
timelineEntries,
669
pendingApprovalRequestIds,
@@ -683,17 +682,19 @@ const ConversationTimeline = memo(function ConversationTimeline({
682
worktreeSetup,
683
});
684
const rows = useStableRows(rawRows, listIdentityKey);
686
- const unmatchedPendingApprovals = new Map(pendingApprovalsByRequestId);
687
- if (unmatchedPendingApprovals.size > 0) {
688
- for (const row of rows) {
689
- const entries =
690
- row.kind === "work" ? row.groupedEntries : row.kind === "work-live" ? [row.entry] : [];
691
- for (const entry of entries) {
692
- const item = entry.projectedItem?.item;
693
- if (item?.type === "approval_request") unmatchedPendingApprovals.delete(item.requestId);
694
- }
685
+ const matchedApprovalRequestIds = new Set<string>();
686
+ for (const row of pendingApprovalRequestIds.size > 0 ? rows : []) {
687
+ const entries =
688
+ row.kind === "work" ? row.groupedEntries : row.kind === "work-live" ? [row.entry] : [];
689
+ for (const entry of entries) {
690
+ const item = entry.projectedItem?.item;
691
+ if (item?.type === "approval_request") matchedApprovalRequestIds.add(item.requestId);
692
}
693
}
694
+ const unmatchedPendingApprovals = pendingApprovals.filter(
695
+ (approval) =>
696
+ isVisiblePendingApproval(approval) && !matchedApprovalRequestIds.has(approval.requestId),
697
+ );
698
// Run status/timestamps change per stream event; keep them out of shared row context.
699
const runs = useStableHandoffRuns(runsProp);
700
const minimapItems = deriveTimelineMinimapItems(rows);
@@ -706,7 +707,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
707
restoringThreadPosition && restoreRowIndex >= 0 ? { indices: [restoreRowIndex] } : undefined;
708
const showsEmptyState =
709
rows.length === 0 &&
709
- unmatchedPendingApprovals.size === 0 &&
710
+ unmatchedPendingApprovals.length === 0 &&
711
!isWorking &&
712
parentThreadLink === null &&
713
historyControls === undefined &&
@@ -1000,6 +1001,13 @@ const ConversationTimeline = memo(function ConversationTimeline({
1001
};
1002
};
1003
1004
+ // Built from props after the last hook so the compiler can memoize the row context; a map
1005
+ // made before a hook would rebuild it, and re-render every row, on each streamed update.
1006
+ const pendingApprovalsByRequestId = new Map(
1007
+ pendingApprovals
1008
+ .filter(isVisiblePendingApproval)
1009
+ .map((approval) => [approval.requestId, approval]),
1010
+ );
1011
const sharedState: TimelineRowSharedState = {
1012
pendingApprovals: pendingApprovalsByRequestId,
1013
respondingRequestIds,
@@ -1238,12 +1246,12 @@ const ConversationTimeline = memo(function ConversationTimeline({
1246
onGrow={onFooterGrow}
1247
>
1248
{footer}
1241
- {unmatchedPendingApprovals.size > 0 ? (
1249
+ {unmatchedPendingApprovals.length > 0 ? (
1250
<TimelineRowCtx value={sharedState}>
1251
<div className="messages-timeline-row-frame">
1252
<div className="chat-content-lane overflow-x-clip" data-timeline-root="true">
1253
<WorkLogBlock>
1246
- {[...unmatchedPendingApprovals.values()].map((approval) => (
1254
+ {unmatchedPendingApprovals.map((approval) => (
1255
<TimelinePendingApprovalRow key={approval.requestId} approval={approval} />
1256
))}
1257
</WorkLogBlock>
apps/web/test/appScenarios.renders.tsx
+3
@@ -201,6 +201,9 @@ it("app-stream-assistant-turn", async () => {
201
.element(page.getByText(`word${STREAM_DELTAS - 1}`, { exact: false }))
202
.toBeVisible();
203
});
204
+ // Only the streaming row changes; history rows must not re-render with it.
205
+ expect(counted.components.UserTimelineRow).toBeUndefined();
206
+ expect(counted.components.AssistantTimelineRow).toBe(STREAM_DELTAS);
207
await report("app-stream-assistant-turn", [counted], { commits: false });
208
});
209