Skip to content

feat(types): add the extended Browser Run snapshot formats - #8676

Merged
harrishancock merged 2 commits into
cloudflare:mainfrom
BernardoPe:browser-run-snapshot-formats
Nov 23, 2026
Merged

harrishancock merged 2 commits into
cloudflare:mainfrom
BernardoPe:browser-run-snapshot-formats

Conversation

@BernardoPe

@BernardoPe BernardoPe commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The Browser Run /snapshot quick action now returns four more formats from a single page load: pdf, links, scrape, and json. The binding types still only allow content, screenshot, markdown, and accessibilityTree, so TypeScript rejects valid calls.

What changed

  • BrowserRunSnapshotFormat gains pdf, links, scrape, and json.
  • BrowserRunSnapshotOptions gains the options those formats use, reusing the per-action types (BrowserRunScrapeOptions['elements'], BrowserRunPDFOptions['pdfOptions'], BrowserRunLinksOptions['visibleLinksOnly' | 'excludeExternalLinks'], BrowserRunAccessibilityTreeOptions['interestingOnly' | 'root']) plus prompt/response_format and custom_ai from BrowserRunJsonBaseOptions, so the shapes cannot drift from the standalone actions.
  • BrowserRunSnapshotSuccessResponse gains pdf, links, scrape, and json.

elements and prompt/response_format stay optional and are documented as required only when formats requests the matching format, since the requirement depends on the array contents and cannot be expressed in the type.

Tests

  • Extended types/test/types/browser-run.ts: a snapshot call using all four new formats and their options, a response-shape check, and a @ts-expect-error proving the internal crawl format is still rejected.

Notes

  • generated-snapshot/ was updated by re-running the printer and prettier steps over the edited defines rather than just generate-types, since this checkout has no bazel build. The diff is confined to the Browser Run block, but CI's snapshot check is the authoritative confirmation.
  • Two pre-existing inaccuracies in these types are left untouched to keep this change scoped: accessibilityTree is declared non-nullable although the API returns null when root matches nothing, and scrape text/width/height are declared required although SVG elements omit them. Both are separate follow-ups.

@BernardoPe
BernardoPe requested review from a team as code owners November 19, 2026 15:53
@BernardoPe
BernardoPe requested a review from NuroDev November 19, 2026 15:53
@clanky-the-clanker

Copy link
Copy Markdown

This pull request was not reviewed automatically because its author does not have write access to this repository. A maintainer with write access can start a review by commenting clanky review (or clanker review or @clanky-the-clanker review), optionally followed by instructions (e.g. clanky review focus on the retry logic).

The `/snapshot` quick action now returns PDFs, links, scraped elements, and
AI-extracted JSON alongside HTML, screenshots, Markdown, and the accessibility
tree. Add the four formats to `BrowserRunSnapshotFormat` and the options each
one uses to `BrowserRunSnapshotOptions`, reusing the per-action option types so
the shapes cannot drift from the standalone actions.

`BrowserRunSnapshotSuccessResponse` gains `pdf`, `links`, `scrape`, and `json`.
Regenerate `generated-snapshot/` and cover the new formats and the internal
`crawl` format in the type tests.
@BernardoPe
BernardoPe force-pushed the browser-run-snapshot-formats branch from ee245e2 to e56a2ad Compare November 19, 2026 15:58
@jasnell
jasnell enabled auto-merge November 20, 2026 17:38
The extended snapshot formats were hand-edited into
types/generated-snapshot, so the snapshot kept two blank lines per
declaration boundary and the .ts copies declared
BrowserRunSnapshotOptions without `export`. `just generate-types` does
not emit either, which failed the check-snapshot job.

Apply the diff produced by the generator so the committed snapshot
matches bazel-bin/types/definitions.
auto-merge was automatically disabled November 21, 2026 03:47

Head branch was pushed to by a user without write access

@harrishancock
harrishancock merged commit c5730a8 into cloudflare:main Nov 23, 2026
32 of 33 checks passed
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.

4 participants