chore: add space to toggle footer

This commit is contained in:
Jack Wotherspoon
2026-02-24 22:38:37 -05:00
committed by Keith Guerin
parent 2d3b43b3c1
commit 88c8e9cca6
3 changed files with 45 additions and 38 deletions
@@ -22,23 +22,25 @@ describe('<FooterConfigDialog />', () => {
vi.restoreAllMocks();
});
it('renders correctly with default settings', () => {
it('renders correctly with default settings', async () => {
const settings = createMockSettings();
const { lastFrame } = renderWithProviders(
const { lastFrame, waitUntilReady } = renderWithProviders(
<FooterConfigDialog onClose={mockOnClose} />,
{ settings },
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
});
it('toggles an item when enter is pressed', async () => {
const settings = createMockSettings();
const { lastFrame, stdin } = renderWithProviders(
const { lastFrame, stdin, waitUntilReady } = renderWithProviders(
<FooterConfigDialog onClose={mockOnClose} />,
{ settings },
);
await waitUntilReady();
act(() => {
stdin.write('\r'); // Enter to toggle
});
@@ -58,11 +60,12 @@ describe('<FooterConfigDialog />', () => {
it('reorders items with arrow keys', async () => {
const settings = createMockSettings();
const { lastFrame, stdin } = renderWithProviders(
const { lastFrame, stdin, waitUntilReady } = renderWithProviders(
<FooterConfigDialog onClose={mockOnClose} />,
{ settings },
);
await waitUntilReady();
// Initial order: cwd, git-branch, ...
const output = lastFrame();
const cwdIdx = output!.indexOf('] cwd');
@@ -88,11 +91,12 @@ describe('<FooterConfigDialog />', () => {
it('closes on Esc', async () => {
const settings = createMockSettings();
const { stdin } = renderWithProviders(
const { stdin, waitUntilReady } = renderWithProviders(
<FooterConfigDialog onClose={mockOnClose} />,
{ settings },
);
await waitUntilReady();
act(() => {
stdin.write('\x1b'); // Esc
});
@@ -104,11 +108,12 @@ describe('<FooterConfigDialog />', () => {
it('highlights the active item in the preview', async () => {
const settings = createMockSettings();
const { lastFrame, stdin } = renderWithProviders(
const { lastFrame, stdin, waitUntilReady } = renderWithProviders(
<FooterConfigDialog onClose={mockOnClose} />,
{ settings },
);
await waitUntilReady();
expect(lastFrame()).toContain('~/project/path');
// Move focus down to 'git-branch'
@@ -123,11 +128,12 @@ describe('<FooterConfigDialog />', () => {
it('shows an empty preview when all items are deselected', async () => {
const settings = createMockSettings();
const { lastFrame, stdin } = renderWithProviders(
const { lastFrame, stdin, waitUntilReady } = renderWithProviders(
<FooterConfigDialog onClose={mockOnClose} />,
{ settings },
);
await waitUntilReady();
for (let i = 0; i < 10; i++) {
act(() => {
stdin.write('\r'); // Toggle (deselect)
@@ -224,7 +224,7 @@ export const FooterConfigDialog: React.FC<FooterConfigDialogProps> = ({
return true;
}
if (keyMatchers[Command.RETURN](key)) {
if (keyMatchers[Command.RETURN](key) || key.name === 'space') {
if (isResetFocused) {
handleResetToDefaults();
} else if (isShowLabelsFocused) {
@@ -378,7 +378,7 @@ export const FooterConfigDialog: React.FC<FooterConfigDialogProps> = ({
<Box marginTop={1} flexDirection="column">
<Text color={theme.text.secondary}>
/ navigate · / reorder · enter select · esc close
/ navigate · / reorder · enter/space select · esc close
</Text>
</Box>
@@ -1,7 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`<FooterConfigDialog /> > renders correctly with default settings 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Configure Footer │
│ │
@@ -21,13 +21,14 @@ exports[`<FooterConfigDialog /> > renders correctly with default settings 1`] =
│ [✓] Show footer labels │
│ Reset to default footer │
│ │
│ ↑/↓ navigate · ←/→ reorder · enter select · esc close
│ ↑/↓ navigate · ←/→ reorder · enter/space select · esc close │
│ │
│ ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ ┌────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ Preview: │ │
│ │ Path Branch /docs /model /stats │ │
│ │ ~/project/path main docker gemini-2.5-pro daily 97% │ │
│ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│ └────────────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
╰──────────────────────────────────────────────────────────────────────────────────────────────────
"
`;