Switch to alternate buffer mode before rendering Ink. (#12833)

This commit is contained in:
Jacob Richman
2025-11-10 12:30:38 -08:00
committed by GitHub
parent 3c9052a751
commit 8f4b1b582d
4 changed files with 16 additions and 6 deletions
+8
View File
@@ -73,6 +73,7 @@ import { createPolicyUpdater } from './config/policy.js';
import { requestConsentNonInteractive } from './config/extensions/consent.js';
import { disableMouseEvents, enableMouseEvents } from './ui/utils/mouse.js';
import { ScrollProvider } from './ui/contexts/ScrollProvider.js';
import ansiEscapes from 'ansi-escapes';
const SLOW_RENDER_MS = 200;
@@ -233,6 +234,7 @@ export async function startInteractiveUI(
}
},
alternateBuffer: settings.merged.ui?.useAlternateBuffer,
alternateBufferAlreadyActive: settings.merged.ui?.useAlternateBuffer,
},
);
@@ -420,6 +422,12 @@ export async function main() {
// input showing up in the output.
process.stdin.setRawMode(true);
if (settings.merged.ui?.useAlternateBuffer) {
process.stdout.write(ansiEscapes.enterAlternativeScreen);
// Ink will cleanup so there is no need for us to manually cleanup.
}
// This cleanup isn't strictly needed but may help in certain situations.
process.on('SIGTERM', () => {
process.stdin.setRawMode(wasRaw);