diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 08a3a2155b..c58b8d22d7 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2446,11 +2446,31 @@ const MessagesTimeline = memo(function MessagesTimeline({ return nextRows; }, [timelineEntries, completionDividerBeforeEntryId, isWorking]); + // Split rows: completed turns are virtualized, current in-progress turn is not. + // The current turn starts at the last user message when actively working. + const currentTurnStartIndex = useMemo(() => { + if (!isWorking) return rows.length; + for (let i = rows.length - 1; i >= 0; i--) { + const row = rows[i]; + if (row?.kind === "message" && row.message.role === "user") return i; + } + return rows.length; + }, [rows, isWorking]); + + const virtualizedRows = useMemo( + () => rows.slice(0, currentTurnStartIndex), + [rows, currentTurnStartIndex], + ); + const currentTurnRows = useMemo( + () => rows.slice(currentTurnStartIndex), + [rows, currentTurnStartIndex], + ); + const rowVirtualizer = useVirtualizer({ - count: rows.length, + count: virtualizedRows.length, getScrollElement: () => scrollContainerRef.current, estimateSize: (index: number) => { - const row = rows[index]; + const row = virtualizedRows[index]; if (!row) return 96; if (row.kind === "work") return 112; if (row.kind === "working") return 40; @@ -2472,292 +2492,306 @@ const MessagesTimeline = memo(function MessagesTimeline({ ); } - return ( -
+ {groupLabel} +
+ {hasOverflow && ( + + )} ++ {workEntry.detail ? ( + <> + {workEntry.label} + + {workEntry.detail} + + > + ) : ( + workEntry.label + )} +
+
+ {row.message.text}
+
+ )}
+ + {formatTimestamp(row.message.createdAt)} +
+- {groupLabel} + Changed files ({changedFileCountLabel}) + {(summaryStat.additions > 0 || summaryStat.deletions > 0) && ( + <> + • + +{summaryStat.additions} + / + + -{summaryStat.deletions} + + > + )}
- {hasOverflow && ( - - )} ++ {formatMessageMeta( + row.message.createdAt, + row.message.streaming + ? formatElapsed(row.message.createdAt, nowIso) + : formatElapsed(row.message.createdAt, row.message.completedAt), + )} +
+
- {row.message.text}
-
- )}
- - {formatTimestamp(row.message.createdAt)} -
-- Changed files ({changedFileCountLabel}) - {(summaryStat.additions > 0 || summaryStat.deletions > 0) && ( - <> - • - +{summaryStat.additions} - / - - -{summaryStat.deletions} - - > - )} -
- -- {formatMessageMeta( - row.message.createdAt, - row.message.streaming - ? formatElapsed(row.message.createdAt, nowIso) - : formatElapsed(row.message.createdAt, row.message.completedAt), - )} -
-