Add runtime stream enable/disable/status commands#951
Add runtime stream enable/disable/status commands#951ctate merged 4 commits intovercel-labs:mainfrom
Conversation
|
@ThomasK33 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
ctate
left a comment
There was a problem hiding this comment.
Thanks for this contribution! I found two issues to address before merging:
handle_stream_disableunconditionally resetsstate.screencasting = false, which can orphan a user-initiated screencast that was started independently. Consider only resetting this if the stream server was responsible for starting it, or leaving it untouched entirely.- In
handle_stream_disable, ifremove_stream_filefails, the?early-return leavesstream_server/stream_clientasSomepointing at a dead server. The state cleanup should be unconditional.
|
Hey Chris, thanks for the quick turnaround on the review. I resolved both issues by having |
af087cf to
7c5ac85
Compare
|
Thanks @ThomasK33 - looks like the only thing that needs to be addressed is a failure for cargo fmt. Everything else is solid. |
|
Thanks @ctate, somehow missed it 😅 |
7c5ac85 to
8dc0ce0
Compare
8dc0ce0 to
dbf5726
Compare
dbf5726 to
8ab885b
Compare
|
Looks great - thanks @ThomasK33 |
* Add runtime stream management commands * Run rustfmt and satisfy clippy * Fix stream disable cleanup semantics * Format stream disable regression tests
* dashboard * fix: re-apply download behavior on recording context (#1019) * fix: re-apply download behavior on recording context record start creates a new browser context via Target.createBrowserContext. Browser.setDownloadBehavior called at launch only applies to the default context, so downloads in the recording context are silently dropped. Fix: 1. Store download_path on BrowserManager (from LaunchOptions) 2. After creating the recording context, call Browser.setDownloadBehavior with the new browserContextId This ensures downloads work during recording. Fixes #1018 * fix: add download_path to third BrowserManager constructor (auto_connect_cdp) * fix: reap zombie Chrome process and fast-detect crash for auto-restart (#1023) When Chrome crashes (e.g. SIGTRAP from CHECK() assertion), the daemon now: 1. Reaps the zombie immediately via a SIGCHLD handler in the event loop that calls waitpid(-1, WNOHANG) 2. Detects the crash instantly on the next command via a non-blocking try_wait() check (has_process_exited), avoiding the 3-second CDP timeout that is_connection_alive() would incur 3. Auto-relaunches Chrome transparently for the caller Fixes #1017 Co-authored-by: ctate <366502+ctate@users.noreply.github.com> * fix: route keyboard type through text input (#1014) * fix: handle --clear flag in console command (#1015) The console and errors commands parsed --clear from CLI args but the action handlers silently ignored the flag. The handlers did not accept the cmd parameter so they had no way to read the clear field. Changes: - Add clear_console() method to EventTracker in network.rs - Update handle_console to accept cmd, read the clear field, and clear the buffer when --clear is passed (returns {cleared: true}) - Update call site in execute_command to pass cmd Co-authored-by: xuyongliang <yongliang.xyl@alibaba-inc.com> * chore: patch release - ### Bug Fixes - **Re-apply download behavior on r... (#1025) * Add runtime stream enable/disable/status commands (#951) * Add runtime stream management commands * Run rustfmt and satisfy clippy * Fix stream disable cleanup semantics * Format stream disable regression tests * fix: retain radio/checkbox elements in compact snapshot tree (#1008) compact_tree() checked for "[ref=" to identify lines worth keeping, but radio and checkbox elements render as e.g. [checked=false, ref=e1] where the "[" opens before "checked=", not "ref=". Dropping the leading bracket so the check is just "ref=" fixes the match for all elements with refs. Fixes #1006 Co-authored-by: ctate <366502+ctate@users.noreply.github.com> * chore: version packages (#1027) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fixes * dashboard * fixes * remove observe * fmt * fixes * fixes * jotai * fmt * upload dashboard --------- Co-authored-by: Stefan Smiljkovic <stefan@vanila.io> Co-authored-by: ctate <366502+ctate@users.noreply.github.com> Co-authored-by: zhanba <c5e1856@gmail.com> Co-authored-by: xuyongliang <478439790@qq.com> Co-authored-by: xuyongliang <yongliang.xyl@alibaba-inc.com> Co-authored-by: Thomas Kosiewski <thoma471@googlemail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
stream enable,stream status, andstream disablecommands for already-running daemon sessions.streammetadata handling, and explicit shutdown behaviorValidation
cd cli && cargo test stream_ -- --nocapturecd cli && cargo test e2e_runtime_stream_enable_before_launch_attaches_and_disables -- --ignored --test-threads=1cd cli && cargo test📋 Implementation Plan
Implementation Plan: Runtime stream enablement for an already-running session
Goal
Add a supported runtime path to enable WebSocket streaming on an already-running
agent-browserdaemon/session without requiring a daemon restart, plus companion status/disable flows so the lifecycle is inspectable and reversible.Verified repo context
AGENT_BROWSER_STREAM_PORTincli/src/native/daemon.rs.DaemonStatealready models streaming as optional runtime state viastream_clientandstream_server, andupdate_stream_client()already re-wires the browser/client relationship when the browser launches or closes incli/src/native/actions.rs.cli/src/native/stream.rsalready supports starting a stream server with or without an attached CDP client viaStreamServer::start()andStreamServer::start_without_client().screencast_start/screencast_stop, but those only control frame production; they do not create the WebSocket server..streamfile management currently lives in daemon startup/shutdown code.Implementation constraints inferred from the current code
.streamfile lifecycle must stay accurate for discovery scripts and existing tooling.Arcdrops alone if the currentStreamServerlifecycle is ambiguous.Proposed product surface
User-facing CLI
Add a
streamcommand group:agent-browser stream enable [--port <port>]agent-browser stream disableagent-browser stream statusUnderlying daemon actions
stream_enablestream_disablestream_statusRecommended response shape
stream_enable→{ enabled: true, port, connected, screencasting }stream_disable→{ disabled: true }stream_status→{ enabled, port: number|null, connected, screencasting }Port behavior
Prefer allowing omitted/auto-assigned ports for the runtime command, because
StreamServeralready returns the actual bound port. If that adds unnecessary CLI complexity, MVP can require an explicit port and defer auto-assignment to a follow-up.Workstream 1: Runtime daemon lifecycle
Files / symbols
cli/src/native/actions.rscli/src/native/stream.rscli/src/native/daemon.rs(reference/consistency, likely light or no edits)cli/src/connection.rsor a small helper extraction)Changes
Add runtime handlers in
cli/src/native/actions.rshandle_stream_enable(cmd, state)handle_stream_disable(state)handle_stream_status(state)execute_command().Implement
handle_stream_enableStreamServerat runtime usingStreamServer::start_without_client(...).stream_serverandstream_clientinDaemonState.state.update_stream_client().awaitso an already-running browser is attached immediately..streamfile with the actual bound port.Implement
handle_stream_disablestate.stream_serverandstate.stream_client..streamfile.Implement
handle_stream_statusAdd deterministic stream shutdown support if needed
StreamServerdoes not already guarantee clean task teardown on drop, add an explicit shutdown mechanism incli/src/native/stream.rsand use it fromhandle_stream_disable.Defensive-programming expectations
stream_server/stream_clientpairing..streamwrite/remove errors where user-visible correctness depends on them.Quality gate after Workstream 1
Workstream 2: CLI wiring and help output
Files / symbols
cli/src/commands.rsand/orcli/src/main.rs(depending on current parser split)cli/src/output.rsChanges
--jsonsupport and machine-readable output examples.cli/src/output.rs:Quality gate after Workstream 2
agent-browser stream enable,disable, andstatusparse correctly.Workstream 3: Tests
Files / symbols
cli/src/native/e2e_tests.rsMinimum test matrix
AGENT_BROWSER_STREAM_PORT.stream statusreports disabled before enable, then enabled with the bound port after enable..streamfile and updates status.Validation commands
If the full ignored e2e suite is too slow during iteration, run a focused subset first, but finish with the full required validation before claiming success.
Workstream 4: Documentation and agent-facing docs
Required documentation updates for this user-facing feature
Per repo guidance, update all of the following:
cli/src/output.rsREADME.mdskills/agent-browser/SKILL.mddocs/src/app/streaming/page.mdxdocs/src/app/commands/page.mdxAdditional docs to consider
docs/src/app/configuration/page.mdxto clarify the difference between startup env-var streaming and runtime CLI streaming.Documentation content to add
stream enableandscreencast_start.--session.Quality gate after Workstream 4
Dogfooding and review evidence
Setup
AGENT_BROWSER_STREAM_PORTso the new runtime path is exercised.Dogfooding flow
agent-browser --session <name> stream statusand verify it reports disabled.agent-browser --session <name> stream enable [--port ...].agent-browser --session <name> stream disable..streamis gone, andstream statusreports disabled.Required evidence artifacts
Capture all of the following during implementation review:
If implementation happens in an environment that supports generated artifacts, attach the screenshots and video to the work report so a reviewer can verify the behavior without replaying the steps manually.
Risks and decisions to resolve during implementation
Command naming
streamcommand group.Auto-port behavior
Disable semantics
Shutdown mechanics
StreamServeris sufficient; if not, add explicit shutdown for deterministic cleanup.Acceptance criteria
AGENT_BROWSER_STREAM_PORTcan enable streaming at runtime without restarting the daemon..stream.stream statusaccurately reports enabled state, port, browser connectivity, and screencasting status.stream disabletears down runtime streaming cleanly and removes.stream.Generated with
mux• Model:openai:gpt-5.4• Thinking:high