Skip to content

fix: make the permission guide offer the launching app, see each grant, and leave no stale host - #330

Merged
lahfir merged 5 commits into
mainfrom
docs/workflows-permission-guide
Oct 30, 2026
Merged

lahfir merged 5 commits into
mainfrom
docs/workflows-permission-guide

Conversation

@lahfir

@lahfir lahfir commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why

On a Mac where the terminal is Rex, agent-desktop permissions --guide showed the agent-desktop binary in its panel, not Rex Server. After the user dragged it and confirmed, the panel stayed on "Allow Accessibility" and permissions still reported denied. Also, the JSON hints and the shared workflow skill told users to run --request, which shows the macOS prompt and does not add an app to either list. On macOS 27 the Accessibility list has the new name "Device Control and Data Access".

Causes and fixes

  1. Wrong app in the panel. The parent walk used NSRunningApplication, which knows only apps registered with LaunchServices. Rex Server is not registered, so the walk fell back to the binary. TCC charges the grant to Rex Server, so the binary drop changed nothing. The walk is now in Rust (permission_guide.rs). It reads each ancestor's executable path and takes the outermost .app, which is also the app that TCC names for a helper such as Code Helper (Plugin).app.
  2. The walk stopped at /usr/bin/login. proc_pidinfo(PROC_PIDTBSDINFO) refuses a root-owned process. The walk uses PROC_PIDT_SHORTBSDINFO, which has no same-user check. The dogfood found this before the user saw it.
  3. The grant poll asked the shared command host. Each poll ran agent-desktop permissions, which goes to the command host, and the poll every second kept that host alive. The poll now runs a fresh process with AGENT_DESKTOP_PERMISSION_GUIDE_PROBE. That process exits before CLI parsing and does not use the host.
  4. A stale host after the grant. A process keeps the Accessibility answer from its first trust check. A host that checked while access was denied kept returning PERM_DENIED after the grant. In the dogfood, a snapshot through that host failed, but a fresh process on the same Rex Server succeeded. Now a host exits after any reply that reports a missing permission (src/command_host/mod.rs, command_host_socket.rs), so the next call starts a host that sees the grant.
  5. Hints and skills. The Accessibility and Screen Recording suggestion text, the screenshot PERM_DENIED hint, and the shared workflow skill now name permissions --guide. The core PERM_DENIED hint was a macOS settings path, but Windows also returns it on E_ACCESSDENIED. It now points at agent-desktop permissions and names --guide only as the macOS path. The macOS skill no longer says to restart the launching app (see the measurements), and its confirm step uses snapshot -i. snapshot --app Finder -i returns WINDOW_NOT_FOUND when Finder has no window.
  6. Panel. The title uses the macOS 27 name when isOperatingSystemAtLeastVersion:{27,0,0} is true (the release binary is built with SDK 26.5, so macOS reports its real version). The title wraps. A gray line tells the user why each permission is necessary. The granted tick pops in with a spring and draws on with NSSymbolDrawOnEffect on macOS 26. The aurora is fainter (opacity 0.55) and lower (96 pt). The done screen no longer tells the user to reopen the terminal.

Dogfood on macOS 26.0, from Rex, with the release build

  • Round 1, starting with a command host already running in the denied state. The panel showed Rex Server. "Not Now" closed it in one click. After the drop, a fresh probe saw Accessibility, then Screen Recording, and the guide exited by itself. The old host still reported Accessibility denied, and a snapshot through it returned PERM_DENIED. That is fix 4.
  • After the grant, with no restart of Rex Server (same PID since Oct 28): snapshot -i returned 18 refs with complete: true. A screenshot showed real window content.
  • Round 2, after tccutil reset of both grants: the why line was correct, and the tick drew itself in. Both grants landed and the guide closed. permissions then reported both permissions as granted. A host started by version before the grant did no trust check, and it saw the grant.

Not driven on this Mac: the macOS 27 title, and the Privacy_Accessibility anchor in System Settings on macOS 27. Those rest on the user's report from a macOS 27 Mac.

Accepted limits

  • A host that reads Accessibility trust while access is denied, and does not reply with a denial, keeps that answer. After a grant, its first Accessibility command returns PERM_DENIED once, then the host exits and the retry succeeds. "First contact" starts with permissions, which stops such a host before the grant.
  • After a revoke, a host that checked trust while it was granted still reports granted. Its first Accessibility command fails with PERM_DENIED, and then it exits.
  • Under a tmux server or an SSH session, no ancestor runs from an app bundle, so the guide offers the binary. The troubleshooting skill says so.
  • Owned elsewhere: the command host takes the TCC identity of the app that first started it, so one host can serve calls from many terminal apps. This is recorded in the local roadmap for the daemon work.

Tests

  • the_guide_offers_the_outermost_app_bundle_of_the_launching_process: this test fails when the innermost bundle is taken.
  • the_host_walk_passes_through_a_process_of_another_user: this test fails with PROC_PIDTBSDINFO.
  • a_host_stops_after_it_reports_a_missing_permission: this test fails when the rule returns false.
  • the_host_returns_after_a_reply_that_asks_it_to_stop: this test times out when the stop check is removed.
  • fmt, clippy -D warnings, the source-rule and architecture scripts, and every host test target pass on macOS.
  • The earlier Test (Windows) failure was input::clipboard::tests::hung_delay_owner_returns_app_unresponsive, a clipboard timing test that this change does not touch.

The shared workflow reference told agents to run permissions --request, which shows the macOS prompt and does not add a new app to the Accessibility list. The macOS skill already names --guide, which opens System Settings with the drag guide.
A denied Accessibility or Screen Recording permission told the user to open System Settings by hand, so users ran permissions --request and got the macOS prompt, which does not add a new app to either list. The hints now name permissions --guide, which opens the right list with the drag guide.

The core PERM_DENIED hint named a macOS settings path, and Windows returns it on E_ACCESSDENIED. It now points at agent-desktop permissions, which gives each platform's own hint, and names --guide only as the macOS path. Automation keeps its hint because the guide does not cover it.
…rant

The guide looked up each parent process with NSRunningApplication, which knows only apps registered with LaunchServices. Rex Server is not, so the walk reached launchd and the panel offered the agent-desktop binary. TCC charges the grant to Rex Server, so a drop of the binary never turned the permission on. The walk now reads each ancestor's executable path and takes its outermost app bundle, which is also the app TCC names for a helper inside an app.

Each grant poll ran agent-desktop permissions, which goes to the shared command host. That host can belong to another terminal app, it keeps the Screen Recording answer it read at launch, and the poll every second kept it alive. The poll now runs a fresh process that reads the two preflight checks and exits before the CLI and the host.

macOS 27 names the Accessibility list Device Control and Data Access, so the panel title, the hint and the macOS skill now use that name there. The title wraps. The aurora is fainter and lower.
A terminal starts the shell through /usr/bin/login, which root owns. The full BSD record from proc_pidinfo is refused for a process of another user, so the walk stopped at login and never reached the terminal app. The short BSD record has no such check.
A process keeps the Accessibility answer it read before a grant. The command host lives up to 15 minutes, so after the user granted Accessibility, every forwarded command still returned PERM_DENIED and permissions still reported denied. A snapshot through such a host failed while a fresh process on the same Rex Server succeeded. The host now exits after any reply that reports a missing permission, so the next call starts a host that sees the grant.

Measured on macOS 26.0: after the grant, a fresh process snapshots and screenshots without a restart of the launching app, so the skill no longer asks for one and the guide's done screen no longer asks to reopen it. The guide also says in one line why each permission is needed, and the granted tick pops in, and draws on where macOS 26 supports it.
@lahfir lahfir changed the title fix: name permissions --guide in the macOS permission hints fix: make the permission guide offer the launching app, see each grant, and leave no stale host Oct 30, 2026
@lahfir
lahfir merged commit e378cf1 into main Oct 30, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Issues and PR Oct 30, 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.

1 participant