Skip to content

Serve browser and desktop views from the Go worker - #97

Merged
devin-ai-integration[bot] merged 11 commits into
mainfrom
devin/1795452868-worker-computer-views-v2
Nov 24, 2026
Merged

devin-ai-integration[bot] merged 11 commits into
mainfrom
devin/1795452868-worker-computer-views-v2

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Supersedes #83 (auto-closed when #80's branch was deleted). Same content, rebased onto main after #80's squash merge — review history lives on #83.

Ports the view op from browser-view.mjs and desktop-view.mjs to the worker. It serves the ComputerRequest fields the service's computer.watch / computer.input send (#81).

View Request ComputerResult.Result
open ViewID from the service; a reopened ID replaces its view empty (TS {})
next — {"messages":[{seq, data (base64), mimeType, width, height, timestamp}]}
send Message: the TS ViewerAction (type: ack, text, key, pointer, back) empty
close — empty

A view is bound to the service and dir that opened it, and worker shutdown closes it. worker.Client also has a typed OpenView → Next/Send/Close over the same wire.

Browser

  • agent-browser stream status --json must report an enabled port in 1..65535.
  • session_info on http://127.0.0.1:<port>/api/command must return the Bot's AGENT_BROWSER_SESSION before the worker dials ws://127.0.0.1:<port>/?pacing=ack&maxFps=30.
  • Frames over 4 MiB and non-frame messages are skipped. A stale ack is EINVAL.
  • Input commands go through the browser's computer lane and uncertainty marker. An unconfirmed command makes the browser COMPUTER_UNCERTAIN, so agent actions need RestartBrowser.
  • Back, pointer cancel and close release a held pointer at (-1, -1).

Desktop

  • get_desktop_state at 1920px with session: <viewID>. The next capture waits for the ack plus 500 ms.
  • Input maps to type_text / hotkey / press_key / click / drag (over 3 px) / move_cursor / scroll, aimed at {kind: desktop, display_id: primary}.

CursorColor on open is unused. In TS the cursor theme is applied on desktop calls, which is a separate change.

This PR adds github.com/coder/websocket for the stream client. TestComputerBrowserView and TestComputerDesktopView run over stdio and SSH against a fake stream server and fake Cua tools.

Link to Devin session: https://app.devin.ai/sessions/dd13702c910149ffaa30fc2797fa3b72
Open in Devin Desktop: https://app.devin.ai/desktop/session/dd13702c910149ffaa30fc2797fa3b72?variant=devin
Requested by: @Personed


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

Ports the view op from browser-view.mjs and desktop-view.mjs to the worker. It serves the ComputerRequest fields the service's computer.watch / computer.input send (#81). Rebased onto main after #80 squash-merged; same content as devin/1795452868-worker-computer-views at 161b199.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Personed and others added 10 commits November 24, 2026 05:57
Emit ready once with a UUIDv4 viewer id, then one frame event per screen image, as apps/api computer.ts does; the decimal id failed the computer.input uuid pattern and opened/message events were never rendered. Prepare the service on open, as views.ts does, so a browser that cannot produce frames fails instead of leaving a blank stream.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
views.ts viewAccess throws when another viewer holds the lease or the lease went stale, and refuses non-ack input without a lease; a signed-in viewer could otherwise type into a Bot-owned computer.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
viewer-types.ts discriminates on type (ack, take, back, text, key, pointer); reading action left every message unmatched, so acks were rejected as unleased input and take/back never ran.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
control() keys an isolated browser by browser:<botId> and shares the desktop lane otherwise; one global lease per service let a second Bot's grant kill an unrelated viewer's lease. The browser's sharedDesktop prepare result maintains the isolation set.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
views.ts forwards "back" to the worker while the lease still stands so it can clear a held pointer, then releases; releasing first made the request fail the lease gate. take also no longer reaches the worker's send, which has no such message.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
omitempty dropped the false that marks a headless browser's own control lane, so a desktop takeover froze its viewers' acknowledgements (browser-service.mjs reports mode === "headed" either way).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
services.ts takeover throws when the control already holds a lease; overwriting it silently revoked the active viewer's control without a hand-back.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
services.ts assigns the control lease before awaiting settle, so a closing viewer's release always sees the reservation. Claiming it afterwards let a grant land on a dead viewer and lock the lane for every later takeover. A failed settle now also gives the claim back.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
views.ts keeps the grant as view.taking: input is refused while it settles, a repeated take or request awaits the same grant instead of reporting control it never received, and back/close wait for it before releasing. A pending grant authorized input before this, and a repeated takeover reported a grant that could still fail.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Unlocked grant fields let two takes each open a channel and close the other's or nil, and a retry could overwrite the failure a waiter was about to read. A per-view mutex and a per-attempt result keep every caller on the grant it awaited.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration
devin-ai-integration Bot merged commit f2ad29e into main Nov 24, 2026
42 of 43 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1795452868-worker-computer-views-v2 branch November 24, 2026 07:10
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