Repository navigation
feat(preview): follow the agent's desktop window and cursor - #1284
Merged
Merged
Conversation
nixuuu
enabled auto-merge (squash)
November 25, 2026 21:08
This was referenced Nov 26, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 29, 2026
## Problem During Desktop automation macOS kept showing "Canopy is requesting to bypass the system private window picker…" although the user had allowed it many times. The `replayd` approval for `app.canopy.desktop` stayed in place (`kScreenCaptureApprovalLastAlerted` unchanged for weeks), so the answers were never stored. The `replayd` log shows why. macOS checks consent after each frame by resolving the capturing process. Every alert came right after the window preview's capture helper disconnected: ``` client disconnected, successfully stopped active session approveOnStreamStart… [ERROR] requireAlertWithCanonicalBundleID… Error resolving binary path and audit token userAcknowledgementAlertWithBundleID → showAlert ``` The preview killed the helper with `SIGKILL` right after a frame when the target changed or the preview stopped (`desktop-follow-preview.ts`). `replayd` could no longer resolve the process, so it showed the alert and had nothing to store the answer for. ## Fix - Stopping the capture ends the helper's stdin instead of killing it. The helper finishes the outstanding frame and exits one second after its last one. `SIGKILL` stays as a fallback after 4 s (the helper bounds one capture at 2.5 s). - `next()` returns as soon as the capture stops and no longer waits for an outstanding frame. The failure path in the follow preview no longer waits for the helper to exit before falling back to Agent Desktop screenshots; the preview's `close()` still awaits it. - `docs/automation-tools.md` describes the behaviour. Fixes: #1284 ## Verification - Locally: worker typecheck, oxlint and oxfmt on the changed files, `bun run check:tmp ./apps/worker/src/agent-preview/desktop-follow.test.ts` (6 pass). - A Bun simulation of the parent/helper protocol confirmed the outstanding frame is still delivered after stdin ends and the helper exits about 1 s after it. - **Not verified on macOS**: this worker runs Linux. To confirm on a nightly build, keep `log stream --info --predicate 'process == "replayd"'` running while the agent switches windows. `Error resolving binary path and audit token` and the alert should no longer appear. - No new test: the path needs ScreenCaptureKit and `replayd`, and the existing follow tests cover the preview wiring on Linux. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Desktop Mini follows the window where the agent is working, even when the user has another application in front. A Desktop tool that returns a screenshot supplies the image for Mini directly. PNG and JPEG images up to 2 MiB keep their original bytes, and larger supported images are resized from the same response. For accessibility actions, Mini shows the live window and the result of the action. Moving on to shell work or ending the turn dismisses the old view. Overlapping GUI calls keep their own lifetimes.
The worker verifies the window ID, PID and process instance before publishing live pixels. On supported Macs it captures a covered window with ScreenCaptureKit. Capture is paced by client frame acknowledgements, up to 12 fps. The read-only Mini and manually selected interactive Preview keep separate subscriptions. Additive protocol fields carry verified frames, model screenshots and ephemeral call completions.
A thread can enable an animated blue cursor for its verified Desktop actions. On macOS the marker is clipped to the visible part of its target window. Web, desktop and mobile Preview draw it over the corresponding image and respect reduced motion. Background input still uses the accessibility actions exposed by the target application. The existing physical-input setting governs operations that move the shared pointer.
Verification
Copy audit
Passed the ten checks in
docs/copy.md§8. The generic “Waiting for image…” becomes “Waiting for the agent’s view…” while Desktop resolves its source. “Last view” labels a completed screenshot. Narrow layouts truncate the window title while keeping the preview controls accessible.