-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Labels
fleetFleet-managed issueFleet-managed issue
Description
Bug
Project.generate() and Screen.edit() crash with:
TypeError: Cannot read properties of undefined (reading 'screens')
Cause
The SDK hardcodes outputComponents[0].design.screens[0] to extract screen data from the API response. The Stitch API now returns designSystem at outputComponents[0] and the actual screen data at outputComponents[1]:
outputComponents[0] → { designSystem: { ... } } // no .design property
outputComponents[1] → { design: { screens: [...] } } // actual screen
outputComponents[2] → { text: "..." }
outputComponents[3..] → { suggestion: "..." }
This affects both generate_screen_from_text and edit_screens response handling.
Affected code
domain-map.json: projection{ "prop": "outputComponents", "index": 0 }- Generated
project.tsline 40:raw.outputComponents[0].design.screens[0] - Generated
screen.tsline 41:raw.outputComponents[0].design.screens[0]
Proposed fix
Replace the brittle index-based lookup with property-based lookup:
- Add
findtoProjectionStepIR schema - Emit
.find((c) => c.design)instead of[0]
This makes the projection resilient to API response ordering changes.
Reproduction
const project = stitch.project("any-project-id");
const screen = await project.generate("A simple card");
// → TypeError: Cannot read properties of undefined (reading 'screens')Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fleetFleet-managed issueFleet-managed issue