1+ import type { ScrollBoxRenderable } from '@opentui/core' ;
12import type { WorkspaceRequest } from '@t-req/sdk/client' ;
23import fuzzysort from 'fuzzysort' ;
34import {
@@ -11,7 +12,7 @@ import {
1112 Show
1213} from 'solid-js' ;
1314import { useDialog , useStore } from '../context' ;
14- import { usePickerNavigation } from '../hooks' ;
15+ import { usePickerNavigation , useScrollToIndex } from '../hooks' ;
1516import { isHttpFile , isRunnableScript , isTestFile } from '../store' ;
1617import { rgba , theme } from '../theme' ;
1718import { RequestPicker } from './request-picker' ;
@@ -39,6 +40,7 @@ const CONFIRM_TIMEOUT_MS = 2000;
3940export function FileRequestPicker ( props : FileRequestPickerProps ) : JSX . Element {
4041 const store = useStore ( ) ;
4142 const dialog = useDialog ( ) ;
43+ const [ scrollRef , setScrollRef ] = createSignal < ScrollBoxRenderable | undefined > ( undefined ) ;
4244
4345 const [ query , setQuery ] = createSignal ( '' ) ;
4446 const [ pendingSendId , setPendingSendId ] = createSignal < string | undefined > ( undefined ) ;
@@ -184,6 +186,12 @@ export function FileRequestPicker(props: FileRequestPickerProps): JSX.Element {
184186 }
185187 } ) ;
186188
189+ useScrollToIndex ( {
190+ scrollRef,
191+ selectedIndex : clampedIndex ,
192+ itemCount : ( ) => filteredItems ( ) . length
193+ } ) ;
194+
187195 // Clear pending send when query or selection changes
188196 createEffect ( ( ) => {
189197 query ( ) ;
@@ -243,7 +251,12 @@ export function FileRequestPicker(props: FileRequestPickerProps): JSX.Element {
243251 </ box >
244252
245253 { /* Items list */ }
246- < box flexDirection = "column" maxHeight = { 10 } >
254+ < scrollbox
255+ ref = { ( r ) => {
256+ setScrollRef ( r ) ;
257+ } }
258+ height = { 10 }
259+ >
247260 < For each = { filteredItems ( ) } >
248261 { ( item , idx ) => {
249262 const isSelected = ( ) => idx ( ) === clampedIndex ( ) ;
@@ -254,6 +267,7 @@ export function FileRequestPicker(props: FileRequestPickerProps): JSX.Element {
254267 return (
255268 < box
256269 height = { 1 }
270+ flexShrink = { 0 }
257271 paddingLeft = { 2 }
258272 paddingRight = { 2 }
259273 flexDirection = "row"
@@ -288,7 +302,7 @@ export function FileRequestPicker(props: FileRequestPickerProps): JSX.Element {
288302 < text fg = { rgba ( theme . textMuted ) } > No matches</ text >
289303 </ box >
290304 </ Show >
291- </ box >
305+ </ scrollbox >
292306
293307 { /* Action bar */ }
294308 < box height = { 1 } paddingLeft = { 2 } flexDirection = "row" gap = { 2 } >
0 commit comments