Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(chat): keep following rapid live output (#7018)
Tobin04fd64b41095
diff --git a/packages/views/chat/components/chat-message-list.test.tsx b/packages/views/chat/components/chat-message-list.test.tsxindex 134e903cab..cbada14519 100644--- a/packages/views/chat/components/chat-message-list.test.tsx+++ b/packages/views/chat/components/chat-message-list.test.tsx@@ -20,16 +20,21 @@ vi.mock("react-virtuoso", () => ({computeItemKey,components,context,+ followOutput,}: {data: unknown[];itemContent: (i: number, item: unknown) => ReactElement;computeItemKey: (i: number, item: unknown) => string;components?: { Footer?: (p: { context?: unknown }) => ReactElement | null };context?: unknown;+ followOutput?: (atBottom: boolean) => "smooth" | "auto" | false;}) => {const Footer = components?.Footer;return (- <div>+ <div+ data-follow-at-bottom={String(followOutput?.(true))}+ data-follow-away-from-bottom={String(followOutput?.(false))}+ >{data.map((item, i) => (<div key={computeItemKey(i, item)} data-row-key={computeItemKey(i, item)}>{itemContent(i, item)}@@ -88,6 +93,46 @@ function pushTaskMessage(qc: QueryClient, msg: TaskMessagePayload) {});}+describe("ChatMessageList live follow (#6697)", () => {+ it("follows appended output immediately only while Virtuoso is at the live end", () => {+ const { container } = render(+ <I18nProvider locale="en" resources={TEST_RESOURCES}>+ <QueryClientProvider client={new QueryClient()}>+ <ChatMessageList+ messages={[]}+ pendingTask={null}+ availability="online"+ />+ </QueryClientProvider>+ </I18nProvider>,+ );++ const list = container.querySelector("[data-follow-at-bottom]");+ expect(list).toHaveAttribute("data-follow-at-bottom", "auto");+ expect(list).toHaveAttribute("data-follow-away-from-bottom", "false");+ });++ it("does not follow while older history is being prepended", () => {+ const { container } = render(+ <I18nProvider locale="en" resources={TEST_RESOURCES}>+ <QueryClientProvider client={new QueryClient()}>+ <ChatMessageList+ messages={[]}+ pendingTask={null}+ availability="online"+ isFetchingOlderMessages+ />+ </QueryClientProvider>+ </I18nProvider>,+ );++ expect(container.querySelector("[data-follow-at-bottom]")).toHaveAttribute(+ "data-follow-at-bottom",+ "false",+ );+ });+});+describe("ChatMessageList live timeline (MUL-3960 regression)", () => {// The live footer is passed to Virtuoso through `components`. If that prop// is rebuilt inline on render, every streamed task:message unmounts anddiff --git a/packages/views/chat/components/chat-message-list.tsx b/packages/views/chat/components/chat-message-list.tsxindex ca3e31400b..18e8cb3e62 100644--- a/packages/views/chat/components/chat-message-list.tsx+++ b/packages/views/chat/components/chat-message-list.tsx@@ -185,7 +185,6 @@ export function ChatMessageList({}: ChatMessageListProps) {const scrollRef = useRef<HTMLDivElement>(null);const [scrollContainerEl, setScrollContainerEl] = useState<HTMLDivElement | null>(null);- const [isNearBottom, setIsNearBottom] = useState(true);const setScrollContainerRef = useCallback((node: HTMLDivElement | null) => {scrollRef.current = node;setScrollContainerEl(node);@@ -329,8 +328,13 @@ export function ChatMessageList({initialTopMostItemIndex={{ index: "LAST", align: "end" }}increaseViewportBy={{ top: 400, bottom: 600 }}atBottomThreshold={120}- atBottomStateChange={setIsNearBottom}- followOutput={() => (!isFetchingOlderMessages && isNearBottom ? "smooth" : false)}+ // Follow rapid streamed output only while Virtuoso says the reader is+ // at the live end. An in-flight smooth animation temporarily reports+ // "not at bottom" on the next append and permanently drops the follow+ // (#6697), so live growth must use an immediate scroll.+ followOutput={(atBottom) =>+ !isFetchingOlderMessages && atBottom ? "auto" : false+ }startReached={() => {if (hasOlderMessages && !isFetchingOlderMessages) {onLoadOlderMessages?.();