Repository navigation
Kill FALLBACK_REGISTRY — generate content types from recipes - #567
Conversation
The 18-entry hardcoded FALLBACK_REGISTRY in ContentTypeRegistry.ts is dead.
Content types are now generated from the 27 recipe JSON files on disk.
New: generator/generate-content-types.ts
- Reads all system/recipes/*.json
- Generates shared/generated/ContentTypes.ts with:
- ContentType union type (27 types from recipes)
- CONTENT_TYPES runtime array (for validation)
- CONTENT_TYPE_CONFIGS map (widget, icon, path, requiresEntity)
- isContentType() type guard
- getContentTypeIcon() function
- Run: npx tsx generator/generate-content-types.ts
Changed: ContentTypeRegistry.ts
- Removed 190-line FALLBACK_REGISTRY
- Removed debug console.logs
- Uses generated CONTENT_TYPE_CONFIGS as compile-time fallback
- RecipeLayoutService still primary runtime source
- Unknown content types log error (no silent fallback to chat)
Changed: UserStateEntity.ts
- ContentType imported from generated types (was hardcoded 18-entry union)
- Validation uses isContentType() (was hardcoded array)
Changed: ContentTabsWidget.ts
- Replaced 18-entry TYPE_ICONS map with getContentTypeIcon()
Adding a new content type: create recipe JSON, run generator. Zero code changes.
…, forge pipeline v3
There was a problem hiding this comment.
Pull request overview
This PR replaces the hardcoded main-panel content type fallback registry with a generated, recipe-driven content type registry so content type unions, icons, and configs are derived from system/recipes/*.json.
Changes:
- Removed the large hardcoded
FALLBACK_REGISTRYand switched lookups toshared/generated/ContentTypes.ts. - Added a generator (
src/generator/generate-content-types.ts) to buildContentTypes.tsfrom recipe JSON files. - Updated tabs + UserState validation to use generated helpers (
getContentTypeIcon,isContentType,CONTENT_TYPES).
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/widgets/main/shared/ContentTypeRegistry.ts | Switches runtime lookups from hardcoded fallback to generated recipe-derived configs. |
| src/widgets/content-tabs/ContentTabsWidget.ts | Uses generated icon lookup instead of a hardcoded icon map. |
| src/system/data/entities/UserStateEntity.ts | Replaces hardcoded ContentType union + validation list with generated types/guards. |
| src/shared/generated/index.ts | Re-exports generated ContentType type. |
| src/shared/generated/ContentTypes.ts | New generated union/config map and helper functions. |
| src/generator/generate-content-types.ts | New generator that reads recipes and emits ContentTypes.ts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Source of truth: Recipe JSON files (system/recipes/*.json) | ||
| * Generated types: shared/generated/ContentTypes.ts | ||
| * | ||
| * ARCHITECTURE: Recipe JSON files are THE source of truth for layouts. | ||
| * This registry provides: | ||
| * 1. Dynamic lookup from RecipeLayoutService (loaded from recipes) | ||
| * 2. Fallback defaults for content types without recipes | ||
| * | ||
| * When adding a new content type: | ||
| * 1. Create a recipe JSON file in system/recipes/{contentType}.json | ||
| * 2. Define layout.widgets array with position/order (new format) | ||
| * 3. The registry will automatically pick it up | ||
| * 4. Only add to FALLBACK_REGISTRY if recipe doesn't exist yet | ||
| * NO FALLBACK REGISTRY. If a content type has no recipe, it fails visibly. | ||
| * Add a recipe JSON file, run the generator. That's it. |
There was a problem hiding this comment.
Header comment says “NO FALLBACK REGISTRY… it fails visibly,” but getWidgetForType() still falls back to 'chat-widget' for unknown types and getRightPanelConfig() falls back to the help panel. Either adjust the comment to reflect the current graceful-degradation behavior, or change the runtime behavior to a truly visible failure mode (e.g., dedicated error widget) if that’s the intent.
| const widget = r.layout?.main?.[0] || 'chat-widget'; | ||
| const displayName = r.displayName || r.name || r.uniqueId; | ||
| const icon = ICON_MAP[r.uniqueId] || '📄'; | ||
| const hasRightPanel = r.layout?.right !== null && r.layout?.right !== undefined; | ||
|
|
||
| return ` '${r.uniqueId}': { | ||
| widget: '${widget}', | ||
| displayName: '${displayName}', | ||
| icon: '${icon}', | ||
| pathPrefix: '/${r.uniqueId}', | ||
| requiresEntity: ${r.uniqueId === 'chat' || r.uniqueId === 'live' || r.uniqueId === 'persona' || r.uniqueId === 'dm'}, | ||
| hasRightPanel: ${hasRightPanel}, | ||
| }`; |
There was a problem hiding this comment.
Generated TS embeds displayName, widget, and icon directly into single-quoted string literals. If any recipe’s displayName/name contains ', newlines, or backslashes, the generated ContentTypes.ts will be invalid TypeScript. Consider emitting strings via JSON.stringify(...) (or otherwise escaping) to make generation robust to recipe text.
| // 3. Build icon map from conventions | ||
| // Icons are inferred from recipe metadata; override with explicit mapping if needed | ||
| const ICON_MAP: Record<string, string> = { | ||
| 'chat': '💬', 'settings': '⚙️', 'theme': '🎨', 'help': '❓', | ||
| 'persona': '🤖', 'browser': '🌐', 'canvas': '🎯', 'diagnostics': '🔍', | ||
| 'diagnostics-log': '📋', 'live': '📹', 'profile': '👤', 'metrics': '📊', | ||
| 'grid-overview': '🖥️', 'training-dashboard': '🧪', 'inference-sample': '🔬', | ||
| 'genome-profile': '🧬', 'terminal': '💻', 'dm': '✉️', | ||
| }; |
There was a problem hiding this comment.
PR description says icons/configs come from the recipe files as the single source of truth, but the generator still relies on a hardcoded ICON_MAP (and defaults to 📄). If the intent is truly “recipes only,” consider adding an icon field to recipes (or deriving from existing recipe metadata) and reading it here; otherwise the PR description should be adjusted to reflect that icons still require generator code changes for overrides.
| // Re-export generated types for consumers | ||
| export { ContentType, ContentTypeConfig, isContentType, CONTENT_TYPE_CONFIGS }; |
There was a problem hiding this comment.
ContentType and ContentTypeConfig are imported with import { type ... }, but then re-exported via export { ... } as if they were runtime values. TypeScript will error because type-only imports can’t be re-exported as values; use export type { ContentType, ContentTypeConfig } (and separately export the runtime bindings like isContentType / CONTENT_TYPE_CONFIGS).
| // Re-export generated types for consumers | |
| export { ContentType, ContentTypeConfig, isContentType, CONTENT_TYPE_CONFIGS }; | |
| // Re-export generated types and runtime helpers for consumers | |
| export type { ContentType, ContentTypeConfig }; | |
| export { isContentType, CONTENT_TYPE_CONFIGS }; |
| const configEntries = recipes.map(r => { | ||
| const widget = r.layout?.main?.[0] || 'chat-widget'; | ||
| const displayName = r.displayName || r.name || r.uniqueId; | ||
| const icon = ICON_MAP[r.uniqueId] || '📄'; | ||
| const hasRightPanel = r.layout?.right !== null && r.layout?.right !== undefined; | ||
|
|
There was a problem hiding this comment.
Generator currently assumes the OLD recipe layout shape (layout.main / layout.right). Several existing recipes use the NEW format (layout.widgets with position: 'center' | 'right' and optional panels.right.visible), so the generated widget and hasRightPanel values are wrong (e.g. settings.json and canvas.json both use layout.widgets, but generation falls back to chat-widget and hasRightPanel: false). The generator should mirror RecipeLayoutService.getWidget() / getRightPanel() logic so both layout formats produce correct configs.
| icon: '${icon}', | ||
| pathPrefix: '/${r.uniqueId}', | ||
| requiresEntity: ${r.uniqueId === 'chat' || r.uniqueId === 'live' || r.uniqueId === 'persona' || r.uniqueId === 'dm'}, | ||
| hasRightPanel: ${hasRightPanel}, |
There was a problem hiding this comment.
requiresEntity is hardcoded to a small allowlist of IDs. Recipes already declare inputs for entity-like identifiers (e.g. profile has inputs.userId, diagnostics-log has inputs.logPath), so generated configs currently mark these as requiresEntity: false. Derive requiresEntity from recipe metadata (at least: presence of any inputs key, or an input with entity), and keep only minimal special-cases like chat if needed.
… ContentService hardcoded map
Recipes now declare entityType ("room", "user", "activity"):
- chat.json: entityType: "room"
- live.json: entityType: "room"
- persona.json: entityType: "user"
- profile.json: entityType: "user"
RoutingService.resolve(): was switch(contentType) with 5 hardcoded cases.
Now reads entityType from generated config, switches on ENTITY TYPE not
content type name. Adding a content type never touches RoutingService.
ContentService: was CONTENT_TYPE_COLLECTIONS map (5 hardcoded entries).
Now derives collection from entityType → collection mapping.
room→rooms, user→users, activity→activities.
Generator updated: reads entityType from recipe, generates it into
ContentTypeConfig. requiresEntity derived from presence of entityType
or inputs — no more hardcoded list of content type names.
windows-setup-autostart.ps1: Run ONCE as admin. Creates Windows Scheduled Task that starts WSL2 at boot as SYSTEM (no login required). Copies boot script into WSL, configures wsl.conf. wsl-boot.sh: Runs inside WSL2 on every boot. Starts SSH, Tailscale, PostgreSQL. Protects SSH and Tailscale from OOM killer. Logs GPU detection. After setup: machine reboots → WSL2 starts → SSH available in 30s → Tailscale reconnects → tower reachable via mesh. Zero human intervention.
sentinel/run, ping, collaboration/chat/export, collaboration/live/join, grid/list, ai/agent — all replaced with generated COMMANDS.* constants. 23 magic strings → 13 remaining (mostly in docs/comments/tests).
Experiential Plasticity paper §3.3: Qwen3.5 domain-specific forging results - Qwen3.5-4B on CodeFeedback: baseline 3.04 → forged 2.31 (+24%) - Domain-specific data amplifies plasticity beyond generic text - Published: continuum-ai/qwen3.5-4b-code-forged Gap analysis: updated status with forge results, Qwen3.5-27B next
|
Already merged. |
Summary
Test plan
npm run build:tssucceedsnpm startdeploys successfully