Repository navigation
feat(drive): serve OpenCode Drive's simulation endpoint headless as the image surface - #1904
Merged
Merged
Conversation
With OPENCODE_DRIVE set, the desktop app runs without a window in a host of its own (crates/rune-drive): a Rune runtime on the wall clock that answers the simulation protocol's ui.* requests over WebSocket, feeds keys and pointer input into Rune's routing, reads ui.state and ui.snapshot from the element tree, and renders ui.capture.image offscreen to PNG. It connects to Drive's server with --server and OPENCODE_SERVER_PASSWORD and opens a new session in Drive's project (--directory). Normal launches are unchanged. User decisions: - Add a gui-rune launch mode to OpenCode Drive that drives the Rune desktop app, headless
OpenCode's simulation protocol is now a core plus one module per surface. The Rune endpoint declares the image surface and serves the core plus ui.captureImage (was ui.capture.image). It drops the terminal-shaped ui.capture text approximation and no longer advertises ui.recording.finish, which belong to the terminal surface. User decisions: - Per-surface simulation protocol extensions, defined in OpenCode's protocol package (one module per surface) - Redo before merging
…press and ui.click
- ui.mouse scroll: wheel_xy's positive deltas move content right and down, so Up is +dy and Down -dy
- the host loop handles a Wake taken between requests: it clears pending and frames before the next
request (or at the end), instead of discarding it and muting the app's wakes for up to a second
- ui.mouse applies its modifiers (held as PhysicalInput::Modifiers, and on the wheel event)
- ui.press: " " and space stay Text(" ") with modifiers; arrowup/del/pgup/pgdn/ins aliases;
unknown multi-character names are refused rather than typed
- ui.click refuses an offset outside the element instead of clamping onto its edge
- run takes a TurnScope that wraps each frame and request turn
User decisions:
- Fix the Carbon review findings on gui-rune
…s, forbid unsafe - Pixels::new uses Gpu::try_new, so no adapter is a JSON-RPC error and the app keeps serving - WebSocket upgrades with an Origin header are refused (403): browsers always send one, Drive's Bun client sends none - #![forbid(unsafe_code)]; PNG Compression::Fast User decisions: - Fix the Carbon review findings on gui-rune
…tartup hooks - each drive turn enters and leaves servers::runtime's scope, as a window's turn_scope does, so the ServerPeer goes back between turns - the drive branch returns before the Mac launch, notification identity, GPU prewarm and app icon - one Phase state machine replaces the ACTIVE/OPENED flags - correct the module comment: RUNE_DIRS_ROOT is what isolates the profile User decisions: - Fix the Carbon review findings on gui-rune
… arrow names - ui.mouse released its modifiers before the frame that runs the queued press and drag handlers, so they saw none (a Ctrl-click on a session row or Shift-click on a button read as plain). The host now releases them after the frames that dispatch the event. - keys: arrow names are matched exactly (up, arrow_up, arrowup, ...) rather than by stripping an "arrow" prefix, which let "arrowenter" through as Enter. - inspect: a duplicated key on an element with an empty path falls back to a non-empty id. - capture: Renderer::try_new, so a renderer that can't be made answers with an error. - The waker's pending flag uses SeqCst on both sides. User decisions: - Fix the Carbon re-review findings on gui-rune
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves OpenCode Drive's simulation UI endpoint headless (
OPENCODE_DRIVE):crates/rune-driveruns anyrune::Runtimeon the wall clock with no window, feeds protocol input into Rune's input routing, answersui.stateandui.snapshotfrom the element tree, and renders pixels offscreen. The desktop app takes this path whenOPENCODE_DRIVEis set (workspace/lifecycle/launch/drive.rs); normal launches don't change.Per-surface protocol
OpenCode's simulation frontend protocol is now a core plus one module per surface (anomalyco/opencode#67407). This endpoint:
surface: "image"in its handshake;ui.type,ui.press,ui.enter,ui.arrow,ui.focus,ui.click+ semantic,ui.mouse,ui.resize,ui.matches,ui.state,ui.snapshot) and the image module'sui.captureImage(offscreen render, PNG, width, height, scale);ui.capture(the text grid approximation) and stops advertisingui.recording.finish. Both belong to the terminal surface, so an unknown-method error now refuses them.Coordinates and sizes are logical points. Drive (anomalyco/opencode-drive#150) connects to it as the image surface and gives
gui-runescripts anImageUiwithui.captureImage()and noui.capture().Verification
cargo build -p opencode-desktopandcargo clippy -p rune-driveare clean.scripts/guardrails.shpasses 11/11.Companion PRs: anomalyco/opencode#67407 (protocol), anomalyco/opencode-drive#150 (Drive), #1904 (Rune).