Skip to content

Commit b21b289

Browse files
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 <jacob314@gmail.com>
1 parent 56a63a3 commit b21b289

2 files changed

Lines changed: 1 addition & 134 deletions

File tree

packages/cli/src/ui/AppContainer.test.tsx

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,136 +2544,6 @@ describe('AppContainer State Management', () => {
25442544
});
25452545
});
25462546

2547-
describe('Expansion Persistence', () => {
2548-
let rerender: () => void;
2549-
let unmount: () => void;
2550-
let stdin: ReturnType<typeof render>['stdin'];
2551-
2552-
const setupExpansionPersistenceTest = async (
2553-
HighPriorityChild?: React.FC,
2554-
) => {
2555-
const getTree = () => (
2556-
<SettingsContext.Provider value={mockSettings}>
2557-
<KeypressProvider config={mockConfig}>
2558-
<OverflowProvider>
2559-
<AppContainer
2560-
config={mockConfig}
2561-
version="1.0.0"
2562-
initializationResult={mockInitResult}
2563-
/>
2564-
{HighPriorityChild && <HighPriorityChild />}
2565-
</OverflowProvider>
2566-
</KeypressProvider>
2567-
</SettingsContext.Provider>
2568-
);
2569-
2570-
const renderResult = render(getTree());
2571-
stdin = renderResult.stdin;
2572-
await act(async () => {
2573-
vi.advanceTimersByTime(100);
2574-
});
2575-
rerender = () => renderResult.rerender(getTree());
2576-
unmount = () => renderResult.unmount();
2577-
};
2578-
2579-
const writeStdin = async (sequence: string) => {
2580-
await act(async () => {
2581-
stdin.write(sequence);
2582-
// Advance timers to allow escape sequence parsing and broadcasting
2583-
vi.advanceTimersByTime(100);
2584-
});
2585-
rerender();
2586-
};
2587-
2588-
beforeEach(() => {
2589-
vi.useFakeTimers();
2590-
});
2591-
2592-
afterEach(() => {
2593-
vi.useRealTimers();
2594-
vi.restoreAllMocks();
2595-
});
2596-
2597-
it('should reset expansion when a key is NOT handled by anyone', async () => {
2598-
await setupExpansionPersistenceTest();
2599-
2600-
// Expand first
2601-
act(() => capturedUIActions.setConstrainHeight(false));
2602-
rerender();
2603-
expect(capturedUIState.constrainHeight).toBe(false);
2604-
2605-
// Press a random key that no one handles (hits Low priority fallback)
2606-
await writeStdin('x');
2607-
2608-
// Should be reset to true (collapsed)
2609-
expect(capturedUIState.constrainHeight).toBe(true);
2610-
2611-
unmount();
2612-
});
2613-
2614-
it('should toggle expansion when Ctrl+O is pressed', async () => {
2615-
await setupExpansionPersistenceTest();
2616-
2617-
// Initial state is collapsed
2618-
expect(capturedUIState.constrainHeight).toBe(true);
2619-
2620-
// Press Ctrl+O to expand (Ctrl+O is sequence \x0f)
2621-
await writeStdin('\x0f');
2622-
expect(capturedUIState.constrainHeight).toBe(false);
2623-
2624-
// Press Ctrl+O again to collapse
2625-
await writeStdin('\x0f');
2626-
expect(capturedUIState.constrainHeight).toBe(true);
2627-
2628-
unmount();
2629-
});
2630-
2631-
it('should NOT collapse when a high-priority component handles the key (e.g., up/down arrows)', async () => {
2632-
const NavigationHandler = () => {
2633-
// use real useKeypress
2634-
useKeypress(
2635-
(key: Key) => {
2636-
if (key.name === 'up' || key.name === 'down') {
2637-
return true; // Handle navigation
2638-
}
2639-
return false;
2640-
},
2641-
{ isActive: true, priority: true }, // High priority
2642-
);
2643-
return null;
2644-
};
2645-
2646-
await setupExpansionPersistenceTest(NavigationHandler);
2647-
2648-
// Expand first
2649-
act(() => capturedUIActions.setConstrainHeight(false));
2650-
rerender();
2651-
expect(capturedUIState.constrainHeight).toBe(false);
2652-
2653-
// 1. Simulate Up arrow (handled by high priority child)
2654-
// CSI A is Up arrow
2655-
await writeStdin('\u001b[A');
2656-
2657-
// Should STILL be expanded
2658-
expect(capturedUIState.constrainHeight).toBe(false);
2659-
2660-
// 2. Simulate Down arrow (handled by high priority child)
2661-
// CSI B is Down arrow
2662-
await writeStdin('\u001b[B');
2663-
2664-
// Should STILL be expanded
2665-
expect(capturedUIState.constrainHeight).toBe(false);
2666-
2667-
// 3. Sanity check: press an unhandled key
2668-
await writeStdin('x');
2669-
2670-
// Should finally collapse
2671-
expect(capturedUIState.constrainHeight).toBe(true);
2672-
2673-
unmount();
2674-
});
2675-
});
2676-
26772547
describe('Shortcuts Help Visibility', () => {
26782548
let handleGlobalKeypress: (key: Key) => boolean;
26792549
let mockedUseKeypress: Mock;

packages/cli/src/ui/AppContainer.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,10 +1873,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
18731873
],
18741874
);
18751875

1876-
useKeypress(handleGlobalKeypress, {
1877-
isActive: true,
1878-
priority: KeypressPriority.Low,
1879-
});
1876+
useKeypress(handleGlobalKeypress, { isActive: true, priority: true });
18801877

18811878
useKeypress(
18821879
() => {

0 commit comments

Comments
 (0)