Repository navigation
feat(sdk): accept deviceType on screen uploads - #384
Open
saariuslystoned wants to merge 1 commit into
Open
saariuslystoned wants to merge 1 commit into
saariuslystoned wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 throughscreens:batchCreatewith"deviceType": "DESKTOP"got a correct 1280 px frame.BatchCreateScreensalready accepts and stores the field.Change
UploadInputSchema: new optionaldeviceType, one ofMOBILE,DESKTOP,TABLETorAGNOSTIC, the same values as the generation tools' device type.DEVICE_TYPE_UNSPECIFIEDis left out, matching the README'sDeviceType; leaving the option unset covers that case.buildBatchCreateScreensBody: setsscreen.deviceTypewhen the option is given. Without it, the request body is unchanged.stitch-sdk-usageskill: adds the option to the upload options table.This PR says
Refs, notFixes: #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 screenCLI could expose this as a--deviceoption. Its source isn't in this repo.Tests
upload.test.ts:project.upload(path, { deviceType: "DESKTOP" })sendsdeviceType: "DESKTOP"on the screen. Fails onmain.deviceTypekey.UploadInputSchemarejectsdeviceType: "PHONE". Fails onmain, 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 onmain)typecheck,build,test:scripts,validate:generated,check:skills,test:coverage,test:smoke,check:bundle,check:consumer-types,check:examplesandpublish:readinessall pass.npm run lintruns no tasks, because no package defines alintscript.format:checkflags onlybridge-0.4.0-premortem.test.tsandschema-repair.test.ts. This PR doesn't touch them, and they fail the same way onmain.🤖 Generated with Claude Code