fix: background input, bridge error surfacing, exact-app targeting, and system permission dialogs #743
<!-- clawsweeper-pr-ack:opened item=743 -->
🦞👀
ClawSweeper picked this up.
Pull request received. I will update this pull request when review starts.
<!-- clawsweeper-review-progress:start -->
ClawSweeper review complete
ClawSweeper finished reviewing this revision. The review result is being finalized.
View the workflow run.
<!-- clawsweeper-review-progress:end -->
PR Summary
<!-- CURSOR_SUMMARY -->
Medium Risk
Changes touch mutation targeting, AX dialog discovery/AXPress, and exact-window input validation—areas where wrong acceptance could click the wrong alert or send keystrokes to the wrong receiver, though discovery remains heavily bounded and fail-closed.
Overview
Adds background system-alert dialog discovery so targetless dialog list / dialog click --button can find and act on allowlisted macOS permission hosts (UserNotificationCenter, SecurityAgent) via bounded AX scanning, attested discovery proofs on prepared receipts, and fail-closed rules (no --foreground, unique dialog + one enabled AXPress button). CLI list output and JSON gain owner/subrole/button detail; remote hosts expose systemAlertDiscovery through resolved dialog capabilities.
Exact app targeting no longer fails solely on a partial mutation inventory when an unrelated generationless process was omitted: planners can fall back to an authoritative direct lookup with selector census proofs, while ambiguity and stale-generation checks stay strict.
Exact-window keyboard delivery is relaxed where UI legitimately moves: typing uses initial vs continuation focus validation (frame reflow OK, receiver/window change still stops delivery); delivered hotkeys/special keys skip post-delivery focus re-checks that used to fail after chords like cmd+n; focus reader disambiguation and large-tree limits are tightened accordingly.
<sup>Reviewed by Cursor Bugbot for commit f112f68399604de073fbad2c17b3bd990888e733. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
<!-- /CURSOR_SUMMARY -->
System-alert host path check is off-by-one
High Severity
<!-- DESCRIPTION START -->DialogSystemAlertHosts.contains compares bundlePath to two parents of the executable, which is the Contents directory. Production bundlePath comes from NSRunningApplication.bundleURL and is the .app or .bundle wrapper, so the allowlist never matches live UserNotificationCenter or SecurityAgent processes. Unfocused TCC and Security Agent alerts are then skipped; only a focused owner can still be discovered.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 6113430a-78ef-4c0e-a61b-ab13eb6d1d82 -->
<!-- LOCATIONS START
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/Core/Protocols/DialogDiscoveryModels.swift#L12-L20
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjI0ODIwN2NhLWVhODUtNDg1MC04ZWNmLWE4NmYwZDNkMjcwMSIsImVuY3J5cHRpb25LZXkiOiJieVBzcURmQWd6TmZpZ1RqMHNHMGtfY1FQWTZoaVktS2loTGhFOFdxVDJjIiwiYnJhbmNoIjoic3RlaXBldGUvam9sbHktYm9vdGgtZTU0YTU1IiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjI0ODIwN2NhLWVhODUtNDg1MC04ZWNmLWE4NmYwZDNkMjcwMSIsImVuY3J5cHRpb25LZXkiOiJieVBzcURmQWd6TmZpZ1RqMHNHMGtfY1FQWTZoaVktS2loTGhFOFdxVDJjIiwiYnJhbmNoIjoic3RlaXBldGUvam9sbHktYm9vdGgtZTU0YTU1IiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJOdW1iZXIiOjc0MywiY29tbWl0U2hhIjoiYzE0OTJmZTUyYzNkNWFhOTBkMzY2ZWQ0OTQ0ZjZhZGI2Y2NmNTgyMCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 c1492fe52c3d5aa90d366ed4944f6adb6ccf5820. Configure here.</sup>
Incomplete focus scan now always fails
Medium Severity
<!-- DESCRIPTION START -->DetachedExactWindowFocusReader.read now returns .multipleFocusedElements whenever the 4096-node walk leaves items in the queue. That applies to the initial receipt as well as continuation. A unique focused match that used to succeed in a large window now fails, so exact-window type and press can refuse in apps whose AX tree is simply large.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: f04b28f8-50e0-4547-831e-dbc9de64fec0 -->
<!-- LOCATIONS START
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/DetachedExactWindowFocusReader.swift#L121-L148
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmE3YjJmMDAxLTRmMWYtNGQyNS1hZTMwLTE4ZmFlYTQ2YThjNCIsImVuY3J5cHRpb25LZXkiOiJlVXh3ZHNDZ1VWMk9QS1RjTHBtbW1FNWV2WDlMV0Z3Q3ItUzBhaVYyTEpJIiwiYnJhbmNoIjoic3RlaXBldGUvam9sbHktYm9vdGgtZTU0YTU1IiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmE3YjJmMDAxLTRmMWYtNGQyNS1hZTMwLTE4ZmFlYTQ2YThjNCIsImVuY3J5cHRpb25LZXkiOiJlVXh3ZHNDZ1VWMk9QS1RjTHBtbW1FNWV2WDlMV0Z3Q3ItUzBhaVYyTEpJIiwiYnJhbmNoIjoic3RlaXBldGUvam9sbHktYm9vdGgtZTU0YTU1IiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJOdW1iZXIiOjc0MywiY29tbWl0U2hhIjoiYzE0OTJmZTUyYzNkNWFhOTBkMzY2ZWQ0OTQ0ZjZhZGI2Y2NmNTgyMCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 c1492fe52c3d5aa90d366ed4944f6adb6ccf5820. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTowNzIzZWJhNy1mODgxLTRmY2QtYTI5Zi1lYmFkMTI0YmQxMTQiLCJlbmNyeXB0aW9uS2V5IjoiTUdLam5wenRmemV3NnZXVTdZQjM4ZUtwT3Jia1N1WlpvbGs1ZnJzcExnUSIsImJyYW5jaCI6InN0ZWlwZXRlL2pvbGx5LWJvb3RoLWU1NGE1NSIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 -->
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
<sup>Reviewed by Cursor Bugbot for commit c1492fe52c3d5aa90d366ed4944f6adb6ccf5820. Configure here.</sup>
Fixed in 7d01ae05. The allowlist now derives the .app/.bundle wrapper (three components up from the executable, matching NSRunningApplication.bundleURL) instead of stopping at Contents, so unfocused UserNotificationCenter / SecurityAgent alerts are discovered — not only a focused owner. The test fixture shared the same wrong depth, which is why it passed; corrected it too, and DialogDiscoveryTests now validates the real path structure.
_🤖 Addressed by Claude Code_
Fixed in 7d01ae05. Removed the guard queue.isEmpty check that failed the scan with .multipleFocusedElements whenever the 4096-node walk was truncated; the existing exactMatches.count == 1 guard already proves uniqueness among the scanned nodes, so a unique focused match in a large AX tree resolves again and exact-window type / press no longer refuse in deep-hierarchy apps.
_🤖 Addressed by Claude Code_
Codex review: blocked before merge. _Reviewed September 16, 2026, 3:05 AM ET / 07:05 UTC (Revision 3)._
ClawSweeper review
What this changes
Repairs background keyboard delivery, exact application selection, and bridge error reporting, and adds discovery and clicking of macOS permission dialogs.
Regression provenance
Possible regression — suspected (reviewed change). No predecessor PR is attributed.
Merge readiness
⛔ Blocked before merge - 3 items remain
The PR contains useful work absent from main, but the previously reported receiver-continuity defect remains unchanged at the pinned head. The collaborator-authored PR is not eligible for cleanup closure.
Priority: P2
Reviewed head: f112f68399604de073fbad2c17b3bd990888e733
Review scores
| Measure | Result | What it means |
|---|---|---|
| Overall readiness | 🦐 gold shrimp (3/6) | Useful implementation and substantial regression coverage remain limited by the unchanged input-routing blocker. |
| Proof confidence | 🌊 off-meta tidepool | Not applicable: The collaborator exemption applies. The body reports real Messages hotkey success and TextEdit permission-dialog discovery and denial through the host; these observations do not resolve the separate sibling-focus defect. |
| Patch quality | 🦐 gold shrimp (3/6) | 1 actionable review finding remain. |
Verification
| Check | Result | Evidence |
|---|---|---|
| Real behavior | Not applicable | Not applicable: The collaborator exemption applies. The body reports real Messages hotkey success and TextEdit permission-dialog discovery and denial through the host; these observations do not resolve the separate sibling-focus defect. |
| Evidence reviewed | 7 items | Previous blocker remains unchanged: The latest commit changes only two CLI test expectations: eight additions and two deletions. The focus-selection and typing implementation remains identical to the previously reviewed head.<br>Focused sibling can replace the captured receiver: When multiple controls match the captured identity and no unique captured-frame match remains, selection falls back to whichever candidate is focused. Continuation validation accepts a matching title without requiring the original frame, so a same-label sibling can pass and receive subsequent characters.<br>Dispatch path makes the selection consequential: TypeService selects the continuation validator after any emitted input, then dispatches the next character. UIAutomationService checks process, window, bounds, and the relaxed identity comparison; those checks do not distinguish same-label siblings in the same window. |
| Findings | 1 actionable finding | [P1] [P1] Reject sibling focus as proof of receiver continuity |
| Security | None | None. |
How this fits together
Peekaboo routes CLI automation requests through local services or a macOS Bridge host. Application, window, and control receipts constrain where keyboard input and dialog actions may be delivered.
flowchart TD
A[CLI automation request] --> B[Local service or Bridge host]
B --> C[Application and dialog discovery]
C --> D[Exact target receipt]
D --> E[Revalidate receiver or dialog]
E --> F[Keyboard input or dialog click]
F --> G[Outcome and signed receipt]
Before merge
AXTextField controls share a title and lack identifiers, the original receiver can reflow after the first character while focus moves to its sibling. With neither candidate at the captured frame, this fallback selects the focused sibling. The later process, window, and title checks accept it, so remaining text reaches the wrong control. Retain verified receiver identity or refuse multiple identity matches when frame disambiguation is lost, and cover reflow combined with sibling focus transfer.Findings
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/DetachedExactWindowFocusReader.swift:221-222<details>
<summary><strong>Agent review details</strong></summary>
Security
None.
Review metrics
| Metric | Value | Why it matters |
|---|---|---|
| Production and test growth | Production +929 net lines; tests +1630 net lines; docs +19 net lines | The stated scope explains the growth across discovery, targeting, input validation, and bridge diagnostics. |
| Changes since previous review | 2 test files changed; 0 production files changed | The previous production-code blocker remains applicable. |
Merge-risk options
Maintainer options:
1. Preserve receiver continuity (recommended)
Remove focus-only disambiguation when captured identity is ambiguous and cover both unchanged duplicate-label controls and reflow followed by sibling focus transfer.
<details>
<summary>Copy recommended automerge instruction</summary>
@clawsweeper automerge
Special instructions:
Repair continuation receiver selection without changing initial receipt validation: preserve unique captured-frame selection, refuse ambiguous identity matches when frame disambiguation is lost, and add regression coverage proving that a same-label sibling receives no remaining characters after reflow.
</details>
Technical review
Best possible solution:
Allow reflow only while receiver identity remains unambiguous, preserving unchanged-frame disambiguation and refusing ambiguous continuation before further input.
Do we have a high-confidence way to reproduce the issue?
Yes, from source: reflow the original field after the first character and move focus to a same-label sibling with no identifier; the PR's fallback selects that sibling. This read-only review did not execute a native reproduction.
Is this the best way to solve the issue?
No, not fully: reusing exact receipts and the authoritative application census is appropriate, but current focus cannot establish continuity between otherwise indistinguishable controls.
Full review comments:
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/DetachedExactWindowFocusReader.swift:221-222This previous finding remains unchanged. If two
AXTextField controls share a title and lack identifiers, the original receiver can reflow after the first character while focus moves to its sibling. With neither candidate at the captured frame, this fallback selects the focused sibling. The later process, window, and title checks accept it, so remaining text reaches the wrong control. Retain verified receiver identity or refuse multiple identity matches when frame disambiguation is lost, and cover reflow combined with sibling focus transfer.Confidence: 0.99
Overall correctness: patch is incorrect
Overall confidence: 0.98
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning medium; reviewed against 4d3c92eaf6e0.
Labels
Label justifications:
P2: This is a bounded desktop-automation improvement with a merge-blocking input-selection defect, without evidence of an urgent shipped outage.merge-risk: 🚨 compatibility: Relaxed continuation selection can redirect existing exact-window typing workflows into a same-label sibling.rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The collaborator exemption applies. The body reports real Messages hotkey success and TextEdit permission-dialog discovery and denial through the host; these observations do not resolve the separate sibling-focus defect.Evidence
Acceptance criteria:
What I checked:
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/DetachedExactWindowFocusReader.swift:221, f112f6839960)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/TypeService.swift:567, f112f6839960)docs/commands/dialog.md:18, d82dbd888326)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/DialogService+PreparedActions.swift:528, f112f6839960)Likely related people:
Rank-up moves
Optional improvements that raise the rating; they are not merge blockers.
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 (2 earlier review cycles)</summary>
<!-- clawsweeper-review-history v=1 total=2 -->
</details>
</details>
<!-- clawsweeper-verdict:needs-human item=743 sha=f112f68399604de073fbad2c17b3bd990888e733 confidence=high updated_at=2026-09-16T07:03:12Z reviewed_at=2026-09-16T07:05:39.385Z lease_owner=github-run-35066529331-1 lease_comment_id=5693404305 source_revision=9655e129003ef2e86b0acd5f126f99e4cd3f3565125d9c5b7882174ebab2b6fb live_verification=absent -->
<!-- clawsweeper-review-state:blocked item=743 sha=f112f68399604de073fbad2c17b3bd990888e733 v=1 -->
<!-- clawsweeper-review-version item=743 reviewed_at=2026-09-16T07:05:39.385Z sha=f112f68399604de073fbad2c17b3bd990888e733 source_revision=9655e129003ef2e86b0acd5f126f99e4cd3f3565125d9c5b7882174ebab2b6fb lease_owner=github-run-35066529331-1 lease_comment_id=5693404305 v=1 -->
<!-- clawsweeper-review item=743 -->
steipete
Five fixes surfaced while driving Messages.app in the background over SSH (macOS 27, Peekaboo host + build-scoped daemon). Each was reproduced against a running host before the fix and re-verified on real hardware afterward.
Fixes
Bridge response was lost … the required receipt envelopeand hiding the real cause. The client now surfaces the host's actual code/message/details plus host-vs-client build strings (with a skew warning), and the server returns a signed receipt carrying the real failure for mutating operations.AppSSODaemon) made the mutation inventory partial and blocked resolving an unambiguous--apptarget fortype/paste/menu. Resolution now falls back to an authoritative selector census when the inventory is partial, preserving ambiguity refusal, expected-generation checks, and PID revalidation. The omission warning now names the skipped process.cmd+n, which opens a window) failed a post-delivery focus re-check even though the keystroke landed. Delivered chords/trailing keys no longer require unchanged focus afterward, and multi-character typing tolerates a same-element frame reflow while still stopping on a genuine receiver change (focus moving to a popup/other window).UserNotificationCenterare invisible to the standard window enumeration.dialog list/dialog click --buttonnow discover allowlisted system-alert hosts (com.apple.UserNotificationCenter,com.apple.SecurityAgent) with bounded, read-only AX traversal and dismiss them via the existing exact-receipt AXPress path (fail-closed on incomplete or ambiguous discovery).systemAlertDiscoveryflag, so a no-targetdialog clickrefused even when the host advertised the capability. Carried the flag through and covered the propagation.A sixth reported issue — a
seesnapshot lost between observation and mutation across daemon/GUI hosts — is already fixed onmainby producer-bound snapshot references and the host-affinity resolver, so no code change is included for it.Verification
Targeted unit/integration suites for all five areas pass (bridge transport/attested-failure, application mutation planner, exact-window focus + hotkey + type continuation, and dialog discovery), format/lint are clean, and Codex autoreview returned scoped-clean. On a real macOS host:
press cmd+n --app Messages --window-id …now succeeds (was "response was lost");dialog listdiscovers a live TextEdit TCC prompt thatwindow list --app UserNotificationCentermisses, anddialog click --button "Don't Allow"dismisses it (the requester received a denial), which is how the capability-propagation bug above was caught.