After the TUI exits, the terminal was left with mouse tracking enabled
(\x1b[?1003l / \x1b[?1006l SGR mode), causing subsequent terminal input
to print raw escape sequences like ^[<35;61;11M instead of being
interpreted normally.
Root cause: renderer.destroy() relies on native destroyRenderer() to
send the mouse-disable sequences, but process.exit() in index.ts fires
before those writes are flushed to stdout.
Fixes:
- exit.tsx: explicitly write mouse-disable + cursor-restore sequences to
stdout before renderer.destroy(), and register a process 'exit' handler
as a last-resort guarantee that fires synchronously on process exit.
- prompt/index.tsx + session/index.tsx: add double-confirm for Ctrl+C
exit (press twice within 3 s) matching the behaviour of claude code and
similar TUI tools; inline hint replaces the toast for the first press.
- win32.ts: tighten the ENABLE_PROCESSED_INPUT enforcement poll from
100 ms to 16 ms so the guard reacts faster after console-mode resets.
Closes#13276