feat(ai-agent): canvas-aware generation with roles, async edges and repair - #26
Conversation
…epair The design agent now sees what is already on the canvas, so follow-up requests extend the existing design instead of redrawing it, and generated diagrams match the starter templates' visual conventions. - lib/ai/canvas-summary.ts: compact canvas listing with refs (ex-N), kinds, used connection points, connections and notes, passed to the analyze, plan and generate steps - Generation schema: role + kicker instead of legacy dark colorId, sync/async delivery (async edges dashed); edges may reference existing components by ref - buildCanvasGraph: resolves refs, folds redrawn or repeated components into the existing/first node, drops unknown and duplicate links, and assigns connection points counting existing edges - lib/ai/graph-validation.ts + one repair call: duplicate/redrawn components, unknown refs, self loops, repeated links, >4 connections, unconnected components, missing plan components - Shared NODE_ROLES / getRoleFill and SHAPE_KICKERS in types/canvas.ts (starter templates use them) - Plan text no longer shows internal canvas refs Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Why
The design agent drew every request from scratch. A follow-up like "add a cache" could redraw existing components or float the new ones unconnected. Generated nodes also used the legacy dark palette instead of the paper fills, role labels and dashed async links the starter templates use. This is step 5 of the AI sessions plan: generation quality.
What
Canvas context:
lib/ai/canvas-summary.tslists the components with short refs (ex-1…), their kind and used connection points, plus the connections and text notes. The listing is capped for large canvases.Richer output:
colorIdwithrole(entry, compute, messaging, data, output → paper fill) and akicker.delivery: sync | async, and async edges are dashed.SHAPE_KICKERSnow live intypes/canvas.ts, and the starter templates use them.buildCanvasGraphwith an existing canvas:Validate and repair:
lib/ai/graph-validation.tsflags:If anything is flagged, the model gets one repair call with those problems, and the attempt with fewer problems is used. If the repair call fails, the first attempt is kept.
Robustness:
Verification
pnpm typecheckandpnpm lintpass.buildCanvasGraphonto an existing canvas: role fills, kickers, dashed async edges, refs and folded duplicates, dropped bad links, connection points avoiding used sidesgemini-3.5-flash-lite), on a room seeded with the Microservices template (8 nodes, 8 edges). Request: "Add a Redis cache in front of the user database, and a notification service that consumes order events."🤖 Generated with Claude Code