11import { AudioPreview } from "../files/AudioPreview" ;
22import { onTestFinished } from "vite-plus/test" ;
3- import { page } from "vite-plus/test/browser" ;
3+ import { page , userEvent } from "vite-plus/test/browser" ;
44import { stubGlobal } from "../../../test/render" ;
55import {
66 EnvironmentId ,
@@ -20,6 +20,7 @@ import "~/index.css";
2020
2121import { act , fakeTimers , render } from "../../../test/render" ;
2222import { MessagesTimeline } from "./MessagesTimeline" ;
23+ import { createWorkspaceFocusController , workspaceAreaProps } from "../../lib/workspaceFocus" ;
2324import { makeStreamingTimelineFixture } from "../../test-fixtures" ;
2425import {
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.
0 commit comments