fix(hotkey): preserve exact background select-all receipts #796
PR Summary
<!-- CURSOR_SUMMARY -->
Medium Risk
Changes background hotkey, typing, and exact-window receipt validation in automation-critical paths; behavior is heavily tested but affects dispatch and error semantics callers rely on.
Overview
Fixes a mismatch where background Cmd+A already performed an Accessibility selection write but reported accessibility_action, so exact-window CLI/MCP validation rejected the route after the mutation.
The hotkey path now emits one dispatched_unverified outcome with accessibility_value when select-all uses AXSelectedTextRange. ExactWindowKeyboardRuntime.validateHotkeyRouteReceipt applies a Cmd+A-only receipt policy shared by CLI and MCP PressTool, while other chords still require window-targeted keyboard delivery.
Background select-all binds to the retained exact-window text receiver: process/window bounds and optional focused-element identity are checked before writing; stale, missing, or drifted receivers refuse without keyboard replay. Ambiguous AX setter failures surface as indeterminate hotkey/typing receipts without replay; definite unsupported selection still falls back to process-targeted events.
TypeService keeps known accepted-prefix counts when later AX leaves fail, avoids double-counting continuation errors, and leaves zero-input AX refusals retry-safe. CI adds anchored Core and mocked PressCommandTests regressions plus docs/changelog for the receipt and remaining strategy/hold limitations.
<sup>Reviewed by Cursor Bugbot for commit 7384de2d72f36f1d8abad7c418505c26aa9452ec. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
<!-- /CURSOR_SUMMARY -->
Type path mishandles new AX errors
Medium Severity
<!-- DESCRIPTION START -->textMutationAccepted now throws InputDeliveryIndeterminateError and DesktopActionFailure from shared type inserts, clears, and special keys. TypeService rethrows the indeterminate error without the sequence's prior emittedUnitCount and wraps the refusal as indeterminate, so a mid-string AX failure can hide already-applied edits and mark retry-safe permission or stale failures as unsafe.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 3fef730c-3da4-4ee6-a731-7f66552149b0 -->
<!-- LOCATIONS START
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/BackgroundInputDriver.swift#L937-L961
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjY3YjhkYTE3LWE3MjUtNGI3NS04Y2Y1LTk5Y2MxZDIyOTU3MCIsImVuY3J5cHRpb25LZXkiOiJNXzhuYlFsZ2ptSktuN1RfVUhyMWswLTZzdWZ5VXRxV2w3VFFSXzBYa3hvIiwiYnJhbmNoIjoiY29kZXgvdGFyZ2V0ZWQtY29tbWFuZC1hLXJlY2VpcHRzIiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjY3YjhkYTE3LWE3MjUtNGI3NS04Y2Y1LTk5Y2MxZDIyOTU3MCIsImVuY3J5cHRpb25LZXkiOiJNXzhuYlFsZ2ptSktuN1RfVUhyMWswLTZzdWZ5VXRxV2w3VFFSXzBYa3hvIiwiYnJhbmNoIjoiY29kZXgvdGFyZ2V0ZWQtY29tbWFuZC1hLXJlY2VpcHRzIiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJOdW1iZXIiOjc5NiwiY29tbWl0U2hhIjoiNWM0MjFlZDBmNjkxYzIwNDE4M2VlMTg1OTM2YWE2Y2VlMGI0ZTdhZCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit 5c421ed0f691c204183ee185936aa6cee0b4e7ad. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo5ZDQ5MDllNi0xY2JhLTQ4YTktODQ0Mi04ZmM1NGNmYWUzZjciLCJlbmNyeXB0aW9uS2V5Ijoic2hYQnpPT3d3c1ZvMTRYLUtIamhLMEFZWGxub1hxMGFEQlM2MGk2c1REcyIsImJyYW5jaCI6ImNvZGV4L3RhcmdldGVkLWNvbW1hbmQtYS1yZWNlaXB0cyIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by Cursor Bugbot for commit 5c421ed0f691c204183ee185936aa6cee0b4e7ad. Configure here.</sup>
Codex review: needs maintainer review before merge. _Reviewed September 24, 2026, 6:32 PM ET / 22:32 UTC (Revision 4)._
ClawSweeper review
What this changes
The branch makes background Cmd+A report its Accessibility selection accurately, validates the selected window and field before writing, and adds CLI, MCP, test, CI, and documentation coverage.
Merge readiness
✅ Ready for maintainer review
Current main and v4.5.0 still have the reported receipt mismatch, so this PR remains useful. The earlier receiver-binding finding is addressed in the current head, and a collaborator explicitly accepted the scoped typing fallback tradeoff.
Priority: P2
Reviewed head: 7384de2d72f36f1d8abad7c418505c26aa9452ec
Review scores
| Measure | Result | What it means |
|---|---|---|
| Overall readiness | 🐚 platinum hermit (4/6) | Focused native evidence carries to the unchanged owning source, and the patch has broad regression coverage with no remaining actionable finding. |
| Proof confidence | 🦞 diamond lobster (5/6) | Sufficient (terminal): The captured PR body reports a signed native default Cmd+A run on source 83481a69: selection changed from {80,0} to {0,80}, the CLI emitted one background Accessibility-value unit, and no keyboard events or activation were observed. The 13 owning runtime and test files are unchanged at this head; injected receiver tests cover refusals, while native focus drift is not claimed. No stored-data contract changes. |
| Patch quality | 🐚 platinum hermit (4/6) | No actionable review findings were identified. |
Verification
| Check | Result | Evidence |
|---|---|---|
| Real behavior | Verified | Sufficient (terminal): The captured PR body reports a signed native default Cmd+A run on source 83481a69: selection changed from {80,0} to {0,80}, the CLI emitted one background Accessibility-value unit, and no keyboard events or activation were observed. The 13 owning runtime and test files are unchanged at this head; injected receiver tests cover refusals, while native focus drift is not claimed. No stored-data contract changes. |
| Evidence reviewed | 10 items | Current main still has the mismatch: The fetched main reports a successful AX selection as accessibility_action, while its exact-window route checker does not admit that mechanism.<br>Current main route check: Background accessibility_value delivery is permitted only for composite typing on main, not for a hotkey.<br>Release check: The v4.5.0 source also reports the AX selection as accessibility_action; the proposed correction is not already shipped there. |
| Findings | None | None. |
| Security | None | None. |
How this fits together
Peekaboo receives hotkey requests through its CLI and MCP tool, then uses macOS Accessibility or keyboard events to act on a selected window. The automation result is checked before the CLI or agent receives a delivery receipt.
flowchart TD
A[CLI or MCP hotkey] --> B[Exact window receipt]
B --> C{Select all field?}
C -->|Yes| D{Receiver matches?}
D -->|No| E[Refuse before input]
D -->|Yes| F[Accessibility selection]
C -->|No| G[Window targeted keys]
F --> H[Outcome receipt]
G --> H
Before merge
None.
<details>
<summary><strong>Agent review details</strong></summary>
Security
None.
Review metrics
| Metric | Value | Why it matters |
|---|---|---|
| Code and regression delta | production +229/−79 lines; tests +990/−41 lines | The production growth implements receiver validation and receipt handling, with substantially larger focused regression coverage. |
Technical review
Best possible solution:
Keep the receipt correction and retained-receiver guard together, preserve unverified outcome semantics, and handle broader typing-strategy qualification in https://github.com/openclaw/Peekaboo/pull/782.
Do we have a high-confidence way to reproduce the issue?
Yes, from source: current main writes the selection but labels it accessibility_action, which the exact-window checker rejects. This read-only review did not run a native reproduction.
Is this the best way to solve the issue?
Yes. The branch corrects the existing shortcut's receipt and checks the retained receiver, while sharing the narrow CLI/MCP route rule.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against b7e2896cd4c5.
Labels
Label changes:
No label changes.
Label justifications:
P2: The mismatch affects a specific background select-all route, with a bounded repair and limited blast radius.merge-risk: 🚨 compatibility: Ambiguous AX typing failures now stop instead of falling back to synthetic input; the collaborator explicitly accepted that scoped recovery tradeoff.rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured PR body reports a signed native default Cmd+A run on source 83481a69: selection changed from {80,0} to {0,80}, the CLI emitted one background Accessibility-value unit, and no keyboard events or activation were observed. The 13 owning runtime and test files are unchanged at this head; injected receiver tests cover refusals, while native focus drift is not claimed. No stored-data contract changes.proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body reports a signed native default Cmd+A run on source 83481a69: selection changed from {80,0} to {0,80}, the CLI emitted one background Accessibility-value unit, and no keyboard events or activation were observed. The 13 owning runtime and test files are unchanged at this head; injected receiver tests cover refusals, while native focus drift is not claimed. No stored-data contract changes.Evidence
What I checked:
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/HotkeyService.swift:237, b7e2896cd4c5)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Strategy/UIAutomationTarget.swift:382, b7e2896cd4c5)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/HotkeyService.swift:237, a1d48b28a371)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/BackgroundInputDriver.swift:965, 7384de2d72f3)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Strategy/UIAutomationTarget.swift:384, 7384de2d72f3)Core/PeekabooCore/Tests/PeekabooTests/HotkeySelectAllReceiptTests.swift:139, 7384de2d72f3)Likely related people:
Rating scale
| Score | Internal tier | Crab rank | Meaning |
|---:|:---:|---|---|
| 6/6 | S | 🦀 challenger crab | Exceptional readiness |
| 5/6 | A | 🦞 diamond lobster | Very strong readiness |
| 4/6 | B | 🐚 platinum hermit | Good normal PR; ordinary maintainer review |
| 3/6 | C | 🦐 gold shrimp | Useful, but confidence is limited |
| 2/6 | D | 🦪 silver shellfish | Proof or implementation needs work |
| 1/6 | F | 🧂 unranked krab | Not merge-ready |
| N/A | NA | 🌊 off-meta tidepool | Rating does not apply |
Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.
Workflow
@clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.@clawsweeper review to request a fresh review only.@clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.@clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.History
<details>
<summary>Review history (3 earlier review cycles)</summary>
<!-- clawsweeper-review-history v=1 total=3 -->
</details>
</details>
<!-- clawsweeper-verdict:needs-human item=796 sha=7384de2d72f36f1d8abad7c418505c26aa9452ec confidence=high updated_at=2026-09-24T22:29:39Z reviewed_at=2026-09-24T22:32:03.501Z lease_owner=github-run-36067635132-1 lease_comment_id=5823280185 source_revision=27967054a781a1ee1ef0c253a4e5ea2e523b66cf0549c85dff36db779099fc8e live_verification=absent -->
<!-- clawsweeper-review-state:ready item=796 sha=7384de2d72f36f1d8abad7c418505c26aa9452ec v=1 -->
<!-- clawsweeper-review-version item=796 reviewed_at=2026-09-24T22:32:03.501Z sha=7384de2d72f36f1d8abad7c418505c26aa9452ec source_revision=27967054a781a1ee1ef0c253a4e5ea2e523b66cf0549c85dff36db779099fc8e lease_owner=github-run-36067635132-1 lease_comment_id=5823280185 v=1 -->
<!-- clawsweeper-review item=796 -->
Fixed in 25d91bf8d88a66d706d81db7c8e33ecf33a9dd05 with the two bounded TypeService normalization changes from #782: a nil-count indeterminate leaf keeps the sequence's known accepted prefix, while a canonical refused / none result before dispatch stays retry safe. A supplied continuation count is retained as-is, and an uncertain write is never counted as accepted.
The regression suite covers text inserts, editable keys, and clear operations with 18 injected cases. It failed first on the old normalization. The final head, including the separate receiver-binding repair, passes 35 tests in the three Core receipt suites and all 33 CI wiring/adjacent Node contracts. This TypeService follow-up itself does not change strategies, defaults, focus handling, or input drivers.
The receiver-binding finding is fixed in 83481a69be406c909dede1876e830336c8591a57. The exact-window receipt now reaches the native select-all primitive. It resolves one AX object, validates that object's actual PID/window and optional focused-element identity before editability or value checks, then selects on that same retained object. Changed, missing, or unreadable receiver identity is a canonical no-dispatch refusal, not an unsupported route that can replay keyboard input.
The deterministic regressions fail before the repair and now cover another-window drift, a different snapshot-pinned field, a noneditable changed receiver, missing/unreadable identity, and receiver retention when application focus changes during the text read. Direct exact-window requests without a field pin still allow another field in that same window. These tests prove receiver binding, not atomic OS focus locking. The exact Core CI suites pass 35 tests; all 33 workflow/adjacent Node contracts pass. Input strategies, hold behavior, and MCP's separate confirmed-effect requirement remain unchanged.
Maintainer decision: retain the shared AX failure classification in this PR. A generic AX setter failure does not establish that no mutation occurred, so automatically replaying the input through keyboard events can duplicate an edit. Definite unsupported-operation results keep their existing fallback; permission/stale-receiver refusals remain no-dispatch outcomes, and uncertain mutations stop without replay.
This is an intentional usability tradeoff: some apps that previously continued through synthetic typing after a generic AX error will now return an indeterminate, retry-unsafe result and require fresh observation/recovery instead of automatic fallback. That fail-closed behavior is accepted here; it does not change the selected input strategy or claim that all existing typing setups continue automatically.
The 18 injected TypeService text/clear/editable-key cases qualify classification, accepted-prefix preservation, refusal safety, and continuation counts. The signed native run on 83481a69be406c909dede1876e830336c8591a57 qualifies only the default Cmd+A selection path. It is not native failed-typing upgrade proof or full typing qualification; broader typing qualification remains separate in #782.
Landed as c50eb0f05631bf73d57d1472b59da170462f1c41 after exact-head macOS CI, CodeQL, supplemental validation, and fresh reviews passed.
The repair keeps the working background Cmd+A selection path, reports its AX-value mutation honestly, and validates the retained receiver before selection. The shared failure handling preserves accepted input prefixes and refuses ambiguous replay. Existing strategy/hold limitations and MCP's separate confirmed-effect requirement remain unchanged.
Verification: the refreshed candidate passed 35 Core/MCP receipt tests, 17 private-root lane tests, 38 inert wiring/adjacent contracts, scoped style and documentation checks, and complete-candidate P0 Autoreview. Native default Cmd+A proof belongs to source-equivalent revision 83481a69: selection changed from 80/0 to 0/80, with zero receiver keyboard events, one dispatched-unverified AX-value unit, unchanged focus samples, a complete 30-second activation observer, and owned cleanup. All 13 owned runtime/test files remained identical through the final candidate. The actual main integration passed 25 graph/policy contracts and its merged tree matches the tested tree.
CI: macOS, CodeQL, and supplemental. Supplemental required one targeted dependency-job retry after an unchanged AXorcist timing test failed. The retry passed without source or timeout changes; the exact scheduling cause is not established, and the test runner was nonparallel.
Main is synchronized locally. This is a landed source fix, not a new release/deployment or proof of complete keyboard parity; #797 remains separate.
steipete
Summary
Preserve the existing working background Cmd+A Accessibility selection while fixing its post-dispatch result. The shortcut writes
AXSelectedTextRange, but previously labeled that writeaccessibility_action; exact-window CLI/MCP validation then rejected the receipt after the mutation had already happened.The producer now reports one unverified
accessibility_valuemutation. CLI and MCP share a normalized Cmd+A-only receipt policy: generic menu actions, composite delivery, process delivery, foreground delivery, and value receipts for other chords remain rejected.The exact-window receipt also reaches the native selection primitive. It resolves one AX receiver, validates that object's actual process/window and optional focused-field identity before editability or value checks, and writes to that same retained object. A changed, missing, or unreadable receiver refuses before dispatch rather than falling back to keyboard input. Direct exact-window requests without a field pin retain their same-window behavior; snapshot-pinned requests retain the specific field contract. This fixes the review finding without claiming atomic OS focus locking.
The shared AX setter classification stops ambiguous mutations without replay. TypeService preserves a known accepted prefix when a later AX failure lacks a count, preserves a supplied continuation count without double counting, and keeps a canonical zero-input refusal retry safe. These bounded shared changes match the corresponding #782 safety repairs and are subsumed there if this lands first.
Default shortcut placement, input-strategy selection, and hold behavior are unchanged. Existing
synthFirst/synthOnlyand--holdlimitations for this shortcut are documented, not claimed fixed. MCP also retains its separate confirmed-effect requirement; preserving an unverified receipt does not turn it into a confirmed success.Proof
Current integration head
7384de2d72f36f1d8abad7c418505c26aa9452ecmerges maine5398c818without rewriting the qualified83481a69band8bc916fe3history. All 13 task-owned runtime/test files are byte-identical to those heads; the inherited #793/#794 lane, paste, and error semantics, both sets of CI guards, and contributor credits are preserved. The native and local CLI proof below belongs to83481a69band is carried only with this verified owning-source-equivalence qualification—not as a new-head native run or whole-tree equivalence claim.83481a69be406c909dede1876e830336c8591a57passed a fresh signed native default-argument test against a synthetic NSTextView receiver: selection changed from{location: 80, length: 0}to{location: 0, length: 80}, with zero application/receiver keyboard events. The CLI exited 0 with one background AX-value unit anddispatched_unverified. Pre/post AX-focus and global-owner checks were unchanged; the complete 30-second observer recorded zero activations, and owned fixture cleanup passed. This is bounded default-path proof, not a native focus-drift reproduction or a claim of strategy, hold, or full keyboard parity.PressCommandTestsfilter, with broad automation disabled and both suite-success and positive-count guards. The refreshed integration also passes 17 source-audited lane-coordinator tests using private temporary lock roots, all 38 inert wiring/adjacent Node contracts, strict style checks, docs lint, diff checks, and scoped P0 full-candidate integration autoreview.The local CLI results establish mocked-input/receipt behavior, not full host-state isolation: the shared in-process runtime can still update host coordination state. That suite was not rerun locally for this integration. Hosted CI runs it on ephemeral runners.
The workflow change also triggers the repository's exact-head supplemental Core, library/app, dependency, and full-safe validation lanes. Standard macOS CI, CodeQL, and all supplemental lanes passed on
8bc916fe3; that is prior-head evidence. Fresh exact-head CI is required for7384de2d7and will be checked before landing.Documentation
Updated
pressimplementation notes with the truthful receipt, retained-receiver validation, and explicit remaining strategy/hold limitation. Added the bounded receipt, failure-normalization, and receiver-binding fixes toUnreleased.