From b21b289e261b2702a2b58d2e73200d6ea3198082 Mon Sep 17 00:00:00 2001 From: gemini-cli-robot Date: Tue, 3 Mar 2026 21:48:23 -0500 Subject: [PATCH] fix(patch): cherry-pick 0659ad1 to release/v0.33.0-preview.0-pr-21042 to patch version v0.33.0-preview.0 and create version 0.33.0-preview.1 (#21047) Co-authored-by: Jacob Richman --- packages/cli/src/ui/AppContainer.test.tsx | 130 ---------------------- packages/cli/src/ui/AppContainer.tsx | 5 +- 2 files changed, 1 insertion(+), 134 deletions(-) diff --git a/packages/cli/src/ui/AppContainer.test.tsx b/packages/cli/src/ui/AppContainer.test.tsx index 8505afd3ef..0326aee766 100644 --- a/packages/cli/src/ui/AppContainer.test.tsx +++ b/packages/cli/src/ui/AppContainer.test.tsx @@ -2544,136 +2544,6 @@ describe('AppContainer State Management', () => { }); }); - describe('Expansion Persistence', () => { - let rerender: () => void; - let unmount: () => void; - let stdin: ReturnType['stdin']; - - const setupExpansionPersistenceTest = async ( - HighPriorityChild?: React.FC, - ) => { - const getTree = () => ( - - - - - {HighPriorityChild && } - - - - ); - - const renderResult = render(getTree()); - stdin = renderResult.stdin; - await act(async () => { - vi.advanceTimersByTime(100); - }); - rerender = () => renderResult.rerender(getTree()); - unmount = () => renderResult.unmount(); - }; - - const writeStdin = async (sequence: string) => { - await act(async () => { - stdin.write(sequence); - // Advance timers to allow escape sequence parsing and broadcasting - vi.advanceTimersByTime(100); - }); - rerender(); - }; - - beforeEach(() => { - vi.useFakeTimers(); - }); - - afterEach(() => { - vi.useRealTimers(); - vi.restoreAllMocks(); - }); - - it('should reset expansion when a key is NOT handled by anyone', async () => { - await setupExpansionPersistenceTest(); - - // Expand first - act(() => capturedUIActions.setConstrainHeight(false)); - rerender(); - expect(capturedUIState.constrainHeight).toBe(false); - - // Press a random key that no one handles (hits Low priority fallback) - await writeStdin('x'); - - // Should be reset to true (collapsed) - expect(capturedUIState.constrainHeight).toBe(true); - - unmount(); - }); - - it('should toggle expansion when Ctrl+O is pressed', async () => { - await setupExpansionPersistenceTest(); - - // Initial state is collapsed - expect(capturedUIState.constrainHeight).toBe(true); - - // Press Ctrl+O to expand (Ctrl+O is sequence \x0f) - await writeStdin('\x0f'); - expect(capturedUIState.constrainHeight).toBe(false); - - // Press Ctrl+O again to collapse - await writeStdin('\x0f'); - expect(capturedUIState.constrainHeight).toBe(true); - - unmount(); - }); - - it('should NOT collapse when a high-priority component handles the key (e.g., up/down arrows)', async () => { - const NavigationHandler = () => { - // use real useKeypress - useKeypress( - (key: Key) => { - if (key.name === 'up' || key.name === 'down') { - return true; // Handle navigation - } - return false; - }, - { isActive: true, priority: true }, // High priority - ); - return null; - }; - - await setupExpansionPersistenceTest(NavigationHandler); - - // Expand first - act(() => capturedUIActions.setConstrainHeight(false)); - rerender(); - expect(capturedUIState.constrainHeight).toBe(false); - - // 1. Simulate Up arrow (handled by high priority child) - // CSI A is Up arrow - await writeStdin('\u001b[A'); - - // Should STILL be expanded - expect(capturedUIState.constrainHeight).toBe(false); - - // 2. Simulate Down arrow (handled by high priority child) - // CSI B is Down arrow - await writeStdin('\u001b[B'); - - // Should STILL be expanded - expect(capturedUIState.constrainHeight).toBe(false); - - // 3. Sanity check: press an unhandled key - await writeStdin('x'); - - // Should finally collapse - expect(capturedUIState.constrainHeight).toBe(true); - - unmount(); - }); - }); - describe('Shortcuts Help Visibility', () => { let handleGlobalKeypress: (key: Key) => boolean; let mockedUseKeypress: Mock; diff --git a/packages/cli/src/ui/AppContainer.tsx b/packages/cli/src/ui/AppContainer.tsx index 4f8d739340..a865f505af 100644 --- a/packages/cli/src/ui/AppContainer.tsx +++ b/packages/cli/src/ui/AppContainer.tsx @@ -1873,10 +1873,7 @@ Logging in with Google... Restarting Gemini CLI to continue. ], ); - useKeypress(handleGlobalKeypress, { - isActive: true, - priority: KeypressPriority.Low, - }); + useKeypress(handleGlobalKeypress, { isActive: true, priority: true }); useKeypress( () => {