Skip to content

Unify content routing: kill ContentTypeRegistry, route everything through recipes #362

Closed

Description

@joelteply

Problem

The data model is correct: Recipe (template) → Room/Activity (instance) with recipeId. But the routing layer completely ignores this and hardcodes everything.

Previous sessions built a parallel routing system instead of using the recipe system that was already there. Now there are two competing systems that must be kept in sync manually, plus 72+ switch statements on content type strings scattered across the codebase.

The Damage

Parallel System 1: Hardcoded Registry

  • ContentTypeRegistry.FALLBACK_REGISTRY — 18 hardcoded content types mapping string → widget + panel config
  • LayoutTypes.DEFAULT_LAYOUTS — 5 more hardcoded layouts for sidebar composition
  • ContentTabsWidget.TYPE_ICONS — 18 hardcoded icon mappings
  • ContentType union type in UserStateEntity — hardcoded string union that must be extended for each new type
  • RoutingService.resolve() — switch statement routing content types to entity resolvers
  • PositronicRAGContext — switch statement for widget-specific context extraction

Parallel System 2: Recipe JSON (the correct one)

  • 24 recipe JSON files in system/recipes/ that define layout, pipeline, RAG, strategy
  • RecipeEntity in the database with proper fields
  • ActivityUILayout type that supports full panel composition
  • Already has main, left, right, bottom panel configs

The Result

  • Adding a new content type requires editing 4+ files
  • Recipe layouts and registry layouts can drift apart
  • No dynamic discovery — everything is hardcoded strings
  • Compression Principle violation: content type definitions duplicated across 6+ locations

Files Affected

Primary targets (kill or gut):

  • src/widgets/main/shared/ContentTypeRegistry.ts — the 18-entry FALLBACK_REGISTRY
  • src/system/layout/LayoutTypes.ts — DEFAULT_LAYOUTS hardcoded map
  • src/widgets/content-tabs/ContentTabsWidget.ts — TYPE_ICONS hardcoded map
  • src/system/data/entities/UserStateEntity.ts — ContentType union type

Switch statements to eliminate (72+ occurrences):

  • src/system/routing/RoutingService.ts — switch on contentType in resolve()
  • src/system/state/PositronicRAGContext.ts — switch for widget highlights
  • src/system/core/client/shared/services/ContentService.ts — hardcoded type list

Target Architecture

One ID, one lookup. ContentService.open(uniqueId) resolves to a recipe, and the recipe defines everything:

User clicks "Training Dashboard"
  → ContentService.open('training-dashboard')  // ONE arg
  → Lookup recipe by uniqueId
  → Recipe defines: widget, layout, right panel, icon, display name, pipeline, RAG
  → No registry, no switch statements, no hardcoded types

What recipes already support (just unused by routing):

  • layout.main — primary widget(s)
  • layout.left / layout.right / layout.bottom — panel composition
  • displayName — tab title
  • pipeline — command sequence for AI behavior
  • ragTemplate — context building rules
  • strategy — response decision criteria
  • tags — for discovery/search

What recipes need added:

  • icon — emoji/icon for tab display (currently hardcoded in TYPE_ICONS)
  • pathPrefix — URL routing (currently hardcoded in registry)
  • requiresEntity — whether uniqueId/entityId is needed (currently hardcoded)

Implementation Strategy

  1. Extend recipe schema with icon, pathPrefix, requiresEntity
  2. Make RecipeLayoutService the single lookup — all routing goes through it
  3. Kill FALLBACK_REGISTRY — migrate each entry to a recipe JSON
  4. Kill DEFAULT_LAYOUTS — sidebar config moves into recipes
  5. Kill TYPE_ICONS — icon comes from recipe
  6. Kill ContentType union — replace with string (recipe uniqueId)
  7. Replace switch statements with recipe-driven lookup (72+ sites)
  8. RoutingService.resolve() — use recipe metadata instead of switch

Scope

This is a large refactor but mechanically straightforward — the data model and recipe system are already correct. The work is eliminating the parallel hardcoded system and making the existing recipe system the single source of truth.

Related Issues

Activity

  1. joelteply commented on Mar 27, 2026

    @joelteply
    ContributorAuthor

    Addressed in PR #567 (branch fix/generated-content-types):

    Eliminated:

    • 18-entry FALLBACK_REGISTRY in ContentTypeRegistry.ts (replaced with generated types from recipe JSON)
    • Hardcoded ContentType union in UserStateEntity.ts (now imported from generated)
    • 18-entry TYPE_ICONS map in ContentTabsWidget.ts (now uses getContentTypeIcon())
    • RoutingService switch on content type names (now switches on entityType from recipe)
    • ContentService CONTENT_TYPE_COLLECTIONS hardcoded map (now derives from entityType)

    New:

    • generator/generate-content-types.ts — reads all 27 recipe JSON files, generates TypeScript types, configs, icons, entityType
    • Recipes declare entityType: "room" | "user" | "activity" — routing uses this, not content type names

    Remaining:

    • PositronicRAGContext highlight switch (marked TODO — needs recipe ragHighlights schema)

    Adding a content type: create recipe JSON, run generator. Zero code changes needed.

  2. added 2 commits that reference this issue on Mar 29, 2026
  3. joelteply commented on Mar 30, 2026

    @joelteply
    ContributorAuthor

    Content routing fixed: generator reads new widgets[] format (#598), generated config checked before async recipe service (#597). Live, factory, grid, logs all route correctly. ContentTypeRegistry still exists but works. Full removal tracked separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions