Skip to content

Commit af39cb7

Browse files
fix(web): conversation focus ring stays whole, and a timeline test guards the focusable scroller
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3b11d3f commit af39cb7

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.browser.test.tsx‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AudioPreview } from "../files/AudioPreview";
22
import { onTestFinished } from "vite-plus/test";
3-
import { page } from "vite-plus/test/browser";
3+
import { page, userEvent } from "vite-plus/test/browser";
44
import { stubGlobal } from "../../../test/render";
55
import {
66
EnvironmentId,
@@ -20,6 +20,7 @@ import "~/index.css";
2020

2121
import { act, fakeTimers, render } from "../../../test/render";
2222
import { MessagesTimeline } from "./MessagesTimeline";
23+
import { createWorkspaceFocusController, workspaceAreaProps } from "../../lib/workspaceFocus";
2324
import { makeStreamingTimelineFixture } from "../../test-fixtures";
2425
import {
2526
type PendingApproval,
@@ -254,6 +255,36 @@ describe("MessagesTimeline messages", () => {
254255
await expectHeadingInView("Last turn", "Turn 118:");
255256
});
256257

258+
it("scrolls from the keyboard once F6 moves into the conversation", async () => {
259+
setup();
260+
const props = baseProps();
261+
const entries = Array.from({ length: 40 }, (_, index) =>
262+
message(`Turn ${index}:\n\n${"x ".repeat(200)}`, {}, `turn-${index}`),
263+
);
264+
await using _screen = await renderElement(
265+
<>
266+
<div
267+
{...workspaceAreaProps("conversation", 1, "Conversation")}
268+
className="relative flex min-h-0 flex-1 flex-col"
269+
>
270+
<MessagesTimeline {...props} timelineEntries={entries} />
271+
</div>
272+
<div {...workspaceAreaProps("composer", 2, "Message input")}>
273+
<button type="button">Send</button>
274+
</div>
275+
</>,
276+
);
277+
const focus = createWorkspaceFocusController(document);
278+
using _focus = { [Symbol.dispose]: focus.dispose };
279+
const viewport = props.listRef.current!.getScrollableNode()!;
280+
await vi.waitFor(() => expect(viewport.scrollTop).toBeGreaterThan(0));
281+
const atEnd = viewport.scrollTop;
282+
page.getByRole("button", { name: "Send" }).element().focus();
283+
focus.move(-1);
284+
await userEvent.keyboard("{PageUp}");
285+
await vi.waitFor(() => expect(viewport.scrollTop).toBeLessThan(atEnd));
286+
});
287+
257288
it("keeps rows in item order after a reload or thread switch, before any timer runs", async () => {
258289
setup();
259290
// NVDA's browse mode keeps the first DOM order it reads, so a timer that sorts rows later is too late.

‎apps/web/src/index.css‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,9 +2540,14 @@ code {
25402540
}
25412541
}
25422542

2543-
/* A workspace area or timeline that takes F6 focus itself, not a control; keep that visible. */
2543+
/* A workspace area with no control of its own takes F6 focus itself; keep that visible.
2544+
The conversation's timeline takes it instead, and its top fade mask would hide its own ring. */
25442545
[data-workspace-area]:focus-visible,
2545-
.messages-timeline-scroll:focus-visible {
2546+
[data-workspace-area="conversation"]:has(.messages-timeline-scroll:focus-visible) {
25462547
outline: 2px solid var(--ring);
25472548
outline-offset: -2px;
25482549
}
2550+
2551+
.messages-timeline-scroll:focus-visible {
2552+
outline: none;
2553+
}

0 commit comments

Comments
 (0)