From c4660e271f52155f0938004edcf89966df213d7d Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 19 Jan 2026 15:12:36 +0100 Subject: [PATCH] fix(respawn): don't remove server's terminal listener The respawn controller was calling removeAllListeners('terminal') which also removed the server's listener that streams output to the browser. This made the console appear "blocked" when respawn was enabled. Now properly tracks and removes only its own listener. Co-Authored-By: Claude Opus 4.5 --- src/respawn-controller.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/respawn-controller.ts b/src/respawn-controller.ts index f0678bd1..92abba73 100644 --- a/src/respawn-controller.ts +++ b/src/respawn-controller.ts @@ -89,6 +89,7 @@ export class RespawnController extends EventEmitter { private terminalBuffer: string = ''; private promptDetected: boolean = false; private workingDetected: boolean = false; + private terminalHandler: ((data: string) => void) | null = null; // Terminal patterns - detect when Claude is ready for input private readonly PROMPT_PATTERNS = [ @@ -166,7 +167,10 @@ export class RespawnController extends EventEmitter { this.log('Stopping respawn controller'); this.clearTimers(); this.setState('stopped'); - this.session.removeAllListeners('terminal'); + if (this.terminalHandler) { + this.session.off('terminal', this.terminalHandler); + this.terminalHandler = null; + } } /** @@ -189,12 +193,15 @@ export class RespawnController extends EventEmitter { } private setupTerminalListener(): void { - // Clear any existing listener - this.session.removeAllListeners('terminal'); + // Remove our previous listener if any (don't remove other listeners!) + if (this.terminalHandler) { + this.session.off('terminal', this.terminalHandler); + } - this.session.on('terminal', (data: string) => { + this.terminalHandler = (data: string) => { this.handleTerminalData(data); - }); + }; + this.session.on('terminal', this.terminalHandler); } private handleTerminalData(data: string): void {