Repository navigation
feat(browser): stream remote browser traffic over multiplexed binary WebSocket (opencode#66217) - #1288
Merged
Conversation
…WebSocket (opencode#66217)
Hona
marked this pull request as ready for review
November 26, 2026 03:58
Hona
added a commit
that referenced
this pull request
Nov 26, 2026
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.
Ports official
anomalyco/opencode#66217(badd3ea1cdbbeaf6e8d7ae73c5866cfb2a1eda0b) so remote browser traffic streams over one prewarmed, multiplexed binary WebSocket with per-origin HTTP/1.1 keep-alive pooling and non-stalling navigation settlement.Summary
crates/opencode-kit/src/client/browser_rpc/):stream_wire.rs, matchingpackages/plugin-browser/src/stream-wire.ts):OPEN,OPENED,DATA,WINDOW_UPDATE,FIN,RESET,PING,PONG,GOAWAYwith strict length/port/host/window/UTF-8 validation and zero base64 encoding.ClientMux+MuxStream(stream_mux/{mod,stream,worker}.rs, matchingpackages/plugin-browser/src/stream-mux.ts): dedicated non-blockingpolling::Pollersingle-writer loop with priority control queue, fair round-robin 16 KiBDATAinterleaving capped at 256 KiB WebSocket buffer, 512 KiB receive window with 128 KiBWINDOW_UPDATEbatches, bounded per-stream and 8 MiB per-attachment buffer enforcement, 128-stream / 32-pending-connect caps, 25 s / 60 s heartbeats, half-closeFIN, immediateRESETon cancel/drop, and clean detach settling every pending opener/reader/writer with a cancellation error.tunnel/client.rs,http.rs,types.rs, matchingpackages/gui-plugins/src/browser/tunnel-client.ts): derivesws:///wss://solely from the configured server URL (preserving reverse-proxy base paths), validatespath == /api/experimental/browser/tunnelandprotocol == 1, passes the single-use upgrade token exclusively in the request header (never query params), enforces verified TLS, and classifies auth/TLS/blocked/protocol/transport errors explicitly without silently downgrading.TransportController(tunnel/stream.rs), per-origin plain HTTP/1.1 keep-alive pooling (tunnel/pool.rs, matchingpackages/plugin-browser/src/proxy.ts), and integrated them intoTunnelProxy(tunnel/proxy.rs,tunnel/pump.rs,framing.rs) while preserving loopback127.0.0.1:0SO_EXCLUSIVEADDRUSEbinding, 384-bit Basic407auth, immediate eviction on error/abort/reset/disconnect, and legacy RPC fallback whentunnel.ws.v1is not advertised orOPENCODE_BROWSER_TUNNEL_TRANSPORT=legacyis set.apps/desktop/src/surfaces/browser/):attached.capabilitiesintypes.rs/machine.rs(packages/gui-plugins/src/browser/pane-machine.ts), prewarming the binary WebSocket inrpc/tunnel.rsand transferring attachment liveness toStreamActivated/StreamEndedso reverse-proxy idle timeouts on the silent HTTPattachrequest do not tear down a live WebSocket (packages/gui-plugins/src/browser/pane.ts).experimental.browser/tunnel.grantwith a per-origin pending-grant barrier for trusted desktop navigations on remote attachments (surfaces/browser/{mod,openers}.rs,rpc/tunnel.rs), skipped for legacy attachments and agent-driven commands.crates/browser-pane/src/client/mod.rs,apps/desktop/src/surfaces/browser/rpc/exec/{settle,nav}.rs):TabPromptState::documentfromTabSnapshot::documenton new tabs.navigationProgressDeadline(packages/gui-plugins/src/browser/navigation-deadline.ts): when the 15 s deadline expires on a navigation whose main document already committed while subresources keep streaming, returns the committed tab (loading: true) immediately instead of failing with a timeout; un-committed stalls preserve the timeout error and open tab.replacementNavigation(packages/gui-plugins/src/browser/navigation-turn.ts,chromium.ts): distinguishes superseded client redirects (ERR_ABORTEDwhile loading or after commit) from genuine no-commit aborts.Verification
45746653359on headc1360881ed: green (guardrails,build-macos,build-windows (x64),build-windows (arm64),build-linux (x64); Linux arm64 skipped).badd3ea1cdserver (OPENCODE_FLAGS=browser_stream_tunnel) with the Windows x64 PR build (3/3 passes, exit 0):tunnel.ws.v1) on 10 MiB + concurrent live WebSocket/echoprobe (http://127.0.0.1:5173/): negotiatedGET /api/experimental/browser/tunnel->HTTP/1.1 101 Switching Protocolswithtunnel.grantand 0 legacytunnel.{open,read,write}RPC calls; completedbytes=10485760inbulkMs=2883(2.88 s, 29.1 Mbps) withechoSamples=18,echoMedianMs=115.3 ms.http://127.0.0.1:5174/): whiteboard canvas, toolbar, and fonts rendered whole over the multiplexed binary WebSocket.OPENCODE_BROWSER_TUNNEL_TRANSPORT=legacy) on the same 10 MiB +/echoprobe: completedbytes=10485760inbulkMs=31040(31.04 s, 2.7 Mbps) withechoSamples=298,echoMedianMs=87.9 ms,echoP95Ms=244.4 ms(10.8x faster bulk throughput over binary WebSocket: 31.04 s -> 2.88 s, 2.7 -> 29.1 Mbps).scripts/guardrails.ps1) andbun scripts/web-clock.tspassed (0 violations).