fix(coding-agent): preserve final TUI frame on quit

This commit is contained in:
Mario Zechner
2026-04-24 00:09:35 +02:00
parent 65a6472bdd
commit 6bb4a55524
2 changed files with 4 additions and 6 deletions

View File

@@ -24,6 +24,7 @@
### Fixed
- Fixed `/quit` shutdown ordering to stop the TUI before extension UI teardown can repaint, preserving the final rendered frame while still emitting `session_shutdown` before process exit.
- Fixed `SettingsManager.inMemory()` initial settings being lost after reloads triggered by SDK resource loading ([#3616](https://github.com/badlogic/pi-mono/issues/3616))
- Fixed `models.json` provider compatibility to accept `compat.supportsLongCacheRetention`, allowing proxies to opt out of long-retention cache fields when needed while long retention is enabled by default when requested ([#3543](https://github.com/badlogic/pi-mono/issues/3543))
- Fixed `--thinking xhigh` for `openai-codex` `gpt-5.5` so it is no longer downgraded to `high`.

View File

@@ -3208,7 +3208,8 @@ export class InteractiveMode {
/**
* Gracefully shutdown the agent.
* Emits shutdown event to extensions, then exits.
* Stops the TUI before emitting shutdown events so extension UI cleanup cannot
* repaint the final frame while the process is exiting.
*/
private isShuttingDown = false;
@@ -3216,17 +3217,13 @@ export class InteractiveMode {
if (this.isShuttingDown) return;
this.isShuttingDown = true;
this.unregisterSignalHandlers();
await this.runtimeHost.dispose();
// Wait for any pending renders to complete
// requestRender() uses process.nextTick(), so we wait one tick
await new Promise((resolve) => process.nextTick(resolve));
// Drain any in-flight Kitty key release events before stopping.
// This prevents escape sequences from leaking to the parent shell over slow SSH.
await this.ui.terminal.drainInput(1000);
this.stop();
await this.runtimeHost.dispose();
process.exit(0);
}