Migrate core render util to use xterm.js as part of the rendering loop. (#19044)

This commit is contained in:
Jacob Richman
2026-02-18 16:46:50 -08:00
committed by GitHub
parent 04c52513e7
commit 04f65f3d55
213 changed files with 7065 additions and 3852 deletions

View File

@@ -69,13 +69,13 @@ const createMockConfig = (overrides = {}) => ({
...overrides,
});
const renderStatusDisplay = (
const renderStatusDisplay = async (
props: { hideContextSummary: boolean } = { hideContextSummary: false },
uiState: UIState = createMockUIState(),
settings = createMockSettings(),
config = createMockConfig(),
) =>
render(
) => {
const result = render(
<ConfigContext.Provider value={config as unknown as Config}>
<SettingsContext.Provider value={settings as unknown as LoadedSettings}>
<UIStateContext.Provider value={uiState}>
@@ -84,6 +84,9 @@ const renderStatusDisplay = (
</SettingsContext.Provider>
</ConfigContext.Provider>,
);
await result.waitUntilReady();
return result;
};
describe('StatusDisplay', () => {
const originalEnv = process.env;
@@ -94,68 +97,77 @@ describe('StatusDisplay', () => {
vi.restoreAllMocks();
});
it('renders nothing by default if context summary is hidden via props', () => {
const { lastFrame } = renderStatusDisplay({ hideContextSummary: true });
expect(lastFrame()).toBe('');
it('renders nothing by default if context summary is hidden via props', async () => {
const { lastFrame, unmount } = await renderStatusDisplay({
hideContextSummary: true,
});
expect(lastFrame({ allowEmpty: true })).toBe('');
unmount();
});
it('renders ContextSummaryDisplay by default', () => {
const { lastFrame } = renderStatusDisplay();
it('renders ContextSummaryDisplay by default', async () => {
const { lastFrame, unmount } = await renderStatusDisplay();
expect(lastFrame()).toMatchSnapshot();
unmount();
});
it('renders system md indicator if env var is set', () => {
it('renders system md indicator if env var is set', async () => {
process.env['GEMINI_SYSTEM_MD'] = 'true';
const { lastFrame } = renderStatusDisplay();
const { lastFrame, unmount } = await renderStatusDisplay();
expect(lastFrame()).toMatchSnapshot();
unmount();
});
it('renders HookStatusDisplay when hooks are active', () => {
it('renders HookStatusDisplay when hooks are active', async () => {
const uiState = createMockUIState({
activeHooks: [{ name: 'hook', eventName: 'event' }],
});
const { lastFrame } = renderStatusDisplay(
const { lastFrame, unmount } = await renderStatusDisplay(
{ hideContextSummary: false },
uiState,
);
expect(lastFrame()).toMatchSnapshot();
unmount();
});
it('does NOT render HookStatusDisplay if notifications are disabled in settings', () => {
it('does NOT render HookStatusDisplay if notifications are disabled in settings', async () => {
const uiState = createMockUIState({
activeHooks: [{ name: 'hook', eventName: 'event' }],
});
const settings = createMockSettings({
hooksConfig: { notifications: false },
});
const { lastFrame } = renderStatusDisplay(
const { lastFrame, unmount } = await renderStatusDisplay(
{ hideContextSummary: false },
uiState,
settings,
);
expect(lastFrame()).toMatchSnapshot();
unmount();
});
it('hides ContextSummaryDisplay if configured in settings', () => {
it('hides ContextSummaryDisplay if configured in settings', async () => {
const settings = createMockSettings({
ui: { hideContextSummary: true },
});
const { lastFrame } = renderStatusDisplay(
const { lastFrame, unmount } = await renderStatusDisplay(
{ hideContextSummary: false },
undefined,
settings,
);
expect(lastFrame()).toBe('');
expect(lastFrame({ allowEmpty: true })).toBe('');
unmount();
});
it('passes backgroundShellCount to ContextSummaryDisplay', () => {
it('passes backgroundShellCount to ContextSummaryDisplay', async () => {
const uiState = createMockUIState({
backgroundShellCount: 3,
});
const { lastFrame } = renderStatusDisplay(
const { lastFrame, unmount } = await renderStatusDisplay(
{ hideContextSummary: false },
uiState,
);
expect(lastFrame()).toContain('Shells: 3');
unmount();
});
});