Skip to content

feat(computer-use): desktop monitor window and session controls - #135

Merged
edenreich merged 17 commits into
mainfrom
feat/computer-use-monitor
Aug 21, 2026
Merged

edenreich merged 17 commits into
mainfrom
feat/computer-use-monitor

Conversation

@edenreich

@edenreich edenreich commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements #70 now that CLI v0.175.0 ships the headless computer-use control surface (inference-gateway/cli#1074). Computer-use tool calls render in the transcript through the existing tool path, a compact always-on-top monitor window tracks active computer-use sessions, and risky actions are gated through the existing approval flow with a system notification when the main window is unfocused.

Changes

  • Backend parses the new computer_use_paused / computer_use_resumed CUSTOM events and adds a send_computer_use_control command that writes the CLI's computer_use_control stdin message, mirroring send_approval.
  • The desktop exports INFER_COMPUTER_USE_APPROVAL=destructive when spawning infer, so mouse clicks and app activation require approval out of the box.
  • New monitor Tauri window (second Vite entry, monitor.html): always on top, docked bottom-right, hidden until a session issues a computer-use tool call and hidden again when the last session ends. It shows session name, status, latest action, approve/deny, pause/resume, and stop, with a native select to switch between concurrent sessions. The backend broadcasts every agent event to all windows as a global agent-event (alongside the ordered per-run IPC channel that feeds the main transcript), so the monitor and overlay consume it directly with no main-window re-broadcast hop; approve/deny decisions are echoed back so the main transcript's approval card resolves.
  • Approval requests fire a system notification via tauri-plugin-notification when the main window is not focused.
  • Transcript bug fixes found while testing: a ToolResult whose tool_call_id matches no tool card now attaches to the newest unresolved card instead of rendering a duplicate; pending approval cards flip to an inert "Session ended" state when the run finishes; user-initiated Stop reports Cancelled instead of a spurious "Process exited with code -1" error.
  • Layout regression fix: fix(transcript): allow scrolling up while agent is busy, add scroll-to-bottom button #127's scroll-button wrapper made the transcript's overflow-y-auto inert, so long conversations floated over the composer instead of scrolling. The wrapper is a flex column again, and a new e2e AX-geometry assertion (assert_above_composer) plus a transcript-overflow test guard it.
  • e2e harness: each mock run gets a scratch HOME (no more polluting the real conversation store), letter keypresses are supported, and the project-grouping test finally has a matching mock scenario - it could never pass before. New computer-use scenario asserts the tool call renders in the transcript. Unless INFER_BIN overrides it, the runner now downloads the latest released infer once per suite (dev-environment PATH as offline fallback), so e2e tests the CLI users actually run instead of a stale pin.

Tests: cargo test (60), bun test (31), task e2e 11/11 passing against the latest released CLI (v0.176.0).

Related: inference-gateway/cli#1080 fixes the CLI nix flake broken by the Swift removal, which currently blocks bumping this repo's flox infer pin past v0.175.0.

Out of scope per the issue: live screenshot preview (CLI frame delivery deferred) and monitor-window AX coverage (driver only walks the main window).

…monitor window

Implements #70 on top of CLI v0.175.0: computer-use tool calls render through the existing tool path, a second always-on-top Tauri window (docked bottom-right) shows per-session status, latest action, approve/deny, pause/resume, and stop controls, approval requests raise a system notification when the main window is unfocused, and the desktop exports INFER_COMPUTER_USE_APPROVAL=destructive so risky actions are gated out of the box.
…-grouping test

The harness previously spawned the app against the real ~/.infer, so every run polluted the user's conversation store and silently tested whatever stale CLI was installed. Each mock run now gets a scratch HOME under e2e/artifacts and INFER_BIN points at the dev environment's pinned infer. Also fixes the project-grouping test, which could never pass: its prompt had no matching mock scenario and the driver rejected letter keypresses.
…en overlay

A third transparent, always-on-top, click-through Tauri window covers the screen while computer-use actions stream: a cursor dot glides to each MouseMove/MouseScroll target, a ring ripples on MouseClick, and a key-cast pill at the bottom shows the text or key combo the agent is typing. All animation is CSS inside the webview, so there is no per-frame IPC, and the same approach works on macOS, Windows, and Linux (macOS additionally needs the macos-private-api flag for transparency). Also corrects the computer-use tool names to the CLI's actual PascalCase identifiers (MouseClick, KeyboardType, ...) - the snake_case names from the issue text never matched.
@edenreich

Copy link
Copy Markdown
Contributor Author

Added a screen overlay for computer-use visualization: a transparent, click-through, always-on-top window shows a gliding cursor dot for MouseMove/MouseScroll, a ripple ring on MouseClick, and a key-cast pill at the bottom of the screen showing what the agent types (text or key combos). Animation is pure CSS in the webview (no per-frame IPC) and the approach is cross-platform. This commit also fixes the computer-use tool names to the CLI's actual PascalCase identifiers - the snake_case names in the issue body never matched.

@edenreich
edenreich marked this pull request as ready for review August 19, 2026 15:02
… overlay and e2e driver fixes

The overlay now shows a rounded breathing border at the screen edges for the whole computer-use session, not just around individual actions, so it is always clear the agent is in control. Overlay sizing uses primaryMonitor with a retry at wake time (currentMonitor returns null for a hidden window, which left the overlay at its 200x200 default and clipped every effect). The e2e driver addresses the main window by title for AX and screenshots - window 1 and largest-window heuristics both break once the fullscreen overlay is visible. The computer-use scenario now exercises MouseMove, MouseClick behind the destructive approval gate, and KeyboardType, and the Taskfile documents single-file filtering: task e2e -- tests/computer-use.yaml
The monitor and overlay windows loaded their own HTML entries, and when multi-page asset resolution fell back to index.html the overlay rendered the full app - transparently, fullscreen, on top of everything (the white screen and the ghost UI over the composer). All windows now load the single index.html entry and main.tsx picks the component by Tauri window label, so the wrong-page failure mode no longer exists. The overlay forces a transparent body since the shared stylesheet paints one.
edenreich added a commit to inference-gateway/cli that referenced this pull request Aug 19, 2026
The desktop app's monitor, screen overlay, and approval surface
(inference-gateway/desktop#135) replace the CLI's macOS-only Swift
floating window, consuming the headless control surface from #1074/#1075.

- delete internal/display/macos/ComputerUse/ (Swift app), the embed and
  FloatingWindowManager lifecycle (manager.go, manager_stub.go, types.go),
  and the cmd wiring (floating_window_darwin.go, floating_window_stub.go)
- drop floating_window from computer_use config, env overrides, and
  defaults; unknown keys stay tolerated on load (covered by test fixture)
- chat: control-event forwarding to Bubble Tea now gates on an EventBridge
  being present instead of the floating window
- release workflow: remove the Swift build step
- CI: add a macos-latest build job so darwin cgo code compiles in CI
  (was ubuntu-only, which previously masked darwin breakage)
- README: point at the desktop app for visualization
edenreich added a commit to inference-gateway/cli that referenced this pull request Aug 19, 2026
Resolves #1077

## Summary

Removes the macOS-only Swift floating window outright (no deprecation
cycle). The desktop app's computer-use monitor, screen overlay, and
approval surface (inference-gateway/desktop#135) are the visualization
layer, consuming the headless control surface from #1074/#1075.

## Changes

- **Deleted**: `internal/display/macos/ComputerUse/` (Swift app), the
`//go:embed` + `FloatingWindowManager` lifecycle (`manager.go`,
`manager_stub.go`, `types.go`), and the cmd wiring
(`floating_window_darwin.go`, `floating_window_stub.go`)
- **Config**: `floating_window` section removed from `computer_use.yaml`
schema, defaults, and `INFER_COMPUTER_USE_FLOATING_WINDOW_*` env
overrides. Existing config files with the old keys still load (yaml
unmarshal is lenient; covered by a test fixture that keeps the removed
keys)
- **Chat**: control-event forwarding to Bubble Tea now gates on an
EventBridge being present instead of the floating window; EventBridge
itself stays (extension bridge / control surface use it)
- **Release workflow**: Swift build step removed
- **CI**: new `build-macos` job (`macos-latest`, plain `go build`) so
darwin cgo code compiles in CI — the previous ubuntu-only matrix masked
darwin breakage (see #1078). Now trivial since the Swift embed is gone
- **README**: points at the desktop app for visualization

## Acceptance criteria

- [x] `ComputerUse/` and `cmd/chat.go` wiring removed
- [x] `floating_window` dropped; unknown keys don't break config load
(test-covered)
- [x] `infer chat` computer-use session verified against the mock
gateway (model select, prompt, reply; 42 tools registered, no
floating-window errors)
- [x] README no longer references the Swift window

## Impacted repos

- **docs**: inference-gateway/docs#578
- **desktop**: no action required — tool names unchanged; schema change
(`bundle_id` → `app_id`/`name`) noted on desktop#70 separately

## Docs

Filed: inference-gateway/docs#578
…report user stop as cancelled

A ToolResult whose tool_call_id does not match any tool card (the CLI sometimes emits an empty id) now attaches to the newest unresolved tool card instead of appending a duplicate. Pending approval cards flip to an inert "Session ended" state when the run finishes, instead of keeping live Approve/Deny buttons that can only fail with "No running agent". Stopping the agent (Stop button, monitor, shutdown) now emits Cancelled instead of a synthetic "Process exited with code -1" error banner; a real signal death still reports the error.
…s inside the chat area

The scroll-to-bottom change (#127) wrapped #chat-transcript in a plain block div, which made its flex-1 and overflow-y-auto inert: the transcript grew with its content and long conversations floated over the composer instead of scrolling. Make the wrapper a flex column and bound the transcript's height again.

The e2e harness gains an assert_above_composer step that checks real AX geometry (a button's bottom edge must sit above the composer textarea), plus a transcript-overflow test that fills the chat and asserts the pending approval card stays inside the conversation area. The assertion was verified to fail on the broken layout and pass on the fixed one.

The harness also stops testing a stale CLI: unless INFER_BIN overrides it, the runner downloads the latest released infer once per suite (falling back to the dev environment's PATH offline), so e2e exercises the version users actually run instead of the flox pin.
… the main-window re-broadcast

Agent events reached the monitor and overlay windows by the main webview re-emitting every Channel message as a global "agent-event" - an extra IPC hop that also tied the secondary windows to the main window being alive. The backend now emits the same payload to all windows itself (tauri Emitter alongside the ordered per-run Channel that feeds the transcript), and the frontend re-broadcast is gone. Monitor and overlay are unchanged consumers.
…e visible

Tool-call coordinates arrive in the CLI's 1024x768 screenshot space; the overlay now scales them to its own CSS pixels instead of drawing them raw, so the dot and ripple land where the click actually happens.

The overlay window now covers the monitor work area instead of the full bounds, so the glow frame's top edge is no longer hidden under the macOS menu bar.
contentProtected maps to NSWindowSharingNone, so the agent's full-display captures no longer show the monitor - it kept trying to click the Approve button it saw there, deadlocking behind its own approval gate.
… composer, and A/R approvals

The monitor now keeps a capped action/text log with the latest captured frame (base64 from the tool result, since frame files are short-lived), expands to reveal a composer that round-trips follow-up prompts through the main window via monitor-send so the transcript stays in sync, and stays open after a run ends.

Approvals sync both directions (main window now emits approval-resolved), and while one is pending the global shortcuts A/R approve or deny without touching the mouse - a hand still on the mouse was dragging the pointer off the agent's synthetic click target.
Extend the overlay from the work-area top (macOS shifts any window overlapping the menu bar) down over the Dock; the backend raises the window to NSStatusWindowLevel so it draws above the Dock.
The CLI now fits frames inside the 1024x768 box with one scale factor (aspect preserved), so the overlay's inverse mapping uses the same single factor for both axes.
Computer-use frames and region crops arrive base64 in the tool result with no file path; the transcript now renders them (download button hidden when there is no on-disk file), so the user can see exactly what the model saw.
infer v0.178.0 collapsed MouseMove/MouseClick/MouseScroll/KeyboardType/
GetFocusedApp/ActivateApp into a single action-based Computer tool, leaving
Computer and GetLatestFrame. The overlay and monitor matched on the removed
names, so against a current CLI the overlay never lit up and the monitor
never auto-opened.

overlayAction now switches on args.action rather than the tool name, picking
up the arg renames (key_combo -> combo, scroll's dy -> direction/amount).
Observation carries no json tags, so parseToolResult falls back to Message
before stringifying data - otherwise every Computer result rendered as a JSON
dump containing the base64 frame. The monitor's approval prompt shows the
args, since "Allow Computer?" no longer says what is about to happen.

Under INFER_COMPUTER_USE_APPROVAL=destructive the CLI now gates every action
except screenshot and cursor, so the e2e scenario pairs an ungated cursor
turn with a gated click turn.
@edenreich
edenreich merged commit a2db84e into main Aug 21, 2026
1 check passed
@edenreich
edenreich deleted the feat/computer-use-monitor branch August 21, 2026 20:33
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.19.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-maintainer inference-gateway-maintainer Bot added the released Shipped in a release label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant