Compare commits

...

4 Commits

4 changed files with 94 additions and 2 deletions
+38
View File
@@ -3893,4 +3893,42 @@ describe('AppContainer State Management', () => {
unmount!();
});
});
describe('Keyboard Shortcuts', () => {
it('should toggle constrainHeight when Ctrl+O is pressed', async () => {
let renderResult: {
stdin: { write: (data: string) => boolean };
waitUntilReady: () => Promise<void>;
unmount: () => void;
};
await act(async () => {
renderResult = renderAppContainer() as unknown as typeof renderResult;
});
const { stdin, waitUntilReady, unmount } = renderResult!;
await waitUntilReady();
// Initially constrained
expect(capturedUIState.constrainHeight).toBe(true);
// Press Ctrl+O (\x0f)
await act(async () => {
stdin.write('\x0f');
});
await waitUntilReady();
// Now unconstrained
expect(capturedUIState.constrainHeight).toBe(false);
// Press Ctrl+O again
await act(async () => {
stdin.write('\x0f');
});
await waitUntilReady();
// Constrained again
expect(capturedUIState.constrainHeight).toBe(true);
unmount();
});
});
});
+2 -1
View File
@@ -1754,7 +1754,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
if (!isAlternateBuffer) {
refreshStatic();
}
return true;
// Return false to allow other components (e.g. ToolConfirmationMessage) to also handle expansion.
return false;
} else if (
(keyMatchers[Command.FOCUS_SHELL_INPUT](key) ||
keyMatchers[Command.UNFOCUS_BACKGROUND_SHELL_LIST](key)) &&
@@ -12,6 +12,7 @@ import type {
Config,
} from '@google/gemini-cli-core';
import { renderWithProviders } from '../../../test-utils/render.js';
import { act } from 'react';
import { createMockSettings } from '../../../test-utils/settings.js';
import { useToolActions } from '../../contexts/ToolActionsContext.js';
@@ -644,4 +645,55 @@ describe('ToolConfirmationMessage', () => {
expect(output).not.toContain('Invocation Arguments:');
unmount();
});
it('should toggle MCP tool details expansion when Ctrl+O is pressed', async () => {
const confirmationDetails: ToolCallConfirmationDetails = {
type: 'mcp',
title: 'Confirm MCP Tool',
serverName: 'test-server',
toolName: 'test-tool',
toolDisplayName: 'Test Tool',
toolArgs: { arg: 'val' },
toolDescription: 'Test tool description',
onConfirm: vi.fn(),
};
const { lastFrame, waitUntilReady, stdin, unmount } = renderWithProviders(
<ToolConfirmationMessage
callId="test-call-id"
confirmationDetails={confirmationDetails}
config={mockConfig}
getPreferredEditor={vi.fn()}
availableTerminalHeight={30}
terminalWidth={80}
/>,
);
await waitUntilReady();
// Initially collapsed
expect(lastFrame()).toContain('(press Ctrl+O to expand MCP tool details)');
expect(lastFrame()).not.toContain('Invocation Arguments:');
// Press Ctrl+O (\x0f)
await act(async () => {
stdin.write('\x0f');
});
await waitUntilReady();
// Now expanded
expect(lastFrame()).toContain(
'(press Ctrl+O to collapse MCP tool details)',
);
expect(lastFrame()).toContain('Invocation Arguments:');
// Press Ctrl+O again
await act(async () => {
stdin.write('\x0f');
});
await waitUntilReady();
// Collapsed again
expect(lastFrame()).toContain('(press Ctrl+O to expand MCP tool details)');
unmount();
});
});
@@ -176,7 +176,8 @@ export const ToolConfirmationMessage: React.FC<
callId,
expanded: !isMcpToolDetailsExpanded,
});
return true;
// Return false to let the global app container also expand its view.
return false;
}
if (keyMatchers[Command.ESCAPE](key)) {
handleConfirm(ToolConfirmationOutcome.Cancel);