feat: shared screens / reusable components#41
Merged
trmquang93 merged 1 commit intomainfrom Apr 26, 2026
Merged
Conversation
Let users explicitly mark screens as reusable components so the AI build instructions describe each component once instead of duplicating code for every placement. - Sidebar + context-menu UI to mark canonical / pick "Instance of…" / unlink - Purple `⟳ Component` and `↗ Instance` pills on the canvas - Instances render the canonical's image and hotspots at draw time, so edits on the canonical propagate live; hotspot editing is canonical-only - generateInstructionFiles emits one `components/<slug>.md` per canonical; instances in `screens.md` link to it instead of duplicating the spec - Auto-promotion: deleting a canonical promotes the first instance, so groups can never become orphaned - importFlow backfills the new fields and enforces one canonical per group - MCP `update_screen` accepts componentId / componentRole - User guide updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
components/<slug>.mdfile per canonical with a Placements table; instance entries inscreens.mdare stubs that link to it.Implementation
useScreenManager.js): addscomponentId/componentRoleto screens, newsetScreenComponent(id, mode)action with auto-promotion of the first instance when a canonical is deleted;duplicateSelectiondemotes copied canonicals to instances.importFlow.js): backfills missing fields and enforces one canonical percomponentId(drops orphan instances, demotes duplicate canonicals).SidebarComponent section (mark canonical / "Instance of…" picker / unlink / open canonical),ScreensPanelcontext-menu items,ScreenNodepurple border +⟳ Component/↗ Instancepills, theme tokens.resolveInstanceVisuals.js): pure helper that merges canonical'simageData, dimensions, andhotspotsinto an instance at draw time. Hotspot edits,+ Link, drag-to-create, and resize handles are gated off on instances.generateInstructionFiles.js): exportedgetComponentGroups; instances render as a stub linking to the canonical's component file; canonicals get a "see component file" header;main.mdadds acomponents/row only when canonicals exist; newgenerateComponentFilesemits per-component markdown with a Placements table (canonical + instances, link counts) and full spec.mcp-server):update_screenacceptscomponentId(string|null) andcomponentRole(canonical|instance|null).Test plan
npm test— 685 tests across 36 files passing (added 8 forresolveInstanceVisuals+ 10 for component grouping = 18 new)npm run lint— 0 errors, 0 warningsnpm run build— success (only pre-existing chunk-size advisory)components/<slug>.mdper canonical, instance entries are stubs