Skip to content

fix(agent-status): clear answered Claude question waits at answer time - #9074

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/fix-ask-user-question-status-linger
Jul 17, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/fix-ask-user-question-status-linger

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • OpenClaude native chat now uses the same completion callback as its Claude-compatible selector.
  • Native-chat completion now waits for verified local/SSH/runtime acceptance before inferring an answer; rejected or cancelled writes keep the wait visible.
  • Merged latest main and regenerated the versioned skill manifest to resolve conflicts.

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

  • Typecheck: pnpm typecheck
  • Targeted lint on all 17 PR source/test files
  • Targeted tests: 5 files / 141 tests
  • Max-lines ratchet and skill-manifest verification
  • Live Claude CLI A/B: Enter and digit answers clear waiting within ~50 ms; unanswered questions and real permission requests remain waiting
  • Full pnpm lint: blocked after merge by two unrelated switch-exhaustiveness failures already on main (native-chat-session-option-labels.ts and skill-freshness-group.tsx)
  • Full pnpm test under this shell: 31,109 passed; 41 unrelated failures under unsupported Node 26 (repo requires Node 24), primarily unavailable localStorage plus main-only runtime graph/relay fixtures
  • pnpm build: not run
  • Added regression coverage for both Claude wait shapes, stale baseline races, real permissions, lead/child restoration, input classification, cancellation/rejection, OpenClaude parity, and verified remote delivery

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:

  1. OpenClaude used the Claude selector but did not install the answer-settled inference callback.
  2. Remote native-chat writes were treated as delivered when merely queued; inference now waits for the host acceptance result.

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.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 27b9938a-f530-44ea-85b9-7a4018ae8074

📥 Commits

Reviewing files that changed from the base of the PR and between 5d5d893 and 0d13e04.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx

📝 Walkthrough

Walkthrough

Adds 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Clear, concise, and accurately describes the main change: clearing answered Claude question waits at answer time.
Description check ✅ Passed Includes all required sections with substantive details on summary, screenshots, testing, review, security, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-ask-user-question-status-linger branch from cfadaa3 to 8a74ae3 Compare July 16, 2026 22:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9fd8e599-2f78-450e-b7d7-c01fc3b98746

📥 Commits

Reviewing files that changed from the base of the PR and between 0712319 and 6cff6d6.

📒 Files selected for processing (18)
  • resources/skills/current-manifest.json
  • src/main/agent-hooks/server.claude-interactive-question.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/ipc/agent-hooks.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/renderer/src/components/terminal-pane/agent-question-answered-inference.test.ts
  • src/renderer/src/components/terminal-pane/agent-question-answered-inference.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/agent-hook-listener.test.ts
  • src/shared/agent-hook-listener.ts
  • src/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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9bc23ba6-b3a7-4faa-9ab0-e68f843cfa3b

📥 Commits

Reviewing files that changed from the base of the PR and between b8a84ae and 5d5d893.

📒 Files selected for processing (6)
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.test.tsx
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/renderer/src/components/terminal-pane/agent-question-answered-inference.test.ts
  • src/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).
@brennanb2025
brennanb2025 merged commit 2cb5d4e into main Jul 17, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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).
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.

1 participant