Skip to content

Commit d93cf67

Browse files
committed
Baseline merge
1 parent 547f5d4 commit d93cf67

31 files changed

+1457
-260
lines changed

packages/cli/src/gemini.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import { createPolicyUpdater } from './config/policy.js';
102102
import { ScrollProvider } from './ui/contexts/ScrollProvider.js';
103103
import { isAlternateBufferEnabled } from './ui/hooks/useAlternateBuffer.js';
104104
import { TerminalProvider } from './ui/contexts/TerminalContext.js';
105+
import { OverflowProvider } from './ui/contexts/OverflowContext.js';
105106

106107
import { setupTerminalAndTheme } from './utils/terminalTheme.js';
107108
import { profiler } from './ui/components/DebugProfiler.js';
@@ -238,17 +239,19 @@ export async function startInteractiveUI(
238239
>
239240
<TerminalProvider>
240241
<ScrollProvider>
241-
<SessionStatsProvider>
242-
<VimModeProvider settings={settings}>
243-
<AppContainer
244-
config={config}
245-
startupWarnings={startupWarnings}
246-
version={version}
247-
resumedSessionData={resumedSessionData}
248-
initializationResult={initializationResult}
249-
/>
250-
</VimModeProvider>
251-
</SessionStatsProvider>
242+
<OverflowProvider>
243+
<SessionStatsProvider>
244+
<VimModeProvider settings={settings}>
245+
<AppContainer
246+
config={config}
247+
startupWarnings={startupWarnings}
248+
version={version}
249+
resumedSessionData={resumedSessionData}
250+
initializationResult={initializationResult}
251+
/>
252+
</VimModeProvider>
253+
</SessionStatsProvider>
254+
</OverflowProvider>
252255
</ScrollProvider>
253256
</TerminalProvider>
254257
</MouseProvider>

packages/cli/src/test-utils/render.tsx

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ import { type HistoryItemToolGroup, StreamingState } from '../ui/types.js';
3535
import { ToolActionsProvider } from '../ui/contexts/ToolActionsContext.js';
3636
import { AskUserActionsProvider } from '../ui/contexts/AskUserActionsContext.js';
3737
import { 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

3946
import { makeFakeConfig, type Config } from '@google/gemini-cli-core';
4047
import { 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

340349
const instances: InkInstance[] = [];
@@ -343,7 +352,10 @@ const instances: InkInstance[] = [];
343352
export 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+
565587
export 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

Comments
 (0)