From 006049e90f43f524864174797080fd907036e06c Mon Sep 17 00:00:00 2001 From: Alwyn Date: Tue, 14 Apr 2026 23:07:19 +0800 Subject: [PATCH] fix: reset per-tab agent state in killAgent() After the per-tab agent refactor, killAgent() correctly reset the legacy global agentStatus to 'idle' but left the per-tab entry in tabAgents with status 'processing'. spawnClaude() checks the per-tab status, not the global, so every message sent after a kill was silently queued in-memory (tabState.queue) instead of being dispatched to the queue file. Result: the sidebar appeared idle (global status = idle) but would never respond to new messages again until the server was restarted. Fix: reset the per-tab TabAgentState alongside the legacy globals. Co-Authored-By: Claude Sonnet 4.6 --- browse/src/server.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/browse/src/server.ts b/browse/src/server.ts index 98f43af0c..d3ef7f65f 100644 --- a/browse/src/server.ts +++ b/browse/src/server.ts @@ -651,6 +651,17 @@ function killAgent(targetTabId?: number | null): void { agentStartTime = null; currentMessage = null; agentStatus = 'idle'; + // Also reset the per-tab state — killAgent resets the global but the tab-level + // status gates spawnClaude, so without this every subsequent message is queued + // instead of dispatched. + const resetTabId = targetTabId ?? agentTabId ?? null; + if (resetTabId !== null && tabAgents.has(resetTabId)) { + const ts = tabAgents.get(resetTabId)!; + ts.status = 'idle'; + ts.startTime = null; + ts.currentMessage = null; + ts.queue = []; + } } // Agent health check — detect hung processes