Repository navigation
fix(agent-status): clear answered Claude question waits at answer time - #9074
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds Claude question-answer inference for terminal and native-chat interactions. Shared predicates validate AskUserQuestion submissions and fresh status baselines. Renderer PTY input and native-chat delivery invoke the new inference path. The main server validates baselines, clears answered question waits, restores status, and avoids clearing genuine permission requests. New IPC, preload, Electron bridge, and web fallback methods expose the inference operation. Tests cover input handling, delivery settlement, status restoration, baseline validation, and permission-request distinctions. 🚥 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.
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.
cfadaa3 to
8a74ae3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9fd8e599-2f78-450e-b7d7-c01fc3b98746
📒 Files selected for processing (18)
resources/skills/current-manifest.jsonsrc/main/agent-hooks/server.claude-interactive-question.test.tssrc/main/agent-hooks/server.tssrc/main/ipc/agent-hooks.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/native-chat/NativeChatView.tsxsrc/renderer/src/components/native-chat/native-chat-runtime-send.test.tssrc/renderer/src/components/native-chat/native-chat-runtime-send.tssrc/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.tssrc/renderer/src/components/terminal-pane/agent-question-answered-inference.test.tssrc/renderer/src/components/terminal-pane/agent-question-answered-inference.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/web/web-preload-api.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-question-answered-intent.ts
🚧 Files skipped from review as they are similar to previous changes (9)
- src/preload/index.ts
- src/preload/api-types.ts
- src/main/ipc/agent-hooks.ts
- src/renderer/src/components/terminal-pane/pty-connection.ts
- src/renderer/src/web/web-preload-api.ts
- src/main/agent-hooks/server.claude-interactive-question.test.ts
- src/renderer/src/components/terminal-pane/agent-question-answered-inference.ts
- src/renderer/src/components/terminal-pane/agent-question-answered-inference.test.ts
- src/main/agent-hooks/server.ts
…user-question-status-linger # Conflicts: # resources/skills/current-manifest.json
…user-question-status-linger
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9bc23ba6-b3a7-4faa-9ab0-e68f843cfa3b
📒 Files selected for processing (6)
src/renderer/src/components/native-chat/NativeChatInteractiveCard.test.tsxsrc/renderer/src/components/native-chat/NativeChatInteractiveCard.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.tssrc/renderer/src/components/terminal-pane/agent-question-answered-inference.test.tssrc/shared/agent-question-answered-intent.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/shared/agent-question-answered-intent.ts
- src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
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).
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).
Summary
Fixes Claude AskUserQuestion waits that stayed amber after the user answered. Newer Claude reports the wait as a PermissionRequest, so the fix keys question behavior on the tool name and uses a strictly guarded submit inference when Claude emits no answer-time hook.
The fallback accepts only a complete single-select submit (Enter, kitty Enter, or a declared-option digit), revalidates the exact main-process status baseline, preserves real permission stickiness, and synchronizes Claude lead/child state so later child activity cannot resurrect the question.
Review follow-ups:
Screenshots
No visual design change. This changes status-transition timing: the existing amber indicator and question card clear immediately after a proven answer instead of lingering through post-answer model work.
Testing
AI Review Report
Reviewed the full renderer → IPC → main cache → Claude listener flow, including race behavior, child-status restoration, input false positives, cancellation, resource cleanup, native-chat parity, and hot-path cost.
The review found and fixed two meaningful issues:
Performance audit: ordinary terminal input exits after one constant-time set lookup without reading Zustand. Only exact Enter/digit candidates read one pane entry, and prompt JSON is parsed only for a fresh waiting AskUserQuestion. Native chat replaces existing fire-and-forget writes with one verified write per answer step; it adds no polling, scans, subprocesses, request fanout, or unbounded cache/timer state.
Cross-platform audit: no keyboard modifier labels, filesystem paths, shell commands, or platform-specific Electron behavior changed. Input encodings cover ordinary and kitty Enter on macOS/Linux/Windows. Local, WSL/SSH, and runtime-owned terminal delivery continue through the shared runtime abstraction; SSH/runtime inference now waits for acceptance.
Security Audit
The new IPC action is fail-closed: main validates the durable pane key, current Claude/waiting/AskUserQuestion identity, exact prompt/agent/timestamp baseline, and freshness before mutating status. Real Bash/Edit/etc. permission waits cannot be cleared through this path. Batched input, paste, multi-question, multi-select, free-text-row selection, rejected writes, and cancelled writes do not infer completion.
No new command execution, path handling, authentication, secrets, dependencies, or external network endpoints are introduced.
Notes
The fallback intentionally does not infer completion for multi-question, multi-select, free-text, pasted, or batched terminal answers because those inputs do not prove the entire prompt is complete. The real answer-time/next-working hook still clears those waits when emitted.