Repository navigation
Fix stale Claude permission status after No or Escape - #32963
brennanb2025 wants to merge 16 commits into
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:
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
736e6f1e-f6b5-4e7a-9a7d-7109dead107e
📒 Files selected for processing: 29
-
src/main/agent-hooks/server-claude-permission-transcript.test.tssrc/main/agent-hooks/server-relayed-claude-permission-replay.test.tssrc/main/agent-hooks/server/server-authority-aliases.tssrc/main/agent-hooks/server/server-claude-status-rules.tssrc/main/agent-hooks/server/server-ingest-normalization.tssrc/main/agent-hooks/server/server-remote-envelope-normalization.tssrc/main/agent-hooks/server/server-status-retries.tssrc/shared/__fixtures__/claude-permission-decline.jsonlsrc/shared/__fixtures__/claude-permission-decline.txtsrc/shared/__fixtures__/claude-permission-escape.jsonlsrc/shared/__fixtures__/claude-permission-escape.txtsrc/shared/agent-hook-listener.tssrc/shared/agent-hook-listener/claude-settled-permission-requests.test.tssrc/shared/agent-hook-listener/claude-settled-permission-requests.tssrc/shared/agent-hook-listener/listener-event.tssrc/shared/agent-hook-listener/listener-state.tssrc/shared/agent-hook-listener/provider-dispatch.tssrc/shared/agent-hook-listener/providers/claude-events.tssrc/shared/agent-hook-listener/providers/claude-permission-transcript-records.tssrc/shared/agent-hook-listener/providers/claude-permission-transcript.tssrc/shared/agent-hook-listener/transcript-poll-policy.tssrc/shared/agent-hook-relay.tssrc/shared/codex-rollout-jsonl-cursor.tssrc/wsl-guest/agent-hook-envelope-build.tssrc/wsl-guest/agent-hook-event-admission.tssrc/wsl-guest/agent-hook-provider-normalization.tssrc/wsl-guest/agent-hook-result-retry-scheduler.tssrc/wsl-guest/agent-hook-server.tssrc/wsl-guest/agent-hook-spool-ingest.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
-
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Allow a later lead PreToolUse to clear a retired permission wait. · claude-events.ts:155-163
src/shared/agent-hook-listener/providers/claude-events.ts:155-163
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftAllow a later lead
PreToolUseto clear a retired permission wait.
pollClaudePermissionTranscriptcan delete the observation without publishing a transition when proof is lost before a result arrives, or after repeated read failures. A later leadPreToolUsewith a different ID then hits the sibling gate, returns the cachedwaitingrow, and skips the normalworkingtransition. The pane can remain stuck on “needs you” untilStop.Keep the gate for live transcript-backed permission waits and AskUserQuestion waits, but let
PreToolUsefollow the normal path after the permission observation is gone.🐛 Suggested fix
const eventToolUseId = readFirstString(hookPayload, ['tool_use_id', 'toolUseId']) + const previousTool = state.lastToolByPaneKey.get(paneKey) + const isLeadPermissionWait = + previousLead?.state === 'waiting' && + previousLead.waitingAgentId === undefined && + !isAskUserQuestionTool(previousTool?.toolName) const isParallelSiblingActivityDuringWait = eventAgentId === undefined && previousLead?.state === 'waiting' && + (eventName !== 'PreToolUse' || + !isLeadPermissionWait || + state.claudePermissionObservationByPaneKey.has(paneKey)) && (eventName === 'PreToolUse' || eventName === 'PostToolUse' || eventName === 'PostToolUseFailure') &&
ℹ️ Review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b9cea912-2e3b-4c3a-91ba-f2ad421da906
📒 Files selected for processing: 11
-
src/main/agent-hooks/server-claude-permission-transcript.test.tssrc/main/agent-hooks/server/server-status-retries.tssrc/shared/agent-hook-listener/providers/claude-events.tssrc/shared/agent-hook-listener/providers/claude-permission-transcript-records.tssrc/shared/agent-hook-listener/providers/claude-permission-transcript.test.tssrc/shared/agent-hook-listener/providers/claude-permission-transcript.tssrc/shared/agent-transcript-poll-scheduler.test.tssrc/shared/codex-rollout-jsonl-cursor.test.tssrc/shared/codex-rollout-jsonl-cursor.tssrc/shared/codex-subagent-transcript.test.tssrc/wsl-guest/agent-hook-result-retry-scheduler.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Major · Keep a second AskUserQuestion request pending. · claude-events.ts:159
src/shared/agent-hook-listener/providers/claude-events.ts:159
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winKeep a second AskUserQuestion request pending.
If AskUserQuestion
q2emitsPreToolUsewhileq1is waiting, this branch returns the cachedq1status because their tool-use IDs differ. The return skips the waiting-state update forq2. Whenq1completes, the lead can becomeworkingeven thoughq2still needs an answer. Exclude waiting-inducingPreToolUseevents from this sibling-activity branch.

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3b0dbf4e-9f8a-4389-9c8b-51e4d4f21e5a
Files selected for processing: 2-
src/shared/agent-hook-listener-interactive-prompts.test.tssrc/shared/agent-hook-listener/providers/claude-events.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
41b811b4-47d1-4b43-923f-345a4bfd0237
Files selected for processing: 2-
src/shared/agent-hook-listener/claude-settled-permission-requests.test.tssrc/shared/agent-hook-listener/providers/claude-events.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
|
Choosing No or pressing Escape could leave Orca showing an ended Claude permission. The real main baseline stayed stale for at least 24 seconds; normal CLI input already worked. This PR settles the exact request on its execution host and independently derives its turn outcome. A genuine second permission or question keeps its own pending state. Full review completed through round 6 at this head. Independent correctness, performance, reference and readiness audits found no remaining proven issue. Review corrections cover request identity and admission, incomplete historical proof, stable append identity, current question propagation, recurring scheduler scans and raw-byte accounting. The final correction passed 130 distinct cases in 11 named files, including real curl→local/guest HTTP→canonical row→visible question card. These are transport/fixture tests, not live parallel-question evidence. Reviewed-head production count was 780/840. CI on the original reviewed head Real QA passed once on QA carry to reviewed Deferred/unexercised: synchronous regular-file latency remains unmeasured; byte/operation bounds do not make it asynchronous. Continued-work rejection is fixture-only because this Claude version interrupts on rejection. Unsupported or missing/ambiguous/late/gapped/exhausted evidence, old peers, replay eviction or missed recovered-ID binds remain gaps. Lost turn proof may leave Working without a guarantee of eventual Interrupted. External admission/clear bursts can remain quadratic. Earlier retirement of already-over-limit unfinished acquisition is intended. The existing roughly two-minute fallback is source-predicted, not measured. For Brennan’s review: the whole-window branch captures below cover every QA flow. Main has terminal/status capture without rendered screenshots. Intermediate wrong-tab/raced captures were excluded; surfaces retain their existing labels. Judgment points:
Main sync, 2026-10-25: The first conflict merge, A second blocking conflict with the MCP elicitation change was resolved by merging The required explicit lint-staged check passed in full. 221 tests passed in 13 named files through tc-gate: the existing 11 suites plus both MCP elicitation change suites. One focused regression covers pending, already-settled and unbound permissions, plus stale callbacks. The correction is in the CLI hook/orchestration tests row; the existing real Claude No/Escape/Q2 and normal-input QA and Codex evidence remain valid at Narrow review agrees with the exact merged head and found no remaining demonstrated interaction failure. The single CI watch exited successfully: 41 checks passed and 13 were skipped, including successful Ubuntu ARM persistence. GitHub reports the PR mergeable, CLEAN and out of draft. The earlier build blocker is resolved. |
|
Superseded: #30261 (OSC 7501 program status) already clears the permission wait when a Claude prompt is declined with Escape or No — re-verified with Claude 2.1.310. The remaining gap (hosts without OSC 7501) isn't worth the transcript approach's size for now. |













Choosing No or pressing Escape could return Claude to its prompt while Orca kept showing “needs permission.” This PR clears the exact ended request on its execution host and derives Interrupted or continued work from separate current evidence. A genuine second permission or question keeps its own state. Typed commands, aliases and normal submission retain their launch path.
The implementation reuses the bounded transcript cursor, shared deadline scheduler and canonical status owner. Unknown request IDs require a complete contiguous acquisition; exact settlement does not itself certify a turn outcome. Stable file identity preserves append progress. Current question identity survives ordinary sibling activity and delayed old results. Recurring polling batches deadline scans, and acquisition charges raw bytes directly.
Tracked in STA-10727. #15078 reports the same symptom and was evidence only. #31182 overlaps status ingest; whichever merges second reconciles with current main.
Verification: Full review completed through round 6 at this head. Independent correctness, performance, reference and readiness audits found no remaining proven issue. The final correction at
71d70c088d8ab9cb2e39bd08d4dc0ef4b9496f13passed 130 distinct cases across 11 named files, including real system curl through local/guest HTTP admission to the canonical row and visible question card. Operation contracts use real capture-derived files at 10/100 observers, count deadline values and iterator visits, and distinguish recurring work from external admission/teardown. Completed byte-limit positives and split-UTF8 over-limit negatives pass. Normal commit hook passed. CI on the original reviewed head71d70c088d8finished with 40 successful checks and 13 skipped. See the main-sync note for the current merge’s CI..One targeted Windows low spec QA round at
4f43ae556aa09600ee89e53022e9f2d1e5c0aea2passed with real Claude 2.1.221 and Codex 0.162.1: No, Escape, a genuine second permission, normal follow-up replies, a real question/answer/reply, and two Codex replies. No/Escape settled in 1,229/1,198 ms; Q2 stayed pending across observations 9,796 ms apart and settled after its own decline. Later changes affect CLI/orchestration/performance seams and use integration/operation tests; that QA carries withqa_head. The original main baseline with Claude 2.1.302 reproduced stale status for at least 24 seconds; normal input already worked. Screenshots are branch evidence; main has terminal/status capture.Limits: Continued-work rejection is fixture evidence only; the tested Claude version interrupts on rejection. Older unchanged execution hosts/receivers retain their existing behavior. Missing or ambiguous identity, unavailable/gapped/exhausted proof, delayed historical records, replay eviction or a receiver missing the live recovered-ID bind can remain unresolved. Lost terminal proof may leave Working after exact request settlement; eventual Interrupted is not promised. Byte/operation bounds do not prove synchronous filesystem latency. External admission and teardown still scan the population and can be quadratic in bursts. An already-over-limit unfinished acquisition retires earlier by design.
Design: The common pattern removes an exact pending request when it ends. Execution-host observation is an intended adaptation for arbitrary independently running terminal commands and aliases. Full review path covers lifecycle, ordering and mixed-version delivery. Reviewed-head production budget was 780/840 changed lines using per-path max(additions,deletions); no new saved format, launch requirement, input gate or minimum server version.
Main sync, 2026-10-25: The first conflict merge,
528cfb20, retained the permission fix and main’s comment cleanup. Its Ubuntu ARM build flake passed on attempt 2.A second blocking conflict with the MCP elicitation change was resolved by merging
4af4bc1a032as2c23e3e2428c6a6481633b03dae420a2883b0e4b. MCP dialogs still show Needs You and restore the preceding state when answered. Declining or cancelling a permission still settles that permission from the transcript. The overlap test exposed an old permission observer treating a newer MCP dialog as its wait; the resolution retires that observer and prevents elicitation from inheriting permission identity. A queued old settlement cannot clear the dialog, and an elicitation after settlement cannot reopen the permission.The required explicit lint-staged check passed in full. 221 tests passed in 13 named files through tc-gate: the existing 11 suites plus both MCP elicitation change suites. One focused regression covers pending, already-settled and unbound permissions, plus stale callbacks. The correction is in the CLI hook/orchestration tests row; the existing real Claude No/Escape/Q2 and normal-input QA and Codex evidence remain valid at
qa_head=4f43ae5. No chat lifecycle, process ownership, login or screen flow changed. The marker records the newly reviewed head while preserving that QA head.Narrow review agrees with the exact merged head and found no remaining demonstrated interaction failure. The single CI watch exited successfully: 41 checks passed and 13 were skipped, including successful Ubuntu ARM persistence. GitHub reports the PR mergeable, CLEAN and out of draft. The earlier build blocker is resolved.