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 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-19 15:12:36 +01:00
co-authored by Claude Opus 4.5
parent d8ca000da1
commit c4660e271f
+12 -5
View File
@@ -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 {