v1.18.0.0 fix(browse): screenshot defaults to viewport, add --full-page#1225
Open
gregario wants to merge 4 commits intogarrytan:mainfrom
Open
v1.18.0.0 fix(browse): screenshot defaults to viewport, add --full-page#1225gregario wants to merge 4 commits intogarrytan:mainfrom
gregario wants to merge 4 commits intogarrytan:mainfrom
Conversation
Fixes garrytan#1214. `browse screenshot` defaulted to `fullPage: true`, so any page taller than ~2000px scroll height produced a PNG that exceeded the Anthropic vision API's per-side limit. The failed image stayed in conversation history, poisoning every subsequent turn — the entire session bricked, not just one tool call. Three changes, kept narrow: 1. Flip the default. Bare `screenshot` captures the visible viewport. Matches Playwright's own `page.screenshot()` default of `fullPage:false`. 2. Add `--full-page` opt-in for callers who really want the whole scroll height. When used, the result is checked against an ~1800px ceiling (Anthropic vision limit with headroom) and emits a one-line `[browse]` warning to stderr if exceeded — agents see the boundary instead of silently producing poison images. 3. Keep `--viewport` as a back-compat no-op alias. Existing scripts that passed `--viewport` continue to work and still produce viewport-only captures (now the default). The output message no longer carries the `(viewport)` suffix because viewport IS the default — only `--full-page` gets a suffix. Annotated/heatmap modes in snapshot.ts keep `fullPage: true` — those are debug UI for humans, not images fed to agents via `Read`. Tests: - regression: tall.html (~3000px scroll) with bare `screenshot` produces a PNG ≤ 800px tall (viewport) - `--full-page` on the same page produces > 2000px - `--full-page` on tall page emits the oversize warning - `--full-page + --clip` and `--full-page + selector` reject mutually- exclusive flag combinations - `--viewport + --clip` is now a no-op + clip (back-compat: was an error) PNG dimensions are read from the IHDR chunk (zero deps, ~10 lines). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Queue advanced past v1.15.x while this branch was open. v1.15.0.0 landed on main (garrytan#1215) and garrytan#1233/garrytan#1234 claimed v1.15.1.0/v1.16.0.0 in the queue, so the next free PATCH slot is v1.16.1.0. Also regenerates SKILL.md / browse/SKILL.md to match the screenshot --full-page additions, fixing the check-freshness CI failure. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Fixes #1214 —
browse screenshotdefaulted tofullPage: true, so any page taller than ~2000px scroll height produced a PNG that exceeded the Anthropic vision API's per-side limit. Once a poison image landed in conversation history, every subsequent turn re-failed on the same envelope. Whole session bricked, not just one tool call.Before
After
Changes
screenshotcaptures the visible viewport. Matches Playwright's ownpage.screenshot()default offullPage: false.--full-pageopt-in. When used, the result is checked against an ~1800px ceiling (vision-API limit with headroom) and emits a one-line[browse]warning to stderr — agents see the boundary instead of silently shipping poison.--viewportas a back-compat no-op alias. Existing scripts that passed--viewportkeep working; the output message just no longer carries(viewport)since viewport IS the default — only--full-pagegets a(full-page)suffix.Annotated/heatmap snapshot modes still default to fullPage — those are debug UI for humans, not images fed to agents via
Read.This goes with the issue author's vote: option 1 (post-capture warn) plus option 2 (flip the default). "Search before recommending" rubric: Playwright's API was already shipping the right default — gstack just wasn't matching it.
Test plan
bun test browse/test/commands.test.ts— 228 pass (8 cases changed/added)tall.html(~3000px) with barescreenshotproduces PNG ≤ 800px tall (viewport)--full-pageon the same page produces > 2000px--full-pageon tall page emits the oversize warning (captured viaconsole.warnpatch)--full-page + --clipand--full-page + selectorreject mutually-exclusive flag combos--viewport + --clipis now a no-op + clip (back-compat: was an error before; fine because clip is what runs)bun test(full free suite) — greenMigration note
If any caller depended on the literal output
\"Screenshot saved (viewport)\", that string changed to\"Screenshot saved\"(since viewport is now the default and not a special case). Only one test in this repo grepped for that exact string; no production callers found ingrep -rn.Files
browse/src/meta-commands.ts— flag parsing + IHDR reader + warnIfOversize helperbrowse/src/commands.ts— usage docstringbrowse/test/commands.test.ts— 5 new tests, 1 updated, 1 inverted (back-compat)browse/test/fixtures/tall.html— new ~3000px fixtureVERSION,CHANGELOG.md— release v1.15.2.0🤖 Generated with Claude Code