Skip to content

feat(sdk): accept deviceType on screen uploads - #384

Open
saariuslystoned wants to merge 1 commit into
google-labs-code:mainfrom
saariuslystoned:feat/upload-device-type
Open

saariuslystoned wants to merge 1 commit into
google-labs-code:mainfrom
saariuslystoned:feat/upload-device-type

Conversation

@saariuslystoned

Copy link
Copy Markdown

Refs #383.

Problem

Screens uploaded as HTML have no device type, and Project.upload() has no option to set one. In the runs reported in #383, 6 of the 8 placeholder frames that Stitch's canvas created for variants of such screens were 390 px (phone) wide, showing the generated desktop designs at phone width. A page uploaded through screens:batchCreate with "deviceType": "DESKTOP" got a correct 1280 px frame. BatchCreateScreens already accepts and stores the field.

Change

  • UploadInputSchema: new optional deviceType, one of MOBILE, DESKTOP, TABLET or AGNOSTIC, the same values as the generation tools' device type. DEVICE_TYPE_UNSPECIFIED is left out, matching the README's DeviceType; leaving the option unset covers that case.
  • buildBatchCreateScreensBody: sets screen.deviceType when the option is given. Without it, the request body is unchanged.
  • stitch-sdk-usage skill: adds the option to the upload options table.
const [screen] = await project.upload("./home.html", { deviceType: "DESKTOP" });

This PR says Refs, not Fixes: #383 also reports that placeholder frames stay labelled "Generating Screen..." after the generation finishes, whatever the device type. That part is in the Stitch canvas, not the SDK.

The stitch upload screen CLI could expose this as a --device option. Its source isn't in this repo.

Tests

upload.test.ts:

  • project.upload(path, { deviceType: "DESKTOP" }) sends deviceType: "DESKTOP" on the screen. Fails on main.
  • Without the option, the uploaded screen has no deviceType key.
  • UploadInputSchema rejects deviceType: "PHONE". Fails on main, where the schema strips the unknown key.

Results with Bun 1.3.1 (all tests mock the client; no live calls):

  • npm run test: 365 passed (362 on main)
  • typecheck, build, test:scripts, validate:generated, check:skills, test:coverage, test:smoke, check:bundle, check:consumer-types, check:examples and publish:readiness all pass.
  • npm run lint runs no tasks, because no package defines a lint script.
  • format:check flags only bridge-0.4.0-premortem.test.ts and schema-repair.test.ts. This PR doesn't touch them, and they fail the same way on main.

🤖 Generated with Claude Code

Screens uploaded as HTML have no device type, and Project.upload had no
way to set one. Stitch's canvas then gives variants generated from such
a screen phone-width placeholder frames (6 of 8 in the runs reported in
google-labs-code#383), while a page uploaded with deviceType DESKTOP got a correct
1280 px frame. BatchCreateScreens already accepts and stores the field.

- UploadInputSchema: optional deviceType, one of MOBILE, DESKTOP, TABLET
  or AGNOSTIC, the same values as the generation tools' device type.
- buildBatchCreateScreensBody: set screen.deviceType when it is given.
  Without it, the request body is unchanged.
- Tests: deviceType is sent when set, omitted when unset, and an invalid
  value is rejected.
- Document the option in the stitch-sdk-usage skill.

Refs google-labs-code#383
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