Skip to content

Remove screenshot type from protocol results - #2754

Open
monadoid wants to merge 4 commits into
protocol-pipeline-checksfrom
screenshot-type-fix
Open

Remove screenshot type from protocol results#2754
monadoid wants to merge 4 commits into
protocol-pipeline-checksfrom
screenshot-type-fix

Conversation

@monadoid

@monadoid monadoid commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Before: page.screenshot returned { data, type } over RPC even though Chrome only returns the image data and every SDK’s screenshot API returns decoded bytes.

    • Now: the protocol result contains only data, while the existing type input still selects PNG or JPEG.
  • Before: generated Python and Go wire models included the unused result field.

    • Now: the generated schema, SDK models, tests, and embedded extension all reflect the data-only result.

Breaking change

  • Removes PageScreenshotResult.Type and the associated result-type constants from the Go SDK.
    • Page.Screenshot(...) ([]byte, error) is unchanged.
    • The public TypeScript and Python screenshot APIs are unchanged.

Summary by cubic

Removes the type field from page.screenshot results; results were { data, type }, now { data }. This tightens the protocol and removes unused SDK surface without changing request options or public screenshot APIs.

  • Protocol: Dropped type from PageScreenshotResult in packages/protocol/schemas.ts and packages/protocol/stagehand.v4.json; tests now assert type is invalid.
  • Runtime: packages/extension/runtime.ts no longer returns type in the screenshot result.
  • SDKs: Removed type and related enums from packages/sdk-go and generated typing from packages/sdk-python; updated tests and the embedded extension asset in packages/sdk-go.
  • Pipeline checks: Removed the page.screenshot.type exemption in rules/ast-grep/sdk-field-pipeline.test.ts so result fields must be used or removed.

Migration

  • Stop reading result.type in all callers.
  • Infer format from your request (options.type) or by inspecting decoded bytes.
  • Update to the regenerated SDKs in packages/sdk-go and packages/sdk-python.

Written for commit 678eacf. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 678eacf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@monadoid
monadoid marked this pull request as ready for review August 17, 2026 13:50

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 11 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant SDK as SDK (TS/Python/Go)
    participant Client as Protocol Client
    participant Runtime as Stagehand Runtime
    participant Browser as Browser
    participant GoSDK as Go SDK

    Note over SDK, Browser: CHANGED: Screenshot Result Shape (data only)

    SDK->>Client: page.screenshot(options)
    Note over SDK: options.type (png/jpeg) still sent as input
    Client->>Runtime: RPC page.screenshot(ref, options)
    Runtime->>Browser: page.screenshot(options)
    Browser-->>Runtime: raw image bytes
    Runtime->>Runtime: base64 encode bytes
    Runtime-->>Client: CHANGED: { data: base64Image }
    Client-->>SDK: CHANGED: result (data only)

    alt SDK validates result type
        SDK->>SDK: CHANGED: schema parse - Type field removed
        Note over SDK: Rejects extra type field
    end

    Note over Runtime: CHANGED: Returns bytesToBase64 without type
    Note over SDK: Callers determine format from request option or byte inspection

    Note over GoSDK: CHANGED: Go model - PageScreenshotResultType removed
    Note over GoSDK: CHANGED: Page.Screenshot() returns []byte (unchanged API)

    Note over SDK, Browser: Failure path: malformed base64 data
    Runtime-->>Client: { data: malformedString }
    Client-->>SDK: parse error
    SDK-->>SDK: return error to caller
Loading

Re-trigger cubic

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