Skip to content

computer: Take the browser module's example screenshot as JPEG - #337

Open
ben-reitz wants to merge 1 commit into
mainfrom
browser/screenshot-jpeg
Open

ben-reitz wants to merge 1 commit into
mainfrom
browser/screenshot-jpeg

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Models copy the screenshot example in codemode:browser's description. The example passes no format, so they take a PNG, and a PNG of a whole window is often over the 1 MiB one call can return. In one session a 1440x900 page came to 1.6 MB: the agent's first screenshot failed, and it only got one after retrying as a JPEG.

The example now takes a JPEG, asks for a .jpg file name, and says why:

 const { data } = await browser.cdp({
   method: "Page.captureScreenshot",
+  params: { format: "jpeg", quality: 80 },
   sessionId: "active",
 });

The limits and the error for an oversized result are unchanged, so a screenshot that is still too large fails with the same message as before. Quality 80 is a starting point: it has not been measured against very large windows.

A test in browser.test.ts checks the new text, and the sentence about screenshots in docs/17_isolate_javascript.md now matches it. A patch changeset is included.


Devin Review

The rules `codemode:browser` adds to its description show how to save
a screenshot with `Page.captureScreenshot`, with no format, so models
that copy it take a PNG. A PNG of a 1440x900 window can come to 1.6
MB, over the 1 MiB one host call can return, and the call fails.

Pass `params: { format: "jpeg", quality: 80 }` in the example, ask
for a `.jpg` file name, and say why in the rule.
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ecb3567

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@cloudflare/computer Patch
@cloudflare/dofs Patch
@cloudflare/computer-rpc Patch
@cloudflare/computerd Patch
@cloudflare/remote-exec Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@337

commit: ecb3567

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.

1 participant