From 5c5e576c10d74c443bb94e8e8785114c8346cc91 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 22 Oct 2026 08:53:44 +0200 Subject: [PATCH 1/2] fix(ui): the feed stays at its end when its box resizes, and the Queue test polls the address (#853) --- e2e/console/queue.spec.ts | 2 +- ui/src/ds/feed.tsx | 53 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/e2e/console/queue.spec.ts b/e2e/console/queue.spec.ts index db411a4e0..9492cabe9 100644 --- a/e2e/console/queue.spec.ts +++ b/e2e/console/queue.spec.ts @@ -181,7 +181,7 @@ test.describe("the Queue page", () => { await expect(page.getByText("Request not waiting.")).toBeVisible({ timeout: 1_000 }); await page.keyboard.press("Escape"); - expect(new URL(page.url()).pathname).toBe("/queue"); + await expect.poll(() => new URL(page.url()).pathname).toBe("/queue"); await expect(row(page, "agent-b")).toHaveCount(0); await expect(page.getByText("No requests are waiting.")).toBeVisible(); await expect(page.getByRole("dialog")).toHaveCount(0); diff --git a/ui/src/ds/feed.tsx b/ui/src/ds/feed.tsx index f2285314e..2232cd47c 100644 --- a/ui/src/ds/feed.tsx +++ b/ui/src/ds/feed.tsx @@ -1,7 +1,15 @@ import "./feed.css"; import { useVirtualizer } from "@tanstack/react-virtual"; -import { type CSSProperties, Fragment, type ReactNode, useEffect, useRef, useState } from "react"; +import { + type CSSProperties, + Fragment, + type ReactNode, + type RefObject, + useEffect, + useRef, + useState, +} from "react"; // why: the box's height and a row's before either is measured: what a first draw lays out. A row's // height is fixed (the caller's rows do not wrap), so no row is measured as it is drawn. @@ -56,6 +64,7 @@ export function Feed(props: { overscan: OVERSCAN, }); useOpenAt(startAt, virtualizer); + const atEnd = useStayAtEnd(box); const toTop = () => { virtualizer.scrollToOffset(0); box.current?.focus(); @@ -77,7 +86,11 @@ export function Feed(props: { role="region" aria-label={label} tabIndex={0} - onScroll={(event) => setAtTop(event.currentTarget.scrollTop < 1)} + onScroll={(event) => { + const target = event.currentTarget; + setAtTop(target.scrollTop < 1); + atEnd.current = target.scrollHeight - target.scrollTop - target.clientHeight < 2; + }} >