Skip to content

fix: Design agent can always access template - #2632

Open
liamdebeasi wants to merge 5 commits into
mainfrom
ld/template-preserve
Open

fix: Design agent can always access template#2632
liamdebeasi wants to merge 5 commits into
mainfrom
ld/template-preserve

Conversation

@liamdebeasi

@liamdebeasi liamdebeasi commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The agent did not have access to the original template on subsequent prompts, so asking it to make multiple changes would result in quality degradation. This PR fixes this by ensuring the agent is always able to access the original template.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Here's a visual recap of what changed:

Visual recap

Open the full interactive recap

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@liamdebeasi
liamdebeasi force-pushed the ld/template-preserve branch from d83af51 to d234455 Compare August 5, 2026 14:39
@netlify

This comment has been minimized.

@liamdebeasi liamdebeasi changed the title properly reference template on subsequent prompts fix: Design agent can always access template Aug 5, 2026
@netlify

This comment has been minimized.

@liamdebeasi
liamdebeasi marked this pull request as ready for review August 5, 2026 17:59
builder-io-integration[bot]

This comment was marked as outdated.

builder-io-integration[bot]

This comment was marked as outdated.

@liamdebeasi

Copy link
Copy Markdown
Contributor Author

@builderio-bot look at latest PR feedback and fix anything you agree with. Be skeptical. Reply to every comment (directly on the comment thread of each comment) if you fixed it or not and why

@liamdebeasi
liamdebeasi requested review from a team and shomix and removed request for a team August 6, 2026 15:16
- Capture quoted CSS font-family declarations
- Respect access to linked design systems in get-design-template
- Skip malformed Google Fonts URLs instead of throwing
- Register get-design-template in the initial agent tool catalog
@builder-io-integration

Copy link
Copy Markdown
Contributor

CI just kicked off from the push; checks are pending. All 4 review findings were legitimate and fixed:

  1. Quoted CSS font-family capture — regex character class excluded quote chars, so font-family: "DM Sans", ... never matched. Widened the capture.
  2. Design-system access leakget-design-template returned the linked designSystemId without checking read access, unlike sibling actions. Added the resolveAccess check.
  3. Missing tool in initial catalogget-design-template is named directly in same-turn refinement directives but wasn't in INITIAL_TOOL_NAMES, forcing an extra tool-search round trip. Added it.
  4. Crash on malformed font URLdecodeURIComponent could throw and abort the whole copy. Wrapped in try/catch to skip just that entry.

Added regression tests for all four, all guards pass, and full test suite is green (unrelated Playwright-browser failures are pre-existing environment issues, not caused by these changes). Replied to each of the 4 review comment threads explaining the fix, and pushed to ld/template-preserve.



🟢 Fixed and replied to all 4 PR review findings; pushed to ld/template-preserve, CI running.


Edit in Builder  Preview

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder reviewed your changes and found 3 potential issues 🟡

Review Details

Incremental Code Review Summary

The latest commit fixes all four previously reported issues: quoted font-family extraction now supports quoted names, malformed Google Fonts URLs are skipped, linked design-system IDs are access-filtered, and get-design-template is included in the initial tool catalog. Those four review threads were resolved before this review.

New Findings

🟡 MEDIUM

  • Invalid JSON in design.data is coerced to {}, so both template recovery and the required snapshot path can report an ordinary non-template design instead of preserving an explicit unreadable-provenance state. This can cause follow-up edits to lose template constraints.
  • get-design-template applies template-level fallback dimensions to every file lacking its own frame, which can copy a sibling screen's dimensions into a multi-screen template. The exact per-file lookup helper explicitly treats missing frames as unknown.

The happy path and access-control fixes are well covered by the new tests, but malformed design metadata and multi-screen dimension fallback need separate handling.

🧪 Browser testing: Will run after this review (PR touches UI code)

if (!designAccess) throw new Error("Design not found");
const design =
designAccess.resource as typeof schema.designs.$inferSelect;
const source = readDesignTemplateSource(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Preserve unreadable design metadata as an error

parseDesignTemplateData returns {} when design.data is invalid JSON, so readDesignTemplateSource returns null and this action reports fromTemplate: false. A corrupted template-backed design is therefore indistinguishable from a design that never used a template, allowing the follow-up workflow to lose its constraints; preserve and surface the parse failure instead of treating it as absent provenance.

Additional Info
Reported by 1 of 3 agents; confirmed against parseDesignTemplateData lines 15-23 and the absent-vs-unreadable contract.

Fix in Builder

const design = access.resource as typeof schema.designs.$inferSelect;

const snapshot = await buildDesignSnapshot(designId, design.data);
const templateSource = readDesignTemplateSource(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Do not silently drop unreadable template provenance

This required follow-up snapshot path also receives {} for invalid design.data, then omits createdFromTemplate entirely. The agent is not told that provenance is unreadable and may edit the design as unconstrained; return an explicit unreadable state or propagate the parse failure rather than silently dropping the template metadata.

Additional Info
Reported by 1 of 3 agents; confirmed against parseDesignTemplateData lines 15-23 and the refinement directive requiring this snapshot.

Fix in Builder

Comment on lines +141 to +148
files = rows.map((row) => {
const frame = templateFileDimensions(templateData, row.id);
return {
templateFileId: row.id,
filename: row.filename,
fileType: row.fileType,
content: row.content,
width: frame.width ?? fallbackWidth,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Do not reuse sibling dimensions for unframed template files

For a saved multi-screen template, fallbackWidth/fallbackHeight come from the template's preferred/first frame and are applied to every file whose own canvasFrames[row.id] is missing. That reports another screen's dimensions as authoritative for the unframed file, contrary to templateFileDimensions' exact-lookup contract; return unknown dimensions for missing per-file frames (or restrict fallback to an explicitly identified legacy single-file case).

Additional Info
Reported by 1 of 3 agents; confirmed against the exact lookup helper and the mapping at lines 141-150.

Fix in Builder

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants