Skip to content

fix: reset per-tab agent state in killAgent()#999

Open
alwynoddle wants to merge 1 commit intogarrytan:mainfrom
alwynoddle:fix/kill-agent-tab-state
Open

fix: reset per-tab agent state in killAgent()#999
alwynoddle wants to merge 1 commit intogarrytan:mainfrom
alwynoddle:fix/kill-agent-tab-state

Conversation

@alwynoddle
Copy link
Copy Markdown

Summary

killAgent() resets the legacy global agentStatus = 'idle' but leaves the per-tab entry in tabAgents with status: 'processing'.

The POST /sidebar-command handler checks per-tab status (not the global) to decide whether to call spawnClaude() or queue the message. After a kill, the tab is permanently stuck — the sidebar looks idle but silently queues every new message in memory instead of dispatching it. Only fix was a server restart.

Root cause

The per-tab tabAgents Map was introduced alongside the cancel-file work in #664, but killAgent() was only updated to write the cancel file — the per-tab state reset was missed.

Fix

Reset the TabAgentState entry in tabAgents inside killAgent(), alongside the existing legacy global resets.

Repro

  1. Send a message before the sidebar agent process is running
  2. Server marks the tab 'processing', agent never responds
  3. Hit Kill — global resets to idle, per-tab stays 'processing'
  4. Every subsequent message is queued in-memory, never dispatched
  5. Sidebar appears functional but never responds

Test

After the fix: kill an in-progress agent, send a new message, confirm agent_start appears in the chat buffer and a new entry is appended to sidebar-agent-queue.jsonl.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants