Support incremental update experiment flag. (#12926)

This commit is contained in:
Jacob Richman
2025-11-13 09:45:03 -08:00
committed by jacob314
parent b37c674f2b
commit 1cab681854
9 changed files with 48 additions and 31 deletions

View File

@@ -502,6 +502,16 @@ const SETTINGS_SCHEMA = {
'Use an alternate screen buffer for the UI, preserving shell history.',
showInDialog: true,
},
incrementalRendering: {
type: 'boolean',
label: 'Incremental Rendering',
category: 'UI',
requiresRestart: true,
default: true,
description:
'Enable incremental rendering for the UI. This option will reduce flickering but may cause rendering artifacts. Only supported when useAlternateBuffer is enabled.',
showInDialog: true,
},
customWittyPhrases: {
type: 'array',
label: 'Custom Witty Phrases',

View File

@@ -474,6 +474,8 @@ describe('startInteractiveUI', () => {
vi.mock('./ui/utils/kittyProtocolDetector.js', () => ({
detectAndEnableKittyProtocol: vi.fn(() => Promise.resolve(true)),
isKittyProtocolSupported: vi.fn(() => true),
isKittyProtocolEnabled: vi.fn(() => true),
}));
vi.mock('./ui/utils/updateCheck.js', () => ({
@@ -531,6 +533,7 @@ describe('startInteractiveUI', () => {
expect(options).toEqual({
alternateBuffer: true,
exitOnCtrlC: false,
incrementalRendering: true,
isScreenReaderEnabled: false,
onRender: expect.any(Function),
});

View File

@@ -158,32 +158,19 @@ export async function startInteractiveUI(
resumedSessionData: ResumedSessionData | undefined,
initializationResult: InitializationResult,
) {
// When not in screen reader mode, disable line wrapping.
// We rely on Ink to manage all line wrapping by forcing all content to be
// narrower than the terminal width so there is no need for the terminal to
// also attempt line wrapping.
// Disabling line wrapping reduces Ink rendering artifacts particularly when
// the terminal is resized on terminals that full respect this escape code
// such as Ghostty. Some terminals such as Iterm2 only respect line wrapping
// when using the alternate buffer, which Gemini CLI does not use because we
// do not yet have support for scrolling in that mode.
if (!config.getScreenReader()) {
process.stdout.write('\x1b[?7l');
}
const useAlternateBuffer = isAlternateBufferEnabled(settings);
// Never enter Ink alternate buffer mode when screen reader mode is enabled
// as there is no benefit of alternate buffer mode when using a screen reader
// and the Ink alternate buffer mode requires line wrapping harmful to
// screen readers.
const useAlternateBuffer =
isAlternateBufferEnabled(settings) && !config.getScreenReader();
const mouseEventsEnabled = useAlternateBuffer;
if (mouseEventsEnabled) {
enableMouseEvents();
}
registerCleanup(() => {
// Re-enable line wrapping on exit.
process.stdout.write('\x1b[?7h');
if (mouseEventsEnabled) {
registerCleanup(() => {
disableMouseEvents();
}
});
});
}
const version = await getCliVersion();
setWindowTitle(basename(workspaceRoot), settings);
@@ -239,6 +226,9 @@ export async function startInteractiveUI(
}
},
alternateBuffer: useAlternateBuffer,
incrementalRendering:
settings.merged.ui?.incrementalRendering !== false &&
useAlternateBuffer,
},
);