Repository navigation
feat(computer-use): headless control surface for host UIs - #1075
Conversation
Co-authored-by: Eden Reich <[email protected]>
Co-authored-by: Eden Reich <[email protected]>
Co-authored-by: Eden Reich <[email protected]>
Co-authored-by: Eden Reich <[email protected]>
|
@infer Can you review this PR? use /ponytail:ponytail /ponytail:ponytail-review /go /go-concurrency From a first look I don't like that we use goto, that's a bad practice. |
|
Model: Todos
Pull Request✅ Infer Result: SuccessHere is my complete review of PR #1075, covering over-engineering (ponytail-review), idiomatic Go, and concurrency correctness. ponytail-review: over-engineering findingsnet: -18 lines possible from the PR diff. Finding 1:
|
| Before (PR) | After (proposed) |
|---|---|
goto done |
natural for range exit |
for/select + break label workaround |
for range |
| buffered channel (cap 4) | func(action string) callback |
| channel overflow risk (5th send blocks forever) | synchronous call, no buffer |
| 18 extra lines for the channel loop | callback integrated into existing for range |
The three new capabilities the PR adds — approval gating, pause/resume IPC, and event emission — are preserved. The only thing removed is unnecessary concurrency plumbing that a goto was gluing together.
Model: ollama_cloud/deepseek-v4-flash:preview · Exit Code: 0 · Duration: 3m 3s
Tokens: 934,529 in · 17,636 out · 952,165 total (15 requests)
Tool calls: 24 total · 100% success rate
Traces
Session: 1787142510-b1aaf597
session (headless, success) 2m55s
├── chat ollama_cloud/deepseek-v4-flash:preview 3.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.0s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 3.0s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 3.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.0s [error: *errors.errorString]
├── execute_tool Read call_f5ifrkez 245µs
├── execute_tool Read call_7ytcji74 322µs
├── execute_tool Bash call_airgw1fw 5ms
├── execute_tool Bash call_jkoy8wf8 4ms
├── chat ollama_cloud/deepseek-v4-flash:preview 3.4s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.3s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 3.3s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 3.3s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.3s [error: *errors.errorString]
├── execute_tool Read call_13hx5x47 144µs
├── execute_tool Read call_5gt7nnfh 118µs
├── execute_tool Read call_6ydmjgb6 266µs
├── execute_tool Read call_d1dwn1zt 99µs
├── execute_tool Read call_7f8vu89x 105µs
├── chat ollama_cloud/deepseek-v4-flash:preview 33.7s
│ ╰── POST /v1/chat/completions [inference-gateway] 33.7s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 33.7s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 33.7s
│ ╰── POST /v1/chat/completions [inference-gateway] 33.7s [error: *errors.errorString]
├── execute_tool Grep call_6xv7eh37 350ms
├── execute_tool Grep call_13zseu40 74ms
├── execute_tool Read call_lh8jfr1v 207µs
├── chat ollama_cloud/deepseek-v4-flash:preview 19.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 19.0s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 19.0s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 19.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 19.0s [error: *errors.errorString]
├── execute_tool TodoWrite call_b7r686r5 62µs
├── chat ollama_cloud/deepseek-v4-flash:preview 2.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 2.8s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 2.8s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 2.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 2.8s [error: *errors.errorString]
├── execute_tool Read call_n108pgjs 222µs
├── execute_tool Grep call_2tb10mj5 69ms
├── chat ollama_cloud/deepseek-v4-flash:preview 23.9s
│ ╰── POST /v1/chat/completions [inference-gateway] 23.9s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 23.8s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 23.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 23.8s [error: *errors.errorString]
├── execute_tool TodoWrite call_iz8djb9s 76µs
├── chat ollama_cloud/deepseek-v4-flash:preview 6.4s
│ ╰── POST /v1/chat/completions [inference-gateway] 6.4s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 6.4s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 6.4s
│ ╰── POST /v1/chat/completions [inference-gateway] 6.4s [error: *errors.errorString]
├── execute_tool Read call_fxnlcvxt 127µs
├── chat ollama_cloud/deepseek-v4-flash:preview 15.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 15.8s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 15.8s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 15.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 15.8s [error: *errors.errorString]
├── chat ollama_cloud/deepseek-v4-flash:preview 11.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 11.8s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 11.8s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 11.8s
│ ╰── POST /v1/chat/completions [inference-gateway] 11.8s [error: *errors.errorString]
├── chat ollama_cloud/deepseek-v4-flash:preview 18.6s
│ ╰── POST /v1/chat/completions [inference-gateway] 18.6s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 18.6s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 18.6s
│ ╰── POST /v1/chat/completions [inference-gateway] 18.6s [error: *errors.errorString]
├── chat ollama_cloud/deepseek-v4-flash:preview 3.7s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.7s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 3.7s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 3.7s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.7s [error: *errors.errorString]
├── execute_tool TodoWrite call_zkbi7i6h 94µs
├── chat ollama_cloud/deepseek-v4-flash:preview 4.1s
│ ╰── POST /v1/chat/completions [inference-gateway] 4.0s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 4.0s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 4.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 4.0s [error: *errors.errorString]
├── execute_tool TodoWrite call_0jkznfsn 59µs
├── chat ollama_cloud/deepseek-v4-flash:preview 3.9s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.9s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 3.9s
│ ╰── POST /proxy/:provider/*path [inference-gateway] 3.9s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.9s
├── execute_tool TodoWrite call_xvkui4jw 67µs
├── chat ollama_cloud/deepseek-v4-flash:preview 3.6s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.6s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 3.6s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 3.6s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.6s
├── execute_tool TodoWrite call_t7bh8dxd 48µs
├── chat ollama_cloud/deepseek-v4-flash:preview 3.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.0s
│ ╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 3.0s [error: *errors.errorString]
│ ╰── POST /proxy/:provider/*path [inference-gateway] 3.0s
│ ╰── POST /v1/chat/completions [inference-gateway] 3.0s [error: *errors.errorString]
├── execute_tool TodoWrite call_1ujhpo16 61µs
╰── chat ollama_cloud/deepseek-v4-flash:preview 15.4s
╰── POST /v1/chat/completions [inference-gateway] 15.3s
╰── POST /proxy/ollama_cloud/chat/completions [inference-gateway] 15.3s [error: *errors.errorString]
╰── POST /proxy/:provider/*path [inference-gateway] 15.3s
╰── POST /v1/chat/completions [inference-gateway] 15.3s [error: *errors.errorString]
Stats
Tool Calls
╭───────────┬───────┬───────┬───────╮
│ Tool │ Calls │ Fail% │ Avg │
├───────────┼───────┼───────┼───────┤
│ Read │ 10 │ 0% │ 0ms │
│ TodoWrite │ 7 │ 0% │ 0ms │
│ Grep │ 3 │ 0% │ 164ms │
│ Bash │ 2 │ 0% │ 5ms │
╰───────────┴───────┴───────┴───────╯
Token Usage
╭────────────────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model │ Prompt │ Cached │ Completion │ Total │ Cost │
├────────────────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/deepseek-v4-flash:preview │ 1004333 │ 0 │ 18779 │ 1023112 │ - │
╰────────────────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯
Sessions
╭───────────┬──────────┬──────────╮
│ Execution │ Mode │ Sessions │
├───────────┼──────────┼──────────┤
│ headless │ headless │ 1 │
╰───────────┴──────────┴──────────╯
Triggered by edenreich · Infer Action · OSS
Co-authored-by: Eden Reich <[email protected]>
|
@infer Can you address the review comments above? use /ponytail:ponytail |
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll complete. The change is pushed at Model: Tokens: 1,065,088 in · 7,285 out · 1,072,373 total (19 requests) Tool calls: 27 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
@edenreich flagged the 'goto done' as non-idiomatic. Replaced with 'break eventLoop' - a labeled break is the standard Go pattern for breaking out of a for-select loop without a goto label. Removes the 'done:' label entirely.
Move IPC handling out of the renderers into a single stdin reader in cmd/headless.go. Pause now cancels the in-flight request and sets the paused state (mirroring chat mode); resume appends the hidden continue message and restarts the run. Real ComputerUsePaused/Resumed events flow through both the JSON and ag-ui renderers, control messages work without --require-approval, and the renderer's speculative select loop and its self-deadlocking control channel are removed.
|
🎉 This PR is included in version 0.175.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
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
Resolves #1074
Summary
Adds a headless computer-use control surface so the desktop app (and other host UIs) can configure action-gating, pause/resume sessions, and observe computer-use state changes through the
infer headless --format ag-uiprotocol. Three capabilities that were only wired intoinfer chatare now available headlessly: approval gating, pause/resume IPC, and a documented frame-delivery plan.Changes
computer_use.approvalconfig knob - three levels:never(default, current bypass behaviour),destructive(MouseClick and ActivateApp require approval),always(every computer-use tool requires approval). TheStandardApprovalPolicychecks this setting instead of unconditionally bypassing all computer-use tools. Unknown values are rejected at config load (Config.Validate) and fail closed in the policy; overridable viaINFER_COMPUTER_USE_APPROVAL.ComputerUseControlMessage IPC type - adds
{"type":"computer_use_control","action":"pause|resume"}as a recognised stdin message following theapproval_responseIPC pattern.Working headless pause/resume - a single stdin-reader goroutine in
cmd/headless.go(headlessControl) owns the IPC line stream for the json, json-pretty, and ag-ui formats — control messages work even withcomputer_use.approval: neverand without--require-approval. Pause mirrors chat mode:agentService.CancelRequest(sessionID)+SetComputerUsePaused. Resume mirrors chat mode's restart: the pump appends the hidden "Please continue from where you left off." message and starts a newRunWithStreamover the same conversation. RealComputerUsePausedEvent/ComputerUseResumedEventare injected into the event stream, so both renderers emit them through their normal event handling: AG-UICUSTOMevents (computer_use_paused/computer_use_resumed) and matching JSON lines with the real sessionrequest_id.Channel-based approval broker - renderers no longer scan stdin;
answerApprovalconsumesApprovalResponsevalues from the control reader's channel, keeping a single stdin owner and letting approvals and control messages interleave freely.Frame delivery decision - documented as host-side polling (desktop app reads the
get_latest_framesource directly). AG-UI frame events are deferred; a follow-up issue may add a lightweight frame-available notification.Swift floating window deprecation path - documented: once the desktop monitor ships, flip the YAML default for
floating_window.enabledtofalse, add a deprecation notice to the Swift README, and remove after a deprecation cycle.