Skip to content

feat(#44): add --diff and --output flags to snapshot command#473

Open
giulio-leone wants to merge 2 commits intovercel-labs:mainfrom
giulio-leone:feat/44-incremental-snapshot
Open

feat(#44): add --diff and --output flags to snapshot command#473
giulio-leone wants to merge 2 commits intovercel-labs:mainfrom
giulio-leone:feat/44-incremental-snapshot

Conversation

@giulio-leone
Copy link
Contributor

Summary

Adds incremental snapshot (--diff) and save-to-file (--output) options to reduce context consumption.

Changes

  • --diff: Only returns lines that changed since the last snapshot (frequency-map comparison handles duplicate lines correctly)
  • --output <path>: Saves snapshot to file instead of returning full content
  • Previous snapshot captured before getSnapshot() to avoid race condition
  • Fully typed response (no as any casts)

Usage

agent-browser snapshot --diff        # Only show changes since last snapshot
agent-browser snapshot -o snap.txt   # Save to file
agent-browser snapshot -i --diff     # Incremental interactive snapshot

Closes #44

@vercel
Copy link
Contributor

vercel bot commented Feb 14, 2026

@giulio-leone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@ctate
Copy link
Collaborator

ctate commented Feb 16, 2026

Thanks for the contribution, @giulio-leone! Reducing context consumption is a real need for AI agents. I pulled the branch, rebuilt both TypeScript and Rust CLI, and tested E2E.

What works:

  • --diff returns (no changes) for identical snapshots
  • --diff shows added/removed lines after navigation
  • --output / -o saves snapshots to file

Issues to address:

  1. --diff + --output combined -- --diff silently wins and the file is never written. Should either combine them or error.

  2. --diff drops refs -- The diff code path early-returns without refs, so the agent can't interact with elements after a diff snapshot without a separate full snapshot. Undermines the token-saving goal.

  3. Diff algorithm loses positional context -- The frequency-map approach groups all removals first, then all additions, with no indication of where in the tree changes occurred. A positional diff would be much more useful for agents reasoning about page structure.

  4. Cross-mode lastSnapshot pollution -- lastSnapshot is shared daemon state regardless of snapshot options (-i, full, etc.). Alternating modes produces misleading diffs. Consider keying by options.

  5. Missing documentation -- Per project guidelines, user-facing features need updates to cli/src/output.rs, README.md, skills/agent-browser/SKILL.md, and docs/src/app/snapshots/page.mdx. None were updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support snapshot command return incremental snapshot info, also with saving to file option

2 participants