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 727ec8f255
commit 8d0d90318d
4 changed files with 16 additions and 6 deletions
+5 -4
View File
@@ -11,6 +11,7 @@
"packages/*"
],
"dependencies": {
"ink": "npm:@jrichman/ink@6.4.2",
"latest-version": "^9.0.0",
"simple-git": "^3.28.0"
},
@@ -9885,9 +9886,9 @@
},
"node_modules/ink": {
"name": "@jrichman/ink",
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/@jrichman/ink/-/ink-6.4.1.tgz",
"integrity": "sha512-YeNdpjFjq7Qbu9FQDQiCNmw4QehoBWi9pMEr52ZM4xLwQkYNtzyi/J5169NPLQCX2kl1WepngoUrzWvuFmjeSA==",
"version": "6.4.2",
"resolved": "https://registry.npmjs.org/@jrichman/ink/-/ink-6.4.2.tgz",
"integrity": "sha512-jfne1I/8+kVhzY/aoIWUKS0adPNRUhnN/wEsdBtSheyAp0b3c94zVsWWyDxnfXKL3RqOd40/H1FFaPLTUwjLXQ==",
"license": "MIT",
"dependencies": {
"@alcalzone/ansi-tokenize": "^0.2.1",
@@ -17265,7 +17266,7 @@
"fzf": "^0.5.2",
"glob": "^10.4.5",
"highlight.js": "^11.11.1",
"ink": "npm:@jrichman/ink@6.4.1",
"ink": "npm:@jrichman/ink@6.4.2",
"ink-gradient": "^3.0.0",
"ink-spinner": "^5.0.0",
"latest-version": "^9.0.0",
+2 -1
View File
@@ -61,7 +61,7 @@
"pre-commit": "node scripts/pre-commit.js"
},
"overrides": {
"ink": "npm:@jrichman/ink@6.4.1",
"ink": "npm:@jrichman/ink@6.4.2",
"wrap-ansi": "9.0.2",
"cliui": {
"wrap-ansi": "7.0.0"
@@ -118,6 +118,7 @@
"yargs": "^17.7.2"
},
"dependencies": {
"ink": "npm:@jrichman/ink@6.4.2",
"latest-version": "^9.0.0",
"simple-git": "^3.28.0"
},
+1 -1
View File
@@ -42,7 +42,7 @@
"fzf": "^0.5.2",
"glob": "^10.4.5",
"highlight.js": "^11.11.1",
"ink": "npm:@jrichman/ink@6.4.1",
"ink": "npm:@jrichman/ink@6.4.2",
"ink-gradient": "^3.0.0",
"ink-spinner": "^5.0.0",
"latest-version": "^9.0.0",
+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);