Repository navigation
Fix: generator reads new layout format — live, factory, logs get correct widgets - #598
Conversation
…s all get correct widget Generator only read layout.main (old format). Recipes using layout.widgets array (live, factory, canvas, logs) all mapped to chat-widget. Now extracts center-position widget from new format, falls back to old format.
There was a problem hiding this comment.
Pull request overview
Updates the content type generator so generated ContentTypes widget mappings correctly reflect recipes using the newer layout.widgets[] schema (instead of always falling back to chat-widget).
Changes:
- Extend
RecipeFile.layouttyping to include the newwidgets[]layout format. - Add
getMainWidget()helper to extract the primary/center widget from either layout format. - Use
getMainWidget()when generatingContentTypeConfig.widget.
Comments suppressed due to low confidence (1)
src/generator/generate-content-types.ts:101
hasRightPanelis still derived fromlayout.right, which is undefined for recipes using the newlayout.widgets[]format. This will incorrectly mark right panels as absent for new-format recipes that include a right-position widget (e.g. canvas/logs/settings/theme), andgetRightPanelConfig()will return null instead of the default help panel when the recipe service isn't loaded. Update the generator to detect right-panel intent fromlayout.widgets(andlayout.panels?.right?.visible === falsewhen present), while keeping the oldlayout.righthandling.
const widget = getMainWidget(r);
const displayName = r.displayName || r.name || r.uniqueId;
const icon = ICON_MAP[r.uniqueId] || '📄';
const hasRightPanel = r.layout?.right !== null && r.layout?.right !== undefined;
const entityType = r.entityType || null;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // New format: widgets array with position | ||
| widgets?: Array<{ widget: string; position: string; order: number }>; | ||
| }; |
There was a problem hiding this comment.
For layout.widgets, position is typed as string, but elsewhere in the codebase it's treated as a fixed set ('left' | 'center' | 'right'). Narrowing this type (or reusing the existing WidgetPosition type) would prevent silent mis-generation if a recipe typo slips in.
| const center = layout.widgets.find(w => w.position === 'center'); | ||
| if (center) return center.widget; | ||
| // Fall back to first widget if no center specified | ||
| if (layout.widgets.length > 0) return layout.widgets[0].widget; |
There was a problem hiding this comment.
In the new layout format, this selects the first position === 'center' widget based on array order, but runtime selection sorts by order and takes the first (see RecipeLayoutService.getWidget()). To keep generated config consistent with runtime behavior, filter to center widgets, sort by order, then pick the first; also consider dropping the fallback to layout.widgets[0] (it could be a left/right widget).
| const center = layout.widgets.find(w => w.position === 'center'); | |
| if (center) return center.widget; | |
| // Fall back to first widget if no center specified | |
| if (layout.widgets.length > 0) return layout.widgets[0].widget; | |
| const centerWidgets = layout.widgets | |
| .filter(w => w.position === 'center') | |
| .slice() | |
| .sort((a, b) => a.order - b.order); | |
| if (centerWidgets.length > 0) { | |
| return centerWidgets[0].widget; | |
| } |
Root Cause Found
The content type generator only read
layout.main[](old format). Recipes usinglayout.widgets[](new format) — live, factory, canvas, logs — all mapped tochat-widgetin the generated config. This is why live mode showed general chat.Combined with the race condition fix in #597, this fully resolves content routing for all content types.
Fix
getMainWidget()helper reads both formats: newwidgets[]array (finds center-position widget) and oldmain[]array.Verified
Test