diff --git a/packages/cli/src/test-utils/render.tsx b/packages/cli/src/test-utils/render.tsx index 6908fd36fb..366e7d5619 100644 --- a/packages/cli/src/test-utils/render.tsx +++ b/packages/cli/src/test-utils/render.tsx @@ -211,7 +211,7 @@ class XtermStdout extends EventEmitter { } await act(async () => { if (vi.isFakeTimers()) { - await vi.advanceTimersByTimeAsync(50); + await vi.advanceTimersByTimeAsync(200); } else { // Wait for at least one render to be called if we haven't rendered yet or since start of this call, // but don't wait forever as some renders might be synchronous or skipped. @@ -220,7 +220,7 @@ class XtermStdout extends EventEmitter { this.once('render', resolve), ); const timeoutPromise = new Promise((resolve) => - setTimeout(resolve, 50), + setTimeout(resolve, 200), ); await Promise.race([renderPromise, timeoutPromise]); } @@ -264,6 +264,13 @@ class XtermStdout extends EventEmitter { return true; } + if (this.lastRenderOutput === undefined && currentFrame !== '') { + // If Ink hasn't reported a render yet but terminal has content, + // it means a render happened but metrics weren't captured or reported yet. + // In this case, we consider it a match if we are just waiting for "anything" (empty expected). + return true; + } + if (this.lastRenderOutput === undefined) { return false; } @@ -528,12 +535,13 @@ export const mockSettings = new LoadedSettings( // A minimal mock UIState to satisfy the context provider. // Tests that need specific UIState values should provide their own. const baseMockUiState = { + history: [], renderMarkdown: true, streamingState: StreamingState.Idle, terminalWidth: 100, terminalHeight: 40, currentModel: 'gemini-pro', - terminalBackgroundColor: 'black', + terminalBackgroundColor: 'black' as const, cleanUiDetailsVisible: false, allowPlanMode: true, activePtyId: undefined, @@ -552,6 +560,9 @@ const baseMockUiState = { warningText: '', }, bannerVisible: false, + nightly: false, + updateInfo: null, + pendingHistoryItems: [], }; export const mockAppState: AppState = { diff --git a/packages/cli/src/ui/__snapshots__/App.test.tsx.snap b/packages/cli/src/ui/__snapshots__/App.test.tsx.snap index 8b3308803d..4ef43ad93c 100644 --- a/packages/cli/src/ui/__snapshots__/App.test.tsx.snap +++ b/packages/cli/src/ui/__snapshots__/App.test.tsx.snap @@ -4,8 +4,8 @@ exports[`App > Snapshots > renders default layout correctly 1`] = ` " ▝▜▄ Gemini CLI v1.2.3 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: @@ -49,23 +49,24 @@ Footer ▝▜▄ Gemini CLI v1.2.3 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands 3. Be specific for the best results -Composer" +Composer +" `; exports[`App > Snapshots > renders with dialogs visible 1`] = ` " ▝▜▄ Gemini CLI v1.2.3 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ @@ -107,8 +108,8 @@ exports[`App > should render ToolConfirmationQueue along with Composer when tool " ▝▜▄ Gemini CLI v1.2.3 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: @@ -116,19 +117,19 @@ Tips for getting started: 2. Ask coding questions, edit code or run commands 3. Be specific for the best results HistoryItemDisplay -╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ Action Required │ -│ │ -│ ? ls list directory │ -│ │ -│ ls │ -│ Allow execution of: 'ls'? │ -│ │ -│ ● 1. Allow once │ -│ 2. Allow for this session │ -│ 3. No, suggest changes (esc) │ -│ │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ Action Required │ +│ │ +│ ? ls list directory │ +│ │ +│ ls │ +│ Allow execution of: 'ls'? │ +│ │ +│ ● 1. Allow once │ +│ 2. Allow for this session │ +│ 3. No, suggest changes (esc) │ +│ │ +╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/packages/cli/src/ui/components/AppHeader.test.tsx b/packages/cli/src/ui/components/AppHeader.test.tsx index 9bf821febc..ebcd4de973 100644 --- a/packages/cli/src/ui/components/AppHeader.test.tsx +++ b/packages/cli/src/ui/components/AppHeader.test.tsx @@ -213,6 +213,12 @@ describe('', () => { it('should NOT render Tips when tipsShown is 10 or more', async () => { const mockConfig = makeFakeConfig(); + const uiState = { + bannerData: { + defaultText: '', + warningText: '', + }, + }; persistentStateMock.setData({ tipsShown: 10 }); @@ -220,6 +226,7 @@ describe('', () => { , { config: mockConfig, + uiState, }, ); await waitUntilReady(); diff --git a/packages/cli/src/ui/components/__snapshots__/AlternateBufferQuittingDisplay.test.tsx.snap b/packages/cli/src/ui/components/__snapshots__/AlternateBufferQuittingDisplay.test.tsx.snap index a2ca66d9f5..089399adee 100644 --- a/packages/cli/src/ui/components/__snapshots__/AlternateBufferQuittingDisplay.test.tsx.snap +++ b/packages/cli/src/ui/components/__snapshots__/AlternateBufferQuittingDisplay.test.tsx.snap @@ -4,8 +4,8 @@ exports[`AlternateBufferQuittingDisplay > renders with a tool awaiting confirmat " ▝▜▄ Gemini CLI v0.10.0 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: @@ -23,8 +23,8 @@ exports[`AlternateBufferQuittingDisplay > renders with active and pending tool m " ▝▜▄ Gemini CLI v0.10.0 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: @@ -38,29 +38,31 @@ Tips for getting started: ╭──────────────────────────────────────────────────────────────────────────╮ │ ✓ tool2 Description for tool 2 │ │ │ -╰──────────────────────────────────────────────────────────────────────────╯" +╰──────────────────────────────────────────────────────────────────────────╯ +" `; exports[`AlternateBufferQuittingDisplay > renders with empty history and no pending items > empty 1`] = ` " ▝▜▄ Gemini CLI v0.10.0 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands -3. Be specific for the best results" +3. Be specific for the best results +" `; exports[`AlternateBufferQuittingDisplay > renders with history but no pending items > with_history_no_pending 1`] = ` " ▝▜▄ Gemini CLI v0.10.0 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: @@ -74,29 +76,31 @@ Tips for getting started: ╭──────────────────────────────────────────────────────────────────────────╮ │ ✓ tool2 Description for tool 2 │ │ │ -╰──────────────────────────────────────────────────────────────────────────╯" +╰──────────────────────────────────────────────────────────────────────────╯ +" `; exports[`AlternateBufferQuittingDisplay > renders with pending items but no history > with_pending_no_history 1`] = ` " ▝▜▄ Gemini CLI v0.10.0 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands -3. Be specific for the best results" +3. Be specific for the best results +" `; exports[`AlternateBufferQuittingDisplay > renders with user and gemini messages > with_user_gemini_messages 1`] = ` " ▝▜▄ Gemini CLI v0.10.0 ▝▜▄ - ▗▟▀ Authenticated with undefined /auth - ▝▀ Gemini Code Assist for individuals /upgrade + ▗▟▀ + ▝▀ Tips for getting started: diff --git a/packages/cli/src/ui/components/__snapshots__/AppHeader.test.tsx.snap b/packages/cli/src/ui/components/__snapshots__/AppHeader.test.tsx.snap index a963c78701..5a0b15adc9 100644 --- a/packages/cli/src/ui/components/__snapshots__/AppHeader.test.tsx.snap +++ b/packages/cli/src/ui/components/__snapshots__/AppHeader.test.tsx.snap @@ -11,7 +11,8 @@ exports[` > should not render the banner when no flags are set 1`] Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands -3. Be specific for the best results" +3. Be specific for the best results +" `; exports[` > should not render the default banner if shown count is 5 or more 1`] = ` @@ -25,7 +26,8 @@ exports[` > should not render the default banner if shown count is Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands -3. Be specific for the best results" +3. Be specific for the best results +" `; exports[` > should render the banner with default text 1`] = ` @@ -35,14 +37,15 @@ exports[` > should render the banner with default text 1`] = ` ▗▟▀ ▝▀ -╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ This is the default banner │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ This is the default banner │ +╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands -3. Be specific for the best results" +3. Be specific for the best results +" `; exports[` > should render the banner with warning text 1`] = ` @@ -52,12 +55,13 @@ exports[` > should render the banner with warning text 1`] = ` ▗▟▀ ▝▀ -╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ There are capacity issues │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ There are capacity issues │ +╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Tips for getting started: 1. /help for more information 2. Ask coding questions, edit code or run commands -3. Be specific for the best results" +3. Be specific for the best results +" `;