Skip to content

Fix stale Claude permission status after No or Escape - #32963

Closed
brennanb2025 wants to merge 16 commits into
mainfrom
brennanb2025/sta-10727-permission-status-clear
Closed

brennanb2025 wants to merge 16 commits into
mainfrom
brennanb2025/sta-10727-permission-status-clear

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1662 $\color{#cf222e}{\Huge{\mathbf{−}}}$​50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1612
Prod 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​777 $\color{#cf222e}{\Huge{\mathbf{−}}}$​88 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​689

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 71d70c088d8ab9cb2e39bd08d4dc0ef4b9496f13 passed 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 head 71d70c088d8 finished 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 4f43ae556aa09600ee89e53022e9f2d1e5c0aea2 passed 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 with qa_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 4af4bc1a032 as 2c23e3e2428c6a6481633b03dae420a2883b0e4b. 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.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 23, 2026 23:01
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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
Walkthrough

The change adds Claude permission transcript observation, matching permission requests to transcript tool-use records and polling for results. Accepted transcript updates adjust status and pass through local and relay event paths. Relay envelopes carry settled-request evidence, which settlement matching accepts on live and replay events. Tests and decline and Escape captures cover these flows, including transcript integrity and pane-authority transfer.

Priority: Normal

Merge Risk: Moderate · up to 3b0ec

Permission status can still remain stale or lose track of a pending question in specific flows. Resolve or explicitly accept these risks before merging; the Windows comparison and CI are also pending.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.30% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 30 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description follows the template in most places and gives a clear account of the change, its mechanism, verification, and known limits. It does not fully meet the template. The ELI5 section is mis… Add an ELI5 section in plain language. Replace 'Fixes #' with the actual linked issue number, or confirm the issue to link, because 'Tracked in STA-10727' is not a link. Add before/after visual proof for the status change, or write N/A with…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: fixing stale Claude permission status after a denial or Escape cancellation.
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.
Full details: Description check

Explanation

The description follows the template in most places and gives a clear account of the change, its mechanism, verification, and known limits. It does not fully meet the template. The ELI5 section is missing. The 'Linked Issue' section reads 'Fixes #' with no issue number. It only says 'Tracked in STA-10727', and the template says an outside contributor's PR is ignored unless it links an actual issue. The 'Visual Proof' section has no before/after media, though the description points to branch screenshots and says main has terminal/status capture. The 'Testing' checklist items are not ticked, and the 'Checklist' is not marked. The 'Review' section and 'Agent skill upstream boundary' checkbox are missing. The 'AI Disclosure' section is blank. The description is long and dense, which conflicts with the template's ELI5 and small-and-focused guidance.

Resolution

Add an ELI5 section in plain language. Replace 'Fixes #' with the actual linked issue number, or confirm the issue to link, because 'Tracked in STA-10727' is not a link. Add before/after visual proof for the status change, or write N/A with a reason. Tick the testing checkboxes that apply and say which platforms were tested locally. Complete the AI Disclosure section if the author used an AI model. Address the 'Agent skill upstream boundary' checkbox. Fill in the 'Review' section. Tick or address the Checklist items, including whether lint, typecheck, test, and build pass locally or in CI. Shorten the description so it covers the What Changed and Why sections in plain terms.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@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: 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
📥 Commits

Reviewing files that changed from the base of the PR and between 6e3f205 and 251d0c2.

📒 Files selected for processing: 29
  • src/main/agent-hooks/server-claude-permission-transcript.test.ts
  • src/main/agent-hooks/server-relayed-claude-permission-replay.test.ts
  • src/main/agent-hooks/server/server-authority-aliases.ts
  • src/main/agent-hooks/server/server-claude-status-rules.ts
  • src/main/agent-hooks/server/server-ingest-normalization.ts
  • src/main/agent-hooks/server/server-remote-envelope-normalization.ts
  • src/main/agent-hooks/server/server-status-retries.ts
  • src/shared/__fixtures__/claude-permission-decline.jsonl
  • src/shared/__fixtures__/claude-permission-decline.txt
  • src/shared/__fixtures__/claude-permission-escape.jsonl
  • src/shared/__fixtures__/claude-permission-escape.txt
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-listener/claude-settled-permission-requests.test.ts
  • src/shared/agent-hook-listener/claude-settled-permission-requests.ts
  • src/shared/agent-hook-listener/listener-event.ts
  • src/shared/agent-hook-listener/listener-state.ts
  • src/shared/agent-hook-listener/provider-dispatch.ts
  • src/shared/agent-hook-listener/providers/claude-events.ts
  • src/shared/agent-hook-listener/providers/claude-permission-transcript-records.ts
  • src/shared/agent-hook-listener/providers/claude-permission-transcript.ts
  • src/shared/agent-hook-listener/transcript-poll-policy.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/codex-rollout-jsonl-cursor.ts
  • src/wsl-guest/agent-hook-envelope-build.ts
  • src/wsl-guest/agent-hook-event-admission.ts
  • src/wsl-guest/agent-hook-provider-normalization.ts
  • src/wsl-guest/agent-hook-result-retry-scheduler.ts
  • src/wsl-guest/agent-hook-server.ts
  • src/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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 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 lift

Allow a later lead PreToolUse to clear a retired permission wait.

pollClaudePermissionTranscript can delete the observation without publishing a transition when proof is lost before a result arrives, or after repeated read failures. A later lead PreToolUse with a different ID then hits the sibling gate, returns the cached waiting row, and skips the normal working transition. The pane can remain stuck on “needs you” until Stop.

Keep the gate for live transcript-backed permission waits and AskUserQuestion waits, but let PreToolUse follow 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
📥 Commits

Reviewing files that changed from the base of the PR and between 251d0c2 and 603fd28.

📒 Files selected for processing: 11
  • src/main/agent-hooks/server-claude-permission-transcript.test.ts
  • src/main/agent-hooks/server/server-status-retries.ts
  • src/shared/agent-hook-listener/providers/claude-events.ts
  • src/shared/agent-hook-listener/providers/claude-permission-transcript-records.ts
  • src/shared/agent-hook-listener/providers/claude-permission-transcript.test.ts
  • src/shared/agent-hook-listener/providers/claude-permission-transcript.ts
  • src/shared/agent-transcript-poll-scheduler.test.ts
  • src/shared/codex-rollout-jsonl-cursor.test.ts
  • src/shared/codex-rollout-jsonl-cursor.ts
  • src/shared/codex-subagent-transcript.test.ts
  • src/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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

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 win

Keep a second AskUserQuestion request pending.

If AskUserQuestion q2 emits PreToolUse while q1 is waiting, this branch returns the cached q1 status because their tool-use IDs differ. The return skips the waiting-state update for q2. When q1 completes, the lead can become working even though q2 still needs an answer. Exclude waiting-inducing PreToolUse events 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
Commits

Reviewing files that changed from the base of the PR and between f0c3f51 and 4f43ae5.

Files selected for processing: 2
  • src/shared/agent-hook-listener-interactive-prompts.test.ts
  • src/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.

@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
  • 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
Commits

Reviewing files that changed from the base of the PR and between 4f43ae5 and 3b0ec56.

Files selected for processing: 2
  • src/shared/agent-hook-listener/claude-settled-permission-requests.test.ts
  • src/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.

@brennanb2025

brennanb2025 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

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 71d70c088d8 finished with 40 successful checks and 13 skipped. See the main-sync note for the current merge’s CI..

Real QA passed once on 4f43ae556aa09600ee89e53022e9f2d1e5c0aea2, Windows low spec, Claude 2.1.221 and Codex 0.162.1. No/Escape settled in 1,229/1,198 ms; Q2 stayed pending across observations 9,796 ms apart, then settled after its own decline. Each had an accepted follow-up and real reply. A real question was answered and replied to; Codex produced two replies with advancing transcripts. The lead cleaned up its recorded processes/listeners and verified real config hashes unchanged.

QA carry to reviewed 71d70c088d8ab9cb2e39bd08d4dc0ef4b9496f13: 3b0ec565db9 is the final main merge; 87ead4467bd added temporary non-shipped test diagnostics, removed by 620cd890878; 620cd890878 qualifies transcript acquisition and stable cursor identity (cursor/failure/authority, host/guest real-command integration, real-IO operation contracts); e717038da90 fixes test-only canonical-row assertions; 71d70c088d8 fixes current question identity and scheduler/raw-byte accounting (real curl admission/card and N/10N operation/Unicode boundary contracts). These shipped deltas are CLI/orchestration/performance tests-row flows; unchanged runtime screenshots carry via qa_head. No second full round was run.

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:

Claude No: pending, settled, then a real reply

decline-before.png

decline-after.png

decline-reply.png

Claude Escape: pending, settled, then a real reply

escape-before.png

escape-after.png

escape-reply.png

Genuine second permission: pending, settled, then a real reply

second-pending.png

second-after.png

second-reply.png

Codex: two real replies

codex-reply1.png

codex-reply2.png

Real question: pending, then answered and replied to

question-pending.png

question-reply.png

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 4af4bc1a032 as 2c23e3e2428c6a6481633b03dae420a2883b0e4b. 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.

@nwparker

Copy link
Copy Markdown
Contributor

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.

@nwparker nwparker closed this Oct 25, 2026
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.

2 participants