Skip to content

feat(automation): add agent tools and live thread previews - #846

Merged
nixuuu merged 5 commits into
devfrom
feat/integrate-agent-tools
Nov 15, 2026
Merged

nixuuu merged 5 commits into
devfrom
feat/integrate-agent-tools

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 15, 2026

Copy link
Copy Markdown
Member

Change

Agents can use local browser, desktop and device automation through worker-scoped grants. When an authorized tool call starts, the thread automatically shows a passive live preview below Thread details. Users can minimize it or open the same session in a resizable Files/Preview sidebar for direct mouse and keyboard input.

  • Add pinned tool discovery, managed installation, readiness checks and a shared MCP bridge for Claude, Codex and Grok. The gateway checks ownership, active turns, grants and approvals for every call, including linked computers.
  • Add browser streaming, desktop/device target catalogs, browser navigation, direct input and fullscreen. Preview traffic stays ephemeral, with bounded frames and queues, ACK pacing, cancellation and connection fencing.
  • Preserve the mini preview across same-worker status updates and deliver the latest bounded frame to viewers joining an active preview. Update architecture, protocol, worker, adapter and workspace documentation.

Verification

  • Regenerated additive protobuf contracts with bun run gen after merging current dev.
  • Gateway, worker and integration package typechecks passed after the merge. Web typecheck passed with 0 errors and 0 warnings.
  • Post-merge check:tmp: 36 tests, 694 assertions across automation grants/security, preview streaming, live activity, linked routing and image publication; no temporary-file leftovers.
  • Focused worker adapters, MCP bridge, native harness and preview lifecycle checks passed. The final frame-retention regression set passed 17 tests.
  • Built and launched the full Linux Electron application with its own PostgreSQL, gateway and worker. A real native agent edited a local page through browser MCP; automatic mini preview, minimize and sidebar handoff worked. Native mouse input, Ctrl+A and text entry through the sidebar reached the page. A second viewer received a static page frame without another page interaction.
  • Inspected light/dark desktop/phone layouts and long labels. Full repository checks and remaining platform builds are left to CI.

Copy audit (§8): 10/10 pass. Manual form controls → compact Preview chrome and direct canvas interaction. Actions use imperative labels (Minimize preview, Restore preview, Open in sidebar); errors and empty states provide one next action. Glossary, capitalization and length limits match; facts are not repeated, optional gaps stay quiet, required dependencies have actions, and no decorative “soul” copy was added. Long names remain usable at desktop/phone widths, with text and accessible labels conveying state independently of colour or icons.

Native desktop and mobile-device OS interaction could not be exercised on this Linux setup. iOS editing keys require the on-screen keyboard. Automatic previews follow the default thread session; explicit foreign sessions or ambiguous browser overrides suppress the automatic signal.

Add per-worker detection, pinned opt-in installs and runtime checks for agent-browser, agent-desktop and agent-device. Provide gateway-authorized MCP access for Claude, Codex and Grok, plus manual controls and screenshot previews in worker settings.

Validate owner grants, active-turn authorization, cancellation and linked computer routing with integration tests. Verify pinned CLIs and a real browser screenshot; inspect web UI in light/dark at desktop and phone widths. Full repository validation remains with CI.
Move browser, desktop and device control into the thread Files/Preview sidebar. Stream browser frames and forward direct pointer and keyboard input through owner-scoped transient worker sessions, with bounded screenshot previews for desktop and devices.

Validated focused worker and gateway integration tests, affected package types, edited-file lint and formatting, and real browser interaction in light/dark desktop/phone layouts. Copy audit: all ten items pass. Full CI remains pending.
Show a passive live preview after approved automation calls, with minimize and sidebar handoff. Keep activity transient and preserve browser navigation during preview startup.
@nixuuu
nixuuu enabled auto-merge (squash) November 15, 2026 18:54
@nixuuu
nixuuu merged commit 3e76f39 into dev Nov 15, 2026
11 checks passed
@nixuuu
nixuuu deleted the feat/integrate-agent-tools branch November 15, 2026 19:06
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

Browser tools could run in a model-selected session such as `demo`,
leaving Preview attached to an empty thread session. A local `headed:
true` configuration could also open a visible window or restart Chrome
while Preview measured the viewport.

Pin Browser MCP calls to the thread session and enforce headless mode in
MCP, Preview commands, and explicit browser navigation. Reject session,
namespace, and headed overrides before authorization. Preserve automatic
preview activity for the injected headless arguments. Tool descriptions
and errors explain the single-session boundary, shared login state
across tabs, and the instruction to explain limitations instead of
bypassing them. Update automation documentation.

## Verification

- Selective `check:tmp` runs passed for browser adapters, Preview
streaming/input, MCP bridge and browser policy, and automation activity
over WorkerLink/UI gRPC, including linked-computer routing. Relevant
reruns passed after subsequent changes.
- Worker typecheck, scoped lint/format checks, and diff checks passed.
- Real agent-browser 0.43.0 with `headed: true` configuration: Open and
New Tab stayed headless. Starting BrowserPreview before MCP navigation
produced a JPEG frame at 1280 × 633 with the correct thread-session URL.
- Full repository verification and builds are left to CI. No frontend UI
changes; copy audit §8 is not applicable to UI text (changed
descriptions/errors are model-facing MCP instructions).

Fixes: #846
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

`[email protected]` reports `screen_recording: unknown` on Linux
because Screen Recording is a macOS TCC permission. The worker
incorrectly treated that state as a readiness failure, so installation
ended with “Grant Screen Recording permission for desktop screenshots”.

Desktop preflight now enforces Screen Recording only on macOS. Linux and
Windows can report `unknown`; Accessibility and the platform check
remain required. Documentation and platform-specific readiness tests are
included.

The Claude live permission integration test now waits for the gateway to
persist the target turn as `running` before sending the live permission
update. This removes a CI-only race between the fixture trace and
WorkerLink ingestion.

Fixes: #846

## Verification

- `bun run check:tmp apps/worker/src/agent-tools/adapters.test.ts` — 18
tests passed
- `bun run check:tmp tests/integration/claude-live-permissions.test.ts`
— 3 tests passed
- `bun run lint -- apps/worker/src/agent-tools/preflight.ts
apps/worker/src/agent-tools/fixtures.test-support.ts
apps/worker/src/agent-tools/adapters.test.ts`
- `bun run lint -- tests/integration/claude-live-permissions.test.ts`
- `bun run --filter @canopy/worker typecheck`
- `bun run format -- apps/worker/src/agent-tools/preflight.ts
apps/worker/src/agent-tools/fixtures.test-support.ts
apps/worker/src/agent-tools/adapters.test.ts
tests/integration/claude-live-permissions.test.ts`
- `git diff --check`
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

Returning to a thread restores its mini preview and minimization state.
Each thread also remembers whether its side panel is open, whether Files
or Preview is selected, and which preview tool is active. Panel metadata
survives reloads in local workspace storage; preview targets remain in
scoped session memory and frames are discarded when a watch closes.

The mini preview uses one fixed icon button for minimize/restore, with
accessible labels, tooltips and keyboard focus preserved. Viewport
width, height and Apply remain visible in narrow panels: the toolbar
wraps and these numeric fields omit the +/− buttons. Other numeric
controls retain their existing steppers.

Documented the implemented behavior and its persistence boundaries in
the workspace and automation docs.

## Verification

- Passed web typecheck with zero errors or warnings, lint on edited
source files, formatting and diff whitespace checks.
- Checked real components in a browser with a temporary fixture and
simulated preview streams: separate A/B/C panel states, reload
persistence, mini preview restore/minimization, stream cleanup and
sidebar handoff. Confirmed no transient mini watch starts for the wrong
thread.
- Checked light/dark themes, desktop and a 390 px phone viewport.
Viewport fields and Apply remain visible at panel widths 320, 390, 468,
520 and 1100 px. Verified resize submission, keyboard increments,
empty-field validation and disabled controls.
- Copy audit (§8): passed. Existing labels are retained as
tooltips/accessibility names; short, typical and long titles were
checked at desktop and phone widths. Icon-only restore replaces the
inconsistent text button without losing its accessible action name.
- Passed integration-tests package typecheck and all four device-view
persistence tests through `check:tmp`, with no temporary files left
behind.
- Remaining repository checks, integration tests and builds run in CI.
No web UI test suite or verification artifacts were added.

Fixes: #846
Fixes: #872
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

Automation could open its own session while thread Preview watched the
thread-derived session, leaving the preview disconnected. Desktop
batches could override the startup session, and global lifecycle
operations could affect other threads.

Use one worker-owned thread scope for browser, desktop and device MCP
calls and catalogs, checked before gateway authorization. Preserve each
tool's supported argument grammar:

- Keep Browser headless and reject global `close all` as well as session
and namespace overrides.
- Bind Desktop batch sessions and session-end IDs. Hide and reject
session creation, global session GC and sandbox execution outside the
host Preview.
- Bind Device calls and batch steps. Hide and reject the `test` runner,
which creates per-attempt sessions; scripts can use `replay` in the
thread session.
- Let default Desktop/Device previews follow the current focused window
or thread-session device while explicit selections stay pinned. Resolve
the `apple` alias against iOS/macOS catalog entries.

Update automation documentation and add adapter and MCP bridge
regression coverage.

Fixes: #846

## Verification

- 60 targeted local tests passed across MCP policies/bridge, tool and
Preview adapters, and real gateway↔worker Preview/activity integration,
with temporary-file cleanup.
- After rebasing onto current `dev`, reran the affected tool/Preview
adapter tests, worker typecheck and scoped lint.
- Edited TypeScript files formatted with oxfmt; diff checks passed.
- Installed Browser 0.43.0, Desktop 1.3.1 and Device 0.21.37 passed
actual MCP catalog checks and read-only calls, including Desktop batch
execution. Native desktop/device UI interaction was not exercised.
- Full generation checks, repository-wide static checks, test shards and
builds remain with CI.

Copy audit (§8): not applicable; no UI copy changed. New guidance and
errors belong to the model-facing MCP interface.
nixuuu added a commit that referenced this pull request Nov 17, 2026
## Change

Returning to an active thread can replay buffered Preview frames while
its conversation catches up, and refreshing target metadata can briefly
replace the image with Connecting. Keep subscriptions stable by
comparing the actual target scope, retain the previous image until the
next frame is decoded and drawn, and preserve automatic Preview when
repairing a history checkpoint.

Web/desktop now acknowledges each frame after drawing it, so the
existing worker pacing also bounds the path through BFF and the browser.
Discarding an obsolete Desktop/Device target frame releases the
replacement image. The additive RPC validates the owner, active grant,
original worker link and delivered frame, including linked-computer
routing. Existing clients retain stream-consumption acknowledgements;
the new mode requires support on the linked home and does not change
WorkerLink.

Update the automation, protocol and UI API documentation.

## Verification

- Passed 8 new integration tests for frame acknowledgements, heartbeat
pacing, cancellation, validation, owner/grant checks, worker
replacement, linked routing and an unsupported linked home, plus 14
existing Preview integration tests through `check:tmp`.
- Passed gateway, web and integration-tests package typechecks, lint on
edited source, scoped formatting and `git diff --check`. Regenerated
protobuf contracts with `bun run gen`.
- Checked real components in Chromium with a simulated stream: metadata
refresh kept one subscription in mini and panel views; pausing drawing
left at most one pending frame; delayed acknowledgements did not build a
playback queue; thread return, minimize/restore and target replacement
before decoding worked.
- Checked light/dark at desktop and 390 px phone widths. Copy audit
(§8): passed; existing labels and recovery text are retained, with
refreshed long labels checked for truncation. No UI test suite or
verification artifacts are included.
- Full repository checks and builds remain for CI. A live external
agent-browser session was not used for the browser verification.

Fixes: #846
nixuuu added a commit that referenced this pull request Nov 17, 2026
## Change

Device Preview previously listed every device on the worker, including
devices belonging to other sessions. It now shows the current thread's
device or, before reservation, free targets matching the selected
platform. Daemon claims and live worker reservations also exclude
devices while they start or are released.

Desktop/Device Preview now captures frames in a private OS cache
directory and deletes each PNG immediately after reading, including
failure paths. This avoids capture failures when a shared temporary
volume reaches its per-user quota (`EDQUOT`, errno 122) despite having
filesystem-wide free space. Catalog-only previews allocate no capture
storage. Updated the behavior and status in `docs/automation-tools.md`.

## Verification

- 55 tests passed through scoped `check:tmp` runs: device catalog,
device pool, Preview adapters, lifecycle, and screenshot storage/failure
cleanup.
- Worker typecheck and lint on all edited TypeScript files passed;
edited files formatted and diff reviewed.
- Independent code review found no actionable defects.
- Full repository checks and builds are left to CI. Live capture on an
updated worker remains unverified.

Fixes: #846
nixuuu added a commit that referenced this pull request Nov 18, 2026
## Change

Agent Desktop can report zero-width or zero-height windows in its
inventory. The worker previously rejected the entire response,
preventing the desktop and mobile clients from previewing other windows.

Treat invalid bounds as missing coordinates for the affected window.
Continue capturing by window ID, using screenshot metadata for logical
dimensions when needed. Pointer input still requires valid global
coordinates.

## Verification

- Reproduced the reported validation error with the regression test
before the fix.
- Passed 16 worker preview adapter tests with `check:tmp`, the worker
type check, and lint and formatting on the edited TypeScript files.
- Verified in an isolated Chromium run that the real worker preview
code, WorkerLink, gateway and SSE helper deliver the first Desktop frame
and continue after the paint acknowledgement with a simulated CLI.
- Live verification on macOS and the full CI gate remain pending.

Fixes: #846
nixuuu added a commit that referenced this pull request Nov 18, 2026
## Summary

- Resolve the Windows npm shim through the package manifest and run the
extensionless Agent Desktop 1.3.1 launcher through Node.js when its
shebang identifies it as a Node script. This covers version checks,
readiness, and normal tool invocations.
- Compare the reported CLI version with the pinned version and report
launch failures separately from version mismatches.
- Add regression coverage for the Windows npm layout, a prefix
containing spaces, version and readiness probes, and rejection of a
prerelease.

Fixes: #846

## Verification

- On nix-pc (Linux), commit `ae652824` passed all 24 tests in
`install.test.ts` and `adapters.test.ts` under
`apps/worker/src/agent-tools` via `check:tmp`.
- Targeted lint and worker typecheck passed. The published launcher also
returned `agent-desktop 1.3.1` when run through Node.js on Linux.
- Native Windows 11 installation, execution of the Windows binary, and
GUI readiness still need verification. GitHub CI and review remain the
merge gates.
nixuuu added a commit that referenced this pull request Nov 19, 2026
## Changes

- Keep collapsed thread details above the transcript and keep submenu
actions reachable on narrow screens. Preserve typed MCP form responses
and hide the floating Cite button while the selection menu is open.
- Show the full desktop invitation or the phone code when clipboard
access fails. Explain the worker-wide automation grant before enabling
Preview and show the reported cause when the computer is unavailable.
- Show shared offline status once across pull request resources. The
combined retry reloads the affected resources. Independent review
failures retain their own retry.
- Simplify empty states, errors and progress across settings, workspace
and bot setup. Keep exact values and recovery actions available in their
relevant views.

## Verification

The UI audit covered all 927 Svelte files in the audit revision,
including 41 route, layout and error files. Verification included
Chromium at phone and desktop widths, both themes, and selected native
Electron windows on Linux. Some conditional states used synthetic
responses or isolated components. Components without their own DOM were
verified through their visible effects. Native macOS and Windows
sessions were outside this pass.

Web, desktop and domain typechecks, formatting, lint of edited files,
and the 19 desktop update tests passed locally during the audit. GitHub
Actions runs the full gate on the rebased revision.

## Copy audit

Reviewed the ten items in docs/copy.md §8. Replaced the thread-scoped
Preview permission description with the actual worker scope. A failed
clipboard copy now exposes the value the receiving device accepts. Empty
libraries show a single add action, connection failures retain their
recovery action, and progress announcements remain accessible. Checked
short and long labels at phone and desktop widths. Two repeated labels
in the versioned visual renderer are deferred to its next version to
preserve existing documents.

Fixes: #68
Fixes: #846
nixuuu added a commit that referenced this pull request Nov 25, 2026
## Change

Installing or repairing Agent Desktop on macOS opens its permission
guide on the worker's computer when macOS reports missing Accessibility
or Screen Recording access. The verified installation shows **Needs
setup** while those permissions are pending. Repair reuses a compatible
installation and **Check tools** verifies readiness after the user
grants access.

## Verification

- 26 tests passed in `install.test.ts` and `adapters.test.ts` through
`check:tmp`.
- Worker typecheck, scoped lint and formatting passed. GitHub CI covers
the full verification gate.
- The tests exercise the guide command, the manual fallback and the
readiness transition. The native guide window and granting permissions
still need a macOS graphical session for verification.

## Copy audit

- “Grant Screen Recording permission for desktop screenshots” → “Allow
Screen Recording in System Settings on the Mac running this worker. Then
select Check tools.” The setup message now says which computer to use
and how to verify access.
- The install log explains what to do when the guide cannot open. The
same setup messages name Accessibility, Screen Recording or both as
reported by the worker.

Fixes: #846
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