Repository navigation
fix(agent-status): waiting state for Claude AskUserQuestion + stop stale-title worktree spinners - #7852
Conversation
…e-title worktree spinners Claude's AskUserQuestion tool is auto-allowed, so it emits a PreToolUse (not PermissionRequest) while blocked on a human answer. normalizeClaudeEvent mapped that to `working`, so the sidebar showed a spinner that decayed to grey while the question sat. Map the auto-allowed AskUserQuestion PreToolUse to `waiting` instead, mirroring the Kimi/OpenCode handling, so the row and worktree dots read amber "Waiting for input". Separately, a frozen braille-spinner title left by an exited agent (e.g. "⠐ Review branch for regressions" over a shell prompt) kept classifyTitleActivity returning `working`, spinning the worktree dot forever with 0 agents — the row builder rejects the same unattributable title, so no agent row is shown. Gate tabHasStatus's title-derived working/permission on the same agent attribution the row builder uses (resolveAgentTypeFromTerminalTitle), so a title only spins the dot when it would also show a row. Hook-driven status (hasLiveWorking/ hasPermission) is untouched.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR modifies worktree status resolution to require agent attribution before trusting title-derived working/permission states, using resolveAgentTypeFromTerminalTitle instead of classifyTitleActivity for attribution checks. It also updates Claude event normalization in agent-hook-listener.ts to map AskUserQuestion PreToolUse events to a "waiting" state rather than "working", alongside PermissionRequest events. Corresponding regression tests were added for both changes: worktree-status tests verify unattributable spinner titles resolve to "active" while attributable ones resolve to "working"; agent-hook-listener tests verify AskUserQuestion transitions between waiting and working states correctly, while non-AskUserQuestion tool calls remain unaffected. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
An answered AskUserQuestion left the amber "waiting" indicator on sidebar rows and tabs until the agent's next tool hook or turn end — unbounded linger while the model thinks or streams after the answer (measured 17s for a 1000-word reply, 44s for 3000 words). Root cause is an event-shape change: newer Claude reports the AskUserQuestion wait as PermissionRequest (not the PreToolUse shape #7852 special-cased), so the wait inherited real-permission stickiness and shouldKeepClaudePermissionVisible swallowed the answer-time PostToolUse(AskUserQuestion) working event — the identity match can never succeed because the question's PermissionRequest carries no inheritable tool_use_id. That silently undid #8311 for questions. Two scoped changes, both keyed on the tool name rather than the hook event name: - Sticky permission hold now exempts AskUserQuestion waits, so the real answer-time hook (when Claude sends one) clears the wait as #8311 intended. - New guarded inference for the hook Claude may never send: the submit keystroke (Enter or digit quick-select) into a pane whose fresh status is a waiting AskUserQuestion synthesizes the post-answer state, exactly mirroring the existing interrupt inference (renderer baseline capture, main-process re-validation, listener lead-state sync so child-driven refreshes cannot resurrect the dismissed question). Real permission waits (other tools) keep their sticky semantics; batched input and pastes never match the submit classifier. Verified live against a real claude CLI: waiting -> working within ~50ms of both Enter and digit answers, question card dropped, unanswered questions still hold amber, permission stickiness covered by tests.
#9074) * fix(agent-status): clear answered Claude question waits at answer time An answered AskUserQuestion left the amber "waiting" indicator on sidebar rows and tabs until the agent's next tool hook or turn end — unbounded linger while the model thinks or streams after the answer (measured 17s for a 1000-word reply, 44s for 3000 words). Root cause is an event-shape change: newer Claude reports the AskUserQuestion wait as PermissionRequest (not the PreToolUse shape #7852 special-cased), so the wait inherited real-permission stickiness and shouldKeepClaudePermissionVisible swallowed the answer-time PostToolUse(AskUserQuestion) working event — the identity match can never succeed because the question's PermissionRequest carries no inheritable tool_use_id. That silently undid #8311 for questions. Two scoped changes, both keyed on the tool name rather than the hook event name: - Sticky permission hold now exempts AskUserQuestion waits, so the real answer-time hook (when Claude sends one) clears the wait as #8311 intended. - New guarded inference for the hook Claude may never send: the submit keystroke (Enter or digit quick-select) into a pane whose fresh status is a waiting AskUserQuestion synthesizes the post-answer state, exactly mirroring the existing interrupt inference (renderer baseline capture, main-process re-validation, listener lead-state sync so child-driven refreshes cannot resurrect the dismissed question). Real permission waits (other tools) keep their sticky semantics; batched input and pastes never match the submit classifier. Verified live against a real claude CLI: waiting -> working within ~50ms of both Enter and digit answers, question card dropped, unanswered questions still hold amber, permission stickiness covered by tests. * fix(agent-status): guard question answer inference Keep multi-question, multi-select, and free-text selector interactions waiting until the full prompt is submitted. Wire native-chat answers into the same guarded inference only after every paced runtime write succeeds, with cancellation and delivery-failure coverage. * chore(skills): refresh manifest for rc.2 * fix(agent-status): verify native chat answer delivery * fix(agent-status): await verified question delivery * fix(agent-status): pin native-chat answer baseline before delivery The native-chat question-answered inference read the live pane status at settle time (after the paced send + remote acceptance, which can span seconds on SSH). If a replacement AskUserQuestion became current in that window, the settle callback minted a fresh baseline from the new question and the server cleared *its* wait — dismissing a question the user never answered. Capture the answered question's baseline before delivery and have the inference getter return it, so the server re-validates against the pinned baseline and rejects a changed status — the same capture-then-revalidate contract the terminal keystroke path already uses. Also hoist the shouldStepNativeChatAskAnswer predicate to a single evaluation. Regression test swaps the live status between sendAnswer and settle and asserts the answered question's baseline is used (fails against the prior live-read getter).
…e-title worktree spinners (stablyai#7852) Claude's AskUserQuestion tool is auto-allowed, so it emits a PreToolUse (not PermissionRequest) while blocked on a human answer. normalizeClaudeEvent mapped that to `working`, so the sidebar showed a spinner that decayed to grey while the question sat. Map the auto-allowed AskUserQuestion PreToolUse to `waiting` instead, mirroring the Kimi/OpenCode handling, so the row and worktree dots read amber "Waiting for input". Separately, a frozen braille-spinner title left by an exited agent (e.g. "⠐ Review branch for regressions" over a shell prompt) kept classifyTitleActivity returning `working`, spinning the worktree dot forever with 0 agents — the row builder rejects the same unattributable title, so no agent row is shown. Gate tabHasStatus's title-derived working/permission on the same agent attribution the row builder uses (resolveAgentTypeFromTerminalTitle), so a title only spins the dot when it would also show a row. Hook-driven status (hasLiveWorking/ hasPermission) is untouched.
stablyai#9074) * fix(agent-status): clear answered Claude question waits at answer time An answered AskUserQuestion left the amber "waiting" indicator on sidebar rows and tabs until the agent's next tool hook or turn end — unbounded linger while the model thinks or streams after the answer (measured 17s for a 1000-word reply, 44s for 3000 words). Root cause is an event-shape change: newer Claude reports the AskUserQuestion wait as PermissionRequest (not the PreToolUse shape stablyai#7852 special-cased), so the wait inherited real-permission stickiness and shouldKeepClaudePermissionVisible swallowed the answer-time PostToolUse(AskUserQuestion) working event — the identity match can never succeed because the question's PermissionRequest carries no inheritable tool_use_id. That silently undid stablyai#8311 for questions. Two scoped changes, both keyed on the tool name rather than the hook event name: - Sticky permission hold now exempts AskUserQuestion waits, so the real answer-time hook (when Claude sends one) clears the wait as stablyai#8311 intended. - New guarded inference for the hook Claude may never send: the submit keystroke (Enter or digit quick-select) into a pane whose fresh status is a waiting AskUserQuestion synthesizes the post-answer state, exactly mirroring the existing interrupt inference (renderer baseline capture, main-process re-validation, listener lead-state sync so child-driven refreshes cannot resurrect the dismissed question). Real permission waits (other tools) keep their sticky semantics; batched input and pastes never match the submit classifier. Verified live against a real claude CLI: waiting -> working within ~50ms of both Enter and digit answers, question card dropped, unanswered questions still hold amber, permission stickiness covered by tests. * fix(agent-status): guard question answer inference Keep multi-question, multi-select, and free-text selector interactions waiting until the full prompt is submitted. Wire native-chat answers into the same guarded inference only after every paced runtime write succeeds, with cancellation and delivery-failure coverage. * chore(skills): refresh manifest for rc.2 * fix(agent-status): verify native chat answer delivery * fix(agent-status): await verified question delivery * fix(agent-status): pin native-chat answer baseline before delivery The native-chat question-answered inference read the live pane status at settle time (after the paced send + remote acceptance, which can span seconds on SSH). If a replacement AskUserQuestion became current in that window, the settle callback minted a fresh baseline from the new question and the server cleared *its* wait — dismissing a question the user never answered. Capture the answered question's baseline before delivery and have the inference getter return it, so the server re-validates against the pinned baseline and rejects a changed status — the same capture-then-revalidate contract the terminal keystroke path already uses. Also hoist the shouldStepNativeChatAskAnswer predicate to a single evaluation. Regression test swaps the live status between sendAnswer and settle and asserts the answered question's baseline is used (fails against the prior live-read getter).
Problem
Two agent-status accuracy bugs, both reproduced against a live instance:
AskUserQuestionshowed grey/idle while the agent was actually waiting for the user to answer an interactive question. Its auto-allowed tool emits aPreToolUse(notPermissionRequest) while blocked, whichnormalizeClaudeEventmapped toworking— so the row showed a spinner that then decayed to grey.⠐ Review branch for regressionssitting over a plain shell prompt) keptclassifyTitleActivityreturningworking, so the worktree top-level dot spun forever even though no agent was running and the sidebar showed 0 agent rows.Fix
src/shared/agent-hook-listener.ts— map the auto-allowedAskUserQuestionPreToolUsetowaiting(mirrors the existing Kimi/OpenCode handling, reusesisAskUserQuestionTool). Sidebar dot and worktree dot now read amber "Waiting for input" and stay durable instead of decaying to grey.src/renderer/src/lib/worktree-status.ts— gatetabHasStatus's title-derivedworking/permissionon agent attribution (resolveAgentTypeFromTerminalTitle(title) !== null), the same check the sidebar row builder uses. A title only spins the worktree dot when it would also produce an agent row. Hook-driven status (hasLiveWorking/hasPermission) is untouched, so real working/blocked agents are unaffected.Why the second gate is safe
Managed agents (Claude/Codex/Gemini/…) drive the worktree via their hook status, not the title heuristic — the title path is only a fallback. Gating it on attribution kills the unattributable stale-spinner case while leaving hook-backed agents spinning. Added tests cover:
⠐ Review branch for regressions→ not working; an attributable⠹ codex …title → working; and a hook-backed agent still working despite a stale unattributable title.Validation
agent-hook-listener,worktree-status,WorktreeCard,worktree-agent-activity-summary,AgentStateDot(new tests reproduce the exact reported titles).max-linessuppressions.Made with Orca 🐋