@@ -35,6 +35,13 @@ import { type HistoryItemToolGroup, StreamingState } from '../ui/types.js';
3535import { ToolActionsProvider } from '../ui/contexts/ToolActionsContext.js' ;
3636import { AskUserActionsProvider } from '../ui/contexts/AskUserActionsContext.js' ;
3737import { TerminalProvider } from '../ui/contexts/TerminalContext.js' ;
38+ import {
39+ OverflowProvider ,
40+ useOverflowActions ,
41+ useOverflowState ,
42+ type OverflowActions ,
43+ type OverflowState ,
44+ } from '../ui/contexts/OverflowContext.js' ;
3845
3946import { makeFakeConfig , type Config } from '@google/gemini-cli-core' ;
4047import { FakePersistentState } from './persistentStateFake.js' ;
@@ -335,6 +342,8 @@ export type RenderInstance = {
335342 lastFrame : ( options ?: { allowEmpty ?: boolean } ) => string ;
336343 terminal : Terminal ;
337344 waitUntilReady : ( ) => Promise < void > ;
345+ capturedOverflowState : OverflowState | undefined ;
346+ capturedOverflowActions : OverflowActions | undefined ;
338347} ;
339348
340349const instances : InkInstance [ ] = [ ] ;
@@ -343,7 +352,10 @@ const instances: InkInstance[] = [];
343352export const render = (
344353 tree : React . ReactElement ,
345354 terminalWidth ?: number ,
346- ) : RenderInstance => {
355+ ) : Omit <
356+ RenderInstance ,
357+ 'capturedOverflowState' | 'capturedOverflowActions'
358+ > => {
347359 const cols = terminalWidth ?? 100 ;
348360 // We use 1000 rows to avoid windows with incorrect snapshots if a correct
349361 // value was used (e.g. 40 rows). The alternatives to make things worse are
@@ -562,6 +574,16 @@ const mockUIActions: UIActions = {
562574 handleNewAgentsSelect : vi . fn ( ) ,
563575} ;
564576
577+ let capturedOverflowState : OverflowState | undefined ;
578+ let capturedOverflowActions : OverflowActions | undefined ;
579+ const ContextCapture : React . FC < { children : React . ReactNode } > = ( {
580+ children,
581+ } ) => {
582+ capturedOverflowState = useOverflowState ( ) ;
583+ capturedOverflowActions = useOverflowActions ( ) ;
584+ return < > { children } </ > ;
585+ } ;
586+
565587export const renderWithProviders = (
566588 component : React . ReactElement ,
567589 {
@@ -663,6 +685,9 @@ export const renderWithProviders = (
663685 . filter ( ( item ) : item is HistoryItemToolGroup => item . type === 'tool_group' )
664686 . flatMap ( ( item ) => item . tools ) ;
665687
688+ capturedOverflowState = undefined ;
689+ capturedOverflowActions = undefined ;
690+
666691 const renderResult = render (
667692 < AppContext . Provider value = { appState } >
668693 < ConfigContext . Provider value = { config } >
@@ -675,35 +700,39 @@ export const renderWithProviders = (
675700 value = { finalUiState . streamingState }
676701 >
677702 < UIActionsContext . Provider value = { finalUIActions } >
678- < ToolActionsProvider
679- config = { config }
680- toolCalls = { allToolCalls }
681- >
682- < AskUserActionsProvider
683- request = { null }
684- onSubmit = { vi . fn ( ) }
685- onCancel = { vi . fn ( ) }
703+ < OverflowProvider >
704+ < ToolActionsProvider
705+ config = { config }
706+ toolCalls = { allToolCalls }
686707 >
687- < KeypressProvider >
688- < MouseProvider
689- mouseEventsEnabled = { mouseEventsEnabled }
690- >
691- < TerminalProvider >
692- < ScrollProvider >
693- < Box
694- width = { terminalWidth }
695- flexShrink = { 0 }
696- flexGrow = { 0 }
697- flexDirection = "column"
698- >
699- { component }
700- </ Box >
701- </ ScrollProvider >
702- </ TerminalProvider >
703- </ MouseProvider >
704- </ KeypressProvider >
705- </ AskUserActionsProvider >
706- </ ToolActionsProvider >
708+ < AskUserActionsProvider
709+ request = { null }
710+ onSubmit = { vi . fn ( ) }
711+ onCancel = { vi . fn ( ) }
712+ >
713+ < KeypressProvider >
714+ < MouseProvider
715+ mouseEventsEnabled = { mouseEventsEnabled }
716+ >
717+ < TerminalProvider >
718+ < ScrollProvider >
719+ < ContextCapture >
720+ < Box
721+ width = { terminalWidth }
722+ flexShrink = { 0 }
723+ flexGrow = { 0 }
724+ flexDirection = "column"
725+ >
726+ { component }
727+ </ Box >
728+ </ ContextCapture >
729+ </ ScrollProvider >
730+ </ TerminalProvider >
731+ </ MouseProvider >
732+ </ KeypressProvider >
733+ </ AskUserActionsProvider >
734+ </ ToolActionsProvider >
735+ </ OverflowProvider >
707736 </ UIActionsContext . Provider >
708737 </ StreamingContext . Provider >
709738 </ SessionStatsProvider >
@@ -718,6 +747,8 @@ export const renderWithProviders = (
718747
719748 return {
720749 ...renderResult ,
750+ capturedOverflowState,
751+ capturedOverflowActions,
721752 simulateClick : ( col : number , row : number , button ?: 0 | 1 | 2 ) =>
722753 simulateClick ( renderResult . stdin , col , row , button ) ,
723754 } ;
0 commit comments