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

@@ -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);
}