mirror of
https://github.com/Narcooo/inkos.git
synced 2026-09-01 15:08:51 +08:00
fix(tui): only use alternate screen buffer on Terminal.app
The alternate screen disables terminal scrollback. Only enable it on Terminal.app where it's needed to prevent IME XPC crashes. Other terminals (iTerm2, etc.) keep native scrolling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -186,13 +186,14 @@ export async function launchTui(
|
||||
return (originalStderrWrite as Function)(chunk, ...args);
|
||||
};
|
||||
|
||||
// Enter alternate screen buffer — isolates Ink rendering from the primary
|
||||
// terminal view. This prevents IME XPC corruption on Terminal.app (the IME's
|
||||
// Terminal.app only: enter alternate screen buffer to isolate Ink rendering
|
||||
// from the primary terminal view. This prevents IME XPC corruption (the IME's
|
||||
// NSRemoteView interacts with the primary screen; the alt screen is separate).
|
||||
// Claude Code uses the same approach via <AlternateScreen> + DEC 1049.
|
||||
const ENTER_ALT = "\x1b[?1049h";
|
||||
const EXIT_ALT = "\x1b[?1049l";
|
||||
process.stdout.write(ENTER_ALT);
|
||||
// Other terminals keep their scrollback.
|
||||
const useAltScreen = isAppleTerminal;
|
||||
if (useAltScreen) {
|
||||
process.stdout.write("\x1b[?1049h");
|
||||
}
|
||||
|
||||
try {
|
||||
await animateStartup(version, basename(projectRoot), session.activeBookId, modelInfo);
|
||||
@@ -214,7 +215,9 @@ export async function launchTui(
|
||||
);
|
||||
await app.waitUntilExit();
|
||||
} finally {
|
||||
process.stdout.write(EXIT_ALT);
|
||||
if (useAltScreen) {
|
||||
process.stdout.write("\x1b[?1049l");
|
||||
}
|
||||
process.emitWarning = originalEmitWarning;
|
||||
process.stderr.write = originalStderrWrite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user