Files
gemini-cli/packages/cli/src/ui/components/Help.test.tsx
T
jacob314 5fbb5e011c feat: add config and keybindings for new ink terminal buffer mode
test: update test utils and resolve snapshot differences for ink changes

feat: refactor VirtualizedList to support static rendering and terminal buffers

feat: wire up AppContainer mouse mode and recording state for ink buffer

Fix stale ref in ScrollProvider breaking scrolling.

The ScrollProvider was getting stuck with a stale reference because the
`scrollables` Map was being registered and unregistered whenever the entry
identity changed. The underlying `ScrollableList` component dynamically created
a new ID which caused React remount cycles, while the `ScrollProvider` itself
suffered from state lag where the event handler ref was one tick behind the
actual registration.

This commit resolves these issues by:
1. Adding a stable `id` and `key` to `ScrollableList` in `MainContent.tsx`
2. Making `scrollablesRef` synchronously update in `ScrollProvider.tsx`
3. Using a proxy entry in `useScrollable` to avoid constant re-registering.

chore: add useEffect cleanup for ResizeObservers

Checkpoint fixing terminal buffer support.

Termina Serializer Optimization
2026-04-01 13:05:59 -07:00

80 lines
1.9 KiB
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { render } from '../../test-utils/render.js';
import { describe, it, expect } from 'vitest';
import { Help } from './Help.js';
import { CommandKind, type SlashCommand } from '../commands/types.js';
const mockCommands: readonly SlashCommand[] = [
{
name: 'test',
description: 'A test command',
kind: CommandKind.BUILT_IN,
},
{
name: 'hidden',
description: 'A hidden command',
hidden: true,
kind: CommandKind.BUILT_IN,
},
{
name: 'parent',
description: 'A parent command',
kind: CommandKind.BUILT_IN,
subCommands: [
{
name: 'visible-child',
description: 'A visible child command',
kind: CommandKind.BUILT_IN,
},
{
name: 'hidden-child',
description: 'A hidden child command',
hidden: true,
kind: CommandKind.BUILT_IN,
},
],
},
];
describe('Help Component', () => {
it('should not render hidden commands', async () => {
const { lastFrame, unmount } = await render(
<Help commands={mockCommands} />,
);
const output = lastFrame();
expect(output).toContain('/test');
expect(output).not.toContain('/hidden');
unmount();
});
it('should not render hidden subcommands', async () => {
const { lastFrame, unmount } = await render(
<Help commands={mockCommands} />,
);
const output = lastFrame();
expect(output).toContain('visible-child');
expect(output).not.toContain('hidden-child');
unmount();
});
it('should render keyboard shortcuts', async () => {
const { lastFrame, unmount } = await render(
<Help commands={mockCommands} />,
);
const output = lastFrame();
expect(output).toContain('Keyboard Shortcuts:');
expect(output).toContain('Ctrl+C');
expect(output).toContain('Shift+Tab');
expect(output).toContain('Page Up/Page Down');
unmount();
});
});