feat: add --follow flag to console and errors commands#867
feat: add --follow flag to console and errors commands#867mvanhorn wants to merge 4 commits intovercel-labs:mainfrom
Conversation
Add real-time log streaming to the console and errors commands via --follow (-f). Polls the daemon's EventTracker at 500ms intervals, printing only new entries since the last poll. Supports both text mode ([level] text) and JSON mode (one JSON object per line). Runs until Ctrl+C or the daemon disconnects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
The console log display code used "messages" and "type" to access console entries, but the daemon's EventTracker returns "entries" and "level". This meant console logs were never displayed in either follow mode or normal output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…d --follow code Addresses @ctate's review: 1. Moved network_wait text output check above the generic URL handler in output.rs so "Matched: POST /api/login -> 200 (xhr)" displays correctly instead of being caught by the navigation response handler. 2. Removed --follow flag parsing and docs from this PR - that belongs in the separate console --follow PR (vercel-labs#867). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ctate
left a comment
There was a problem hiding this comment.
Thanks for putting this together! The follow mode is a nice addition — polling the existing EventTracker keeps things simple and avoids touching the daemon protocol.
One issue to fix before merging: -f is already the global short flag for --full (full-page screenshots). Since global flags are parsed first, agent-browser console -f would silently set full=true instead of enabling follow mode. I'd suggest dropping the -f alias and keeping only --follow, or picking a different short flag like -F.
A couple smaller things:
- The
last_seenindex tracking inrun_console_followusesentries/levelkeys butrun_errors_followuseserrors/text— just want to confirm these match the actual daemon response shape (the output.rs fix in this PR changesmessages→entriesandtype→level, so it looks like the daemon response was recently updated). - If the daemon disconnects or returns an error, the loop retries silently every 500ms forever — might be worth printing a message or backing off after repeated failures.
|
Actually - one sec. Moving --full down in #876. |
Move --full/-f from global flags (parsed in flags.rs) to command-level parsing in commands.rs, scoped to the three commands that actually use it: `screenshot`, `diff screenshot`, and `diff url`. This frees up `-f` for other commands (e.g. `--follow` on `console`/`errors`, see #867) and better reflects that full-page capture is not a global concern. Changes: - Remove `full` from Flags struct, Config struct, and global flag parsing - Remove `--full`/`-f` from clean_args global boolean flags list - Parse `--full`/`-f` inline in `screenshot` command handler - Accept `-f` shorthand in `diff screenshot` and `diff url` (previously only `--full` was accepted at command level) - Remove fallback from global `flags.full` in diff subcommands - Update tests to pass --full as a command argument rather than a global flag Fixes #876
Removes -f as a short flag for --follow on console/errors commands since -f is already the global shorthand for --full (full-page screenshots). Only --follow is supported now. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Removed |
* refactor: make --full/-f a command-level flag instead of global Move --full/-f from global flags (parsed in flags.rs) to command-level parsing in commands.rs, scoped to the three commands that actually use it: `screenshot`, `diff screenshot`, and `diff url`. This frees up `-f` for other commands (e.g. `--follow` on `console`/`errors`, see #867) and better reflects that full-page capture is not a global concern. Changes: - Remove `full` from Flags struct, Config struct, and global flag parsing - Remove `--full`/`-f` from clean_args global boolean flags list - Parse `--full`/`-f` inline in `screenshot` command handler - Accept `-f` shorthand in `diff screenshot` and `diff url` (previously only `--full` was accepted at command level) - Remove fallback from global `flags.full` in diff subcommands - Update tests to pass --full as a command argument rather than a global flag Fixes #876 * fix: remove stale AGENT_BROWSER_FULL env var from help and add -f shorthand tests - Remove AGENT_BROWSER_FULL from help text in output.rs since the env var is no longer read after moving --full to command-level parsing - Add test_screenshot_full_page_shorthand to verify screenshot -f works - Add test_diff_screenshot_command_full_flag_shorthand to verify diff screenshot -f works --------- Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
|
@mvanhorn Sorry for the back and forth. |
Per @ctate's vercel-labs#876, --full is now scoped to screenshot only, so -f is free for --follow on console/errors commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
--follow(-f) flag to theconsoleanderrorscommands for real-time log streamingEventTrackerat 500ms intervals, printing only new entries since the last poll[level] textfor console,text (url:line:col)for errors) and JSON mode (one JSON object per line, NDJSON)Evidence
Usage
Technical notes
The implementation uses a poll-based approach rather than WebSocket streaming. The CLI sends the existing
console/errorscommand to the daemon in a loop, tracking alast_seenindex to print only new entries. The daemon'sEventTrackeruses an append-only model so index tracking is straightforward. This avoids modifying the daemon's streaming protocol while still delivering a good developer experience.If demand exists for sub-500ms latency, WebSocket-based push can be added later as a follow-up.
Checklist
cargo fmt- cleancargo clippy- cleancargo test- 461 passed, 0 failedThis contribution was developed with AI assistance (Claude Code).