fix(tui): call process.exit(0) after Ink exit to trigger terminal cleanup

Ink's exit() calls unmount() which resets terminal modes (kitty keyboard,
mouse, etc.) but does NOT call process.exit().  The Node process stays
alive because stdin is still open (Ink listens on it), so the
process.on('exit') handler in entry.tsx — which sends the final
resetTerminalModes() — never fires.

This left kitty keyboard protocol and other terminal modes enabled in the
parent shell after /quit, Ctrl+C, or Ctrl+D, breaking arrow keys and
other input in subsequent programs.

Add explicit process.exit(0) after exit() in die() so the process
actually terminates and the exit handler runs.

Fixes #19194
This commit is contained in:
liuhao1024 2026-05-04 00:04:58 +08:00 committed by Teknium
parent 74c997d985
commit 9c93fc5775

View file

@ -358,6 +358,13 @@ export function useMainApp(gw: GatewayClient) {
const die = useCallback(() => {
gw.kill()
exit()
// Ink's exit() calls unmount() which resets terminal modes but does NOT
// call process.exit(). Without an explicit exit the Node process stays
// alive (stdin listener keeps the event loop open), so the process.on('exit')
// handler in entry.tsx — which sends the final resetTerminalModes() — never
// fires. This leaves kitty keyboard protocol, mouse modes, etc. enabled
// in the parent shell. See issue #19194.
process.exit(0)
}, [exit, gw])
const session = useSessionLifecycle({