Skip to content

feat(server): let agents save browser screenshots - #6387

Draft
adinschmidt wants to merge 1 commit into
pingdotgg:mainfrom
adinschmidt:feat/preview-screenshot-tool
Draft

feat(server): let agents save browser screenshots#6387
adinschmidt wants to merge 1 commit into
pingdotgg:mainfrom
adinschmidt:feat/preview-screenshot-tool

Conversation

@adinschmidt

@adinschmidt adinschmidt commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Agents can save a recording of a collaborative browser tab, but they have no way to save a still. preview_snapshot returns a downscaled PNG inline for the agent to look at, and the desktop camera button writes a file, but that capture was never exposed over MCP — so an agent that just wants to hand the user a still image has to record a video instead.

This adds a preview_screenshot tool that reuses the existing desktop capture and returns the saved artifact's path, mirroring preview_recording_stop:

preview_screenshot { tabId? } → { id, tabId, path, mimeType: "image/png", sizeBytes, createdAt }

Artifacts land in the same browser-artifacts directory as recordings and the camera button, so reveal and copy-path work unchanged.

The tool returns a path rather than image data on purpose: preview_snapshot already covers "let the agent see the page", and re-encoding a full-resolution PNG into the transcript on every capture would be a lot of tokens for an evidence artifact the human is meant to open.

"screenshot" joins PREVIEW_AUTOMATION_OPERATIONS but not the V1 list, so desktop hosts predating this change are filtered out by the broker and get a capability error rather than an operation they cannot serve.

One inherited constraint worth knowing: capture needs a composited tab. This calls the same webContents.capturePage() as preview_snapshot, which fails with UnknownVizError on a hidden guest — so a tab opened with open: false, or one whose thread is not routed in the desktop window, will not produce an artifact.

Verification

Against a dev desktop build, an agent called preview_screenshot after preview_open and reported sizeBytes: 57265, matching the artifact written to disk byte for byte. The image below is that artifact, unmodified — full resolution, not downscaled the way snapshot captures are.

Screenshot artifact saved by preview_screenshot

tsgo --noEmit is clean for contracts, server, and web; the preview toolkit and automation broker tests pass.

Model: Claude Opus 5, via Claude Code.

Note

Add preview_screenshot tool to let agents capture browser tab screenshots

  • Adds a new preview_screenshot MCP tool to PreviewToolkit and PreviewStandardToolkit that captures a full-resolution PNG of a targeted browser tab and returns a PreviewAutomationScreenshotArtifact with path, size, and timestamp.
  • Extends PreviewAutomationHost to handle the screenshot automation operation by calling bridge.captureScreenshot with the runtime tab id.
  • Adds the screenshot operation to PREVIEW_AUTOMATION_OPERATIONS and defines the PreviewAutomationScreenshotArtifact schema in previewAutomation.ts.

Macroscope summarized 63b662c.

Agents could save a recording of a collaborative browser tab but had no
way to save a still image. preview_snapshot returns a PNG inline for the
agent to look at, and the desktop camera button writes a file, but that
path was never exposed over MCP.

Add a preview_screenshot tool that reuses the existing desktop capture
and returns the saved artifact's path, so an agent can hand the user a
still the same way it hands over a recording.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c8488f6-467d-431c-93d7-0e54285bb198

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant