Repository navigation
Keep chats with background work awake, track resumed agents, show subagent approvals in sidebar - #424
Conversation
Claude Code reports a SendMessage resume as a fresh task_started with the same task_id but the SendMessage call's tool_use_id, so the Agent card stayed 'completed' for the whole resumed run. Resolve task events by task_id back to the original Agent record, and attach the resumed run's report to that card. Background Bash emits the same task_started/task_notification pair (task_type local_bash), so AutoSleepMonitor now skips any session with a running detached task. Running tasks are settled when the process exits so a dead one can't pin a tab awake forever. Task lifecycle events are now logged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A background agent blocked on an approval only showed a ⚠ in the sidebar; the actionable prompt lived inside its Task card, usually far up the transcript. collectAgents now records each agent's own pending tool_use ids, and the Subagents column card (outside its disclosure) and the agent peek render the same approval card the chat does. The collapsed column's chip turns amber while any subagent is blocked. Questions (AskUserQuestion) point back to the chat instead of mounting a second autofocusing copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟡 Evidence review: partially verifiedThe subagent approval prompt now appears on the agent's card in the Subagents column, the collapsed chip turns amber with ⚠, and the agent history window opened from the Agents panel shows the prompt with working buttons. Before shows only a ⚠ with no controls. Auto-sleep and the SendMessage resume card were not reached: the auto-sleep setting exists in Settings, but the blocked approval keeps the tab in 'running', so the sweep never fires. Those claims rest on the unit tests in the diff.
Test plan
E1Before: the subagent card in the Subagents column shows only a ⚠ and no approval buttons. After: the card carries its own NEEDS APPROVAL prompt with Allow/Deny.
E2Subagents column reopened: after shows the agent's own NEEDS APPROVAL card with Allow/Deny inside the Subagents column; before shows the agent with only a ⚠ and no approval controls.
E3After: the agent history window for the blocked subagent shows the NEEDS APPROVAL Bash card with Allow/Deny buttons, opened from the Agents panel row. after Model
Automated evidence review of |
- collectAgents no longer reuses a settled summary once its lifecycle record has moved, so a SendMessage resume shows as running with its new steps and pending approvals instead of the pre-resume snapshot. - Tasks still running when the process exits settle as 'interrupted', not 'failed' — a sleep isn't an error. - AutoSleepMonitor documents that background work keeps a tab awake with no upper bound, and logs the skip once per stretch. - Note why the task key is resolved in both manager and reducer; narrow the peek's session id instead of passing ''. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The exited state event now carries a timestamp, which the reducer stamps as completedAt on tasks it settles as interrupted. Without it the right panel and peek kept ticking the elapsed time of a dead agent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>





Three related fixes for background work in Chat tabs.
1. Auto-sleep no longer kills chats with background work running
AutoSleepMonitorslept any idle'waiting'chat tab, even when a background Agent orrun_in_backgroundBash was still going. Sleeping kills the Claude process, which kills that work too. The sweep now skips any session with a running detached task. Background Bash counts too: Claude Code reports it through the sametask_started/task_notificationpair (task_type: "local_bash"), so Ness was already recording it.When the process exits, tasks still marked running are set to failed. Otherwise a task that died with its process would show a spinner forever and keep the tab from ever auto-sleeping again.
2. Resumed background agents show as running again
When an agent is resumed with SendMessage, Claude Code sends a new
task_startedwith the sametask_idbut with the SendMessage call'stool_use_id. Ness tracked agents bytool_use_id, so the resume created a second record and the original Agent card said "completed" for the whole resumed run. Task events are now matched back to the original record bytask_id, and the resumed run's report goes on the Agent card.task_started/task_notificationare now written todebug.log.The event sequences above come from running the bundled Claude Code 2.1.327 in stream-json mode, and the new manager test replays them.
3. Subagent approval prompts in the sidebar
A blocked subagent showed only a ⚠ in the sidebar. The prompt you could act on was inside its Task card, which for a background agent is usually far up the transcript. The approval card now also appears:
The collapsed "subagents" chip turns amber while any subagent is waiting. A subagent's question (AskUserQuestion) points you to the chat rather than mounting a second copy of the question box, which takes focus and keeps its own draft.
Testing
npm run typecheck,npx electron-vite build,npx vitest run(2827 tests) all pass.auto-sleep-monitor.test.ts(running agent, settled agent, resumed agent, background Bash), reducer tests for resume and exit, a manager test replaying the recorded resume sequence, andcollectAgentstests for each agent's own pending calls.🤖 Generated with Claude Code