fix(tui): restore terminal state on crash and release leaked resources (#1272)

* fix(tui): restore terminal state on crash and release leaked resources

Restore raw mode, cursor, and flow control on uncaughtException, unhandledRejection, and SIGTERM cleanup failure; reclaim pasted image bytes when transcript entries are trimmed; and stop feedback, activity, transcript, footer, and editor timers during shutdown.

* fix(tui): keep crash handlers installed and attach stty to the tty

Keep uncaughtException / unhandledRejection handlers installed for the whole interactive session; removing them right after start() resolved left runtime crashes uncaught. Run stty with stdin inherited from the TTY, since stty fails when stdin is /dev/null.
This commit is contained in:
liruifengv 2026-07-01 21:14:19 +08:00 committed by GitHub
parent b905dd4910
commit 54703d9457
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 251 additions and 40 deletions

View file

@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---
Release pasted images and streaming timers once they are no longer shown, so memory stops growing in long sessions.

View file

@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---
Fix the terminal being left in raw mode with a hidden cursor and disabled flow control after a crash or abrupt exit.