231 Progress Report

Documentation for Sessions

Session 231 — Vitto Studio: From Broken Preview to Working Platform Builder

Date: March 17, 2026 Focus: Fix the live preview, improve platform generation quality, design versioning system Platform: Claude Code (claude-opus-4-6) Branch: session-230-231


What This Session Achieved (Plain English)

When we started this session, the Vitto Studio — our platform builder where users design and build their own applications — was fundamentally broken. The Live Preview (the window that shows users what their platform looks like in real-time) showed nothing but a "Ready when you are" message, even when the platform had generated modules. The file explorer showed irrelevant JSON data files instead of actual code. And when users made edits, nothing happened.

By the end of this session:


Timeline of Changes

Phase 1: Fixing the Live Preview (S231.1 — S231.2)

Problem: The live preview showed "Ready when you are" forever, even when 5 modules existed.

What we found: A chain of THREE bugs working together to silently prevent compilation:

  1. Race condition (S231.1): The system signaled "modules are loaded" the instant it got the list of module names from GitLab — but before any actual file contents were downloaded. The compiler then checked for .routes.ts files, found none (still downloading), and gave up.

  2. Type mapping error (S231.2): This was the real killer. GitLab's API returns type: "blob" for files, but our code checked type === "file". Every file in the system was misidentified as a directory. Zero files were ever loaded into the virtual file system. The preview had directories but no code inside them.

  3. Stale cache (S231.2): When the user navigated away from Studio and came back, old module slugs were cached, so the system thought everything was "already loaded" and skipped fetching entirely.

Impact: After these fixes, the live preview compiled and rendered the platform for the first time.


Phase 2: Generation Quality (S231.3)

Problem: The generated Angular code had quality issues compared to our reference codebase (gmodules1).

What we found: Four specific gaps in the LLM generation prompt:

  1. The prompt contradicted itself about CSS vs SCSS files (said ".css" in one place, showed ".scss" in examples) — the AI generated both, creating duplicate files
  2. File path examples had src/lib/ but actual files should be at src/ — confused the AI about directory structure
  3. Entity pluralization was wrong ("Childs" instead of "Children") because the pipeline never computed the correct plural form before sending to the AI
  4. No HTML template example was provided for the list component — the AI had to guess the shell component's API

What we fixed: Updated the generation prompt with correct instructions, added the pluralize() function call before the AI prompt, and added complete golden examples for list HTML, detail HTML, badge components, button components, checkbox selection, and route data.


Phase 3: File Tree and App Visibility (S231.4 — S231.5)

Problem: Users couldn't see "the app" in the file explorer. They saw raw JSON data files (pages, widgets) that weren't useful for coding. The Angular application entry point (app.component.ts, app.routes.ts, main.ts) was completely missing.

What we found:

What we fixed:


Phase 4: Live Editing (S231.6 — S231.7)

Problem: When users edited code in the Studio, changes weren't reflected in the preview.

What we found: An Angular reactivity bug — _fileChanges.set() was called inside _state.update() (a signal write inside another signal's write). Angular's reactive system doesn't reliably fire effects from nested signal writes. The preview's recompile trigger never fired.

What we fixed:


Phase 5: Preview Route Persistence (S231.8)

Problem: Every time the preview recompiled (after an edit), it reset to the first page. If the user was looking at /family-profiles/list and changed something, the preview jumped back to the default route.

What we fixed: Before each recompile, the system now saves the current route hash from the iframe. After the new app boots (~350ms), it sends a PREVIEW_NAVIGATE message to restore the previous route. The user stays on the same page across edits.


Phase 6: Pipeline Bug Fixes (S231.9)

Problem: Module names with special characters produced broken paths. "Family & Household" became family--household (double dash) which breaks imports and routing.

What we fixed: Added a third regex pass to the slug sanitizer that collapses multiple consecutive dashes. This affects both the execute phase and the template generator.

Also added a GET /module-generation/platform/sessions endpoint so Vitto can find its active generation session ID after a context reset.


Phase 7: Versioning Design (S231.10)

Problem: Each platform generation creates a Git branch, but there's no way for users to see what was generated, switch between versions, or understand which generation is active. Manual code edits go directly to the develop branch, creating conflicts with new generations.

What we designed: A complete versioning system inspired by how GitHub Copilot Agent, Replit, and Lovable handle AI-generated code:

This design is documented in a full spec at docs/superpowers/specs/2026-03-17-generation-versioning-drafts-design.md.


What's Next

Priority Task Status
1 Implement the versioning system (GenerationManifest, Generations panel, draft branches) Design complete, implementation plan pending
2 Add admin app to platform-base-template (each platform needs a management interface) Designed, not started
3 Fix empty Studio tabs (Modules, Entities, Data panels need real data) Identified, not started
4 CSS-only instant preview updates (style changes without rspack recompile) Designed, deferred
5 Multi-module editing (Vitto regenerates single modules to a draft branch) Designed in spec, not started

Technical Summary (for developers)

Commits in this session

Commit Type Description
S231.1 bugfix forkJoin to emit modulesLoaded$ after all files fetched, not just slug list
S231.2 bugfix GitLab tree type mapping blob→file + clear loadedModuleSlugs on VFS re-init
S231.3 improvement Generation prompt: correct plurals, .scss, paths, HTML template golden examples
S231.4 feature Load apps/ from GitLab into VFS, remove JSON data blobs from code editor
S231.5 bugfix Fix insertFileIntoVfs hardcoded /modules/ path, strip universe-slug prefix
S231.6 bugfix Angular signal reactivity fix for file changes, rename app→apps
S231.7 feature Incremental PATCH compilation, reduce debounce 500ms→150ms
S231.8 feature Route preservation across preview recompiles via PREVIEW_NAVIGATE postMessage
S231.9 bugfix Double-dash slug sanitizer, generation session list endpoint
S231.10 design Full versioning & draft system spec (Option B)

Files changed across session

Backend (APIs):

Frontend (libs):

Static assets:

Documentation: