Skip to content

feat(computer-use): cross-platform AppProvider replacing macOS-only FocusManager - #1078

Merged
edenreich merged 2 commits into
mainfrom
fix/issue-1076
Aug 19, 2026
Merged

edenreich merged 2 commits into
mainfrom
fix/issue-1076

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Resolves #1076

Summary

Replace the macOS-only FocusManager interface with a cross-platform AppProvider abstraction for the computer-use tool surface. ActivateApp now targets running applications by stable ID or name (not installed-bundle lookup), and GetFocusedApp returns structured application data on all three platforms. Errors distinguish "not running" from "OS refused".

Changes

  • New domain type: Application struct (ID, Name, PlatformID) - a cross-platform model for running apps
  • New interface: display.AppProvider replacing display.FocusManager - methods: ListRunning, Activate, GetFocused, Close
  • New sentinel errors: ErrAppNotFound and ErrAppUnsupported for clear error distinction
  • macOS: Standalone macosAppProvider registered via init(), uses NSWorkspace to enumerate all running apps, activate by bundle ID or PID (unbundled/dev processes now work)
  • X11: Full x11AppProvider using _NET_CLIENT_LIST, _NET_WM_PID, _NET_ACTIVE_WINDOW atoms + fallback to SetInputFocus
  • Wayland: AppProvider stub returning ErrAppUnsupported with documented limitation
  • ActivateApp: Tool schema changed from bundle_id (macOS-only) to app_id (stable ID) or name (substring match)
  • GetFocusedApp: Now returns structured data (app_id, app_name, platform_id) instead of raw bundle ID
  • MouseClick: Updated to use AppProvider instead of FocusManager type assertion for post-click focus recording
  • No backward compatibility: Breaking change - old bundle_id argument removed

…ocusManager

Replace the macOS-only FocusManager interface with a cross-platform AppProvider that enumerates running applications, activates by stable ID/name, and reports the focused application - implemented for macOS, X11, and Wayland (stub). Breaking changes: ActivateApp now takes app_id or name instead of bundle_id. GetFocusedApp returns structured Application data. FocusManager interface removed; replaced by AppProvider. macOS: added PID-based activation for unbundled/dev processes. X11: implemented via _NET_CLIENT_LIST, _NET_WM_PID, _NET_ACTIVE_WINDOW. Wayland: stub returning ErrAppUnsupported. Errors distinguish 'application not running' (ErrAppNotFound) from OS refusal. Resolves #1076
@edenreich
edenreich marked this pull request as ready for review August 19, 2026 15:58
@edenreich
edenreich requested a review from a team as a code owner August 19, 2026 15:58
- app_darwin.go could not compile: cgo names are per-file, so the
  standalone provider referencing C functions from client_darwin.go's
  preamble failed; it is now a thin provider delegating to package
  functions in client_darwin.go (also removes the duplicated
  implementation on MacOSClient/Controller)
- remove leftover GetTerminalApp/SwitchToTerminal calling the deleted
  getTerminalApp C function, and the unused GetFrontmostApp
- strdup ObjC UTF8String returns: freeing autoreleased interior
  pointers corrupted the heap, and listRunningApps returned a pointer
  that died with its autorelease pool
- drop Close from AppProvider: tools were closing the shared registered
  singleton, killing the X11 connection after the first call; the X11
  provider is now stateless and opens one short-lived connection per
  call
- fix _NET_ACTIVE_WINDOW client message: the target window belongs in
  the event's window field (was root), use proper
  SubstructureRedirect|Notify mask (was 0x00FFFFFF), and build it with
  xproto.ClientMessageEvent instead of hand-rolled byte helpers
- delete the Wayland stub: it was only registered when it would always
  be skipped by DetectAppProvider, which no longer probes
- stop advertising a nonexistent ListRunning tool in prompts and
  schema descriptions
- only warn in storeFocusedApp on a real error, not on headless nil
@edenreich
edenreich merged commit 9f8fecc into main Aug 19, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1076 branch August 19, 2026 16:24
edenreich added a commit 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
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.176.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

[FEATURE] Cross-platform app activation and focus for computer-use (breaking)

1 participant