🤖 feat: auto-enable browser session streaming on bootstrap#3073
🤖 feat: auto-enable browser session streaming on bootstrap#3073
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1dfaa85c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Added streaming enablement failure patterns ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 468cb368e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Fixed: |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
CI Status UpdateThe only failing CI check is
Evidence this is pre-existing and unrelated:
This appears to be a CI environment issue that should be tracked separately. |
Summary
Auto-enable runtime
agent-browserstreaming formissing_streamsessions in the Browser tab, eliminating the dead-endAGENT_BROWSER_STREAM_PORTenv-var message.Background
When an
agent-browsersession is started withoutAGENT_BROWSER_STREAM_PORT, the Browser tab discovers it but shows a dead-end message telling the user to restart with the env var set. Theagent-browserCLI now supports runtime streaming commands (stream status,stream enable,stream disable), so Mux can enable streaming on demand instead of requiring a restart.Implementation
Backend (
AgentBrowserSessionDiscoveryService.ts,router.ts):ensureSessionAttachable()method that auto-enables streaming formissing_streamsessions at bootstrap timeagent-browser --json --session <name> stream status|enablewith defensive JSON parsinggetBootstraphandler to useensureSessionAttachableinstead ofgetSessionConnectionFrontend (
BrowserTab.tsx):getMissingStreamMessage()and themissing_streamdisconnect guardmissing_streamsessions now proceed togetBootstrapwhich triggers runtime enablementValidation
make typecheck✅make lint✅make static-check✅ (onlyhadolintmissing, unrelated)missing_streamsessions trigger connect and show activating copyDogfood evidence
Tested with a sandboxed dev server + real
agent-browsersession started withoutAGENT_BROWSER_STREAM_PORT:missing_streamsession📸 Dogfood screenshots
Browser tab with live preview after auto-enable:
The Browser tab shows "Live" badge with
mux-stream-smokesession rendering example.com. Session was started withoutAGENT_BROWSER_STREAM_PORT.Reconnection fast path:
After switching tabs and back, the bridge reconnected immediately showing "Live" badge.
Negative path — session killed:
After killing the session, the Browser tab shows "Waiting for browser preview" with a neutral message about auto-attaching when available.
Risks
status === "attachable") returns immediately without calling any CLI stream commands.stream statusandstream enableJSON output parsing is isolated behind narrow helpers, so upstream CLI changes are easy to adapt to.stream disableexposed: Intentionally omitted — no UX need identified.📋 Implementation Plan
Plan: integrate runtime
agent-browserstreaming into the right-hand Browser panelGoal
Make the RHS Browser tab auto-attach to a running
agent-browsersession even when that session was launched withoutAGENT_BROWSER_STREAM_PORT.Target behavior:
Verified context
src/browser/features/RightSidebar/BrowserTab/BrowserTab.tsxcurrently renders the env-var error viagetMissingStreamMessage(...).src/browser/features/RightSidebar/BrowserTab/useBrowserBridgeConnection.tscurrently short-circuits and disconnects when the selected discovered session status is"missing_stream".src/node/services/browser/AgentBrowserSessionDiscoveryService.tscurrently marks a workspace-matching session asmissing_streamwhen<session>.streamis absent, and reads the stream port from that file when present.src/node/orpc/router.tsandsrc/common/orpc/schemas/api.tscurrently exposebrowser.listSessionsandbrowser.getBootstrapfor the Browser tab flow.agent-browserCLI now advertises runtime streaming commands (stream enable [--port],stream disable,stream status), while the public README/docs still mostly describe the startup env-var path. Plan against the CLI/runtime behavior rather than the older docs.Recommended approaches
A. Auto-enable on bootstrap — recommended (product code net LoC: +80 to +130)
Use the existing discovery flow to list sessions, but change backend bootstrap so the selected session is made attachable on demand:
stream status,stream enablewith no--port,Why this is the plan of record:
B. Explicit “Enable preview” action in the Browser tab (product code net LoC: +120 to +190)
Keep
missing_streamas a blocked UI state and add a button that calls a new backend action to enable streaming before reconnecting.Why this is the fallback only:
Plan of record
Implement Approach A.
Expected touch points
src/node/services/browser/AgentBrowserSessionDiscoveryService.tssrc/node/orpc/router.tssrc/browser/features/RightSidebar/BrowserTab/useBrowserBridgeConnection.tssrc/browser/features/RightSidebar/BrowserTab/BrowserTab.tsxsrc/node/services/browser/AgentBrowserSessionDiscoveryService.test.tssrc/browser/features/RightSidebar/BrowserTab/BrowserTab.test.tsxsrc/browser/features/RightSidebar/BrowserTab/useBrowserBridgeConnection.test.tsx(if present; otherwise extend the closest Browser tab test coverage)Implementation phases
Phase 1 — backend: ensure runtime streaming before bridge bootstrap
Files:
src/node/services/browser/AgentBrowserSessionDiscoveryService.ts,src/node/orpc/router.tslistSessions()read-only and cheap. It should continue to discover sessions and classifymissing_streamwithout side effects.workspaceId,agent-browser --session <name> stream status --json,agent-browser --session <name> stream enable --jsonwithout--port,browser.getBootstrapto use that “ensure attachable” path instead of assumingmissing_streamis terminal.Defensive-programming requirements
enabled: truewith no port, malformed JSON, vanished session) as explicit failures with clear error messages.stream enablerather than assuming the returned data is sufficient.Phase 1 quality gate
stream status/stream enablepayloads,Phase 2 — frontend: stop treating
missing_streamas terminalFiles:
src/browser/features/RightSidebar/BrowserTab/useBrowserBridgeConnection.ts,src/browser/features/RightSidebar/BrowserTab/BrowserTab.tsxmissing_streamdisconnect gate fromuseBrowserBridgeConnection.tsso selecting a discovered session still attemptsbrowser.getBootstrap.BrowserTab.tsxwith a neutral state machine:missing_streamtoattachableon the next render."Needs streaming") if it becomes misleading once streaming can be started lazily; either rename it to something neutral or remove it once the refresh settles.Phase 2 quality gate
missing_streamsession no longer dead-ends,Phase 3 — hardening and repo-level validation
AGENT_BROWSER_STREAM_PORTnow attaches on first selection.stream statusreports an unexpected shape,make typecheck,make lint(or the repo’s preferred targeted lint equivalent for touched files).Acceptance criteria
AGENT_BROWSER_STREAM_PORTno longer lands on the dead-end env-var message.Dogfooding / reviewer evidence
Setup
make dev.agent-browsersession withoutAGENT_BROWSER_STREAM_PORT, for example:agent-browser --session mux-stream-smoke open https://example.comDogfood flow
agent-browsersession.Reviewer artifacts
Capture and attach all of the following:
Negative-path dogfood
Tradeoffs and rationale
stream disableis not required for this user request; do not expose it in Mux unless a concrete UX need appears.Generated with
mux• Model:anthropic:claude-opus-4-6• Thinking:xhigh• Cost:$7.27