Skip to content

fix(agent-hooks): clear a Claude permission wait when its approved tool fails - #29387

Merged
nwparker merged 1 commit into
mainfrom
nwparker/claude-permission-tool-failure
Oct 16, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/claude-permission-tool-failure

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7

ELI5

If you approved a Claude tool and that tool then failed (for example, a command exited with an error), Orca kept showing the pane as "needs permission" even though Claude had already moved on. Now the wait clears as soon as Claude reports that exact tool failed.

What Changed

  • Before: Orca keeps a Claude permission wait visible until it sees the tool it was waiting on resume. It recognized the resume only on PreToolUse / PostToolUse with the same tool name and input. A failed tool reports PostToolUseFailure, and Orca's Claude parser clears the tool name and input for that event, so the check could never match. The wait stayed until some later unrelated hook happened to replace it.
  • After: a PostToolUseFailure carrying the waiting request's exact tool_use_id, from the same owner (the lead, or the same subagent id and type), settles the wait. The row then shows the state Claude reported, which is working. A failure from a different tool use, or from a subagent reusing the id, leaves the wait in place.
  • Mechanism: one extra branch in isClaudePermissionResumingApprovedTool (src/main/agent-hooks/server/server-claude-status-rules.ts), on the execution host's hook server, the single store every reader subscribes to.

Why

The exact request id plus owner is the narrowest evidence that the waiting request is over. It doesn't infer an approval, a cancellation, or the end of a turn. Matching on tool name or input isn't possible for this event, and loosening the existing name/input rule would let a sibling tool's failure clear an unrelated wait.

This is one of the cases listed in #28186. It does not close that issue. The headline case (a transcript result observed during a disconnect that a later hook replaces before the desktop reconnects) needs the transcript-result reconciliation proposed in draft #28187. That draft is not taken over here: it is about 3,000 lines across 37 files, conflicts with main, mixes in unrelated workspace-trust and restart-recovery work, and its author notes that it hasn't been validated against real persisted Claude transcripts.

Linked Issue

Part of #28186. It does not close it.

Visual Proof

N/A: there's no layout change. The pane's status simply leaves the permission state, which the hook-server tests assert directly.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New src/main/agent-hooks/server-claude-permission-tool-failure.test.ts drives the real hook server over HTTP. With an exact-id failure the wait clears (this test fails on main: the row stays waiting). A sibling tool's failure and a subagent's failure with the same id keep the wait.

  • Ran the existing server-claude-permission-visibility, server-claude-child-permission-lifecycle and server-claude-normalization suites: all pass.

  • src/main/claude/claude-structured-* is not touched, so the real-CLI suite does not apply.

AI Disclosure

Review

Codex review (gpt-6.1-sol, high) found no issues.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

SSH: the rule runs on the execution host's hook server, so it applies to local, WSL and managed SSH hosts alike. Remote clients receive the corrected row through the existing status stream. No wire change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…ol fails

Orca keeps a Claude permission wait visible until it sees the exact tool it was
waiting on resume. A tool that fails reports PostToolUseFailure, whose tool
name and input Orca clears, so the resume check never matched and the pane kept
showing "needs permission" while Claude was already working. The exact
tool_use_id and owner now settle the wait for a failure as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1aa27339-d2b4-42de-8564-b093a96af7f7
📥 Commits

Reviewing files that changed from the base of the PR and between 9b99928 and 41a3a94.

📒 Files selected for processing: 2
  • src/main/agent-hooks/server-claude-permission-tool-failure.test.ts
  • src/main/agent-hooks/server/server-claude-status-rules.ts
  • 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.

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