Repository navigation
fix(render): unmask render errors and make w/h="fill" work (#42) - #43
Closed
clementcopper wants to merge 2 commits into
Closed
clementcopper wants to merge 2 commits into
clementcopper wants to merge 2 commits into
Conversation
The generated root-frame code declared `const frame` inside the `try` and called `frame.remove()` from the `catch`, where that binding is not in scope. Every failure — a bad prop, an unsupported sizing keyword, a missing parent — was therefore replaced by `ReferenceError: frame is not defined`, and the `[Node: …] <message>` wrapper built for exactly this purpose was unreachable. Two consequences, both fixed here: - the real error now reaches the caller - cleanup runs, so a failed render no longer leaves an orphan frame on the canvas (it did: two failed renders, two frames left behind) `let frame` is hoisted out of the `try` and the cleanup is guarded, so a `createFrame()` that throws, or a `remove()` that fails, cannot replace the original error either. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
With the error masking gone (previous commit), three separate `fill` bugs became visible. All three used to surface as the same ReferenceError. 1. Root frame with `--parent`: `frame.layoutSizingHorizontal = 'FILL'` was emitted near the top of the generated code, but `appendChild` runs at the very end (deliberately, so an auto-layout parent measures real content instead of the seed size). FILL was set while the frame was still parentless, which Figma rejects. The assignment now runs after `appendChild`, guarded by a check that the parent actually uses auto-layout. 2. Root frame without `--parent`: nothing to fill. Emits a layout warning through the existing `__layoutWarnings` channel instead of throwing. 3. `<Rectangle>` / `<Ellipse>` / `<Image>` passed `item.w` straight into `resize()`, so `w="fill"` arrived at the Plugin API as the string "fill". They now follow the same shape as a Frame child: the keyword is kept out of `resize()`, and `layoutSizing*` plus `__figHugWarn` are emitted after `appendChild`. In a `flex="none"` parent the keyword is ignored rather than emitted, matching Frame children. The decision logic lives in `src/lib/fill-sizing.js` as two pure functions, per the repo convention, with unit tests that need no Figma. `tests/render-fill-errors.test.js` asserts on the generated code for each reproduction case from the bug report, including the render-batch path, which shares the child generator. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
clementcopper
added a commit
to clementcopper/figma-claude
that referenced
this pull request
Aug 17, 2026
…h="fill" (silships#42, upstream PR silships#43)
clementcopper
added a commit
to clementcopper/figma-claude
that referenced
this pull request
Sep 3, 2026
Seven branches became one on 2026-09-03. The skill's first line still said the default was v2, and it is the file you read right before merging from upstream. What the cleanup was based on: `feat/swift-host` was v2 plus 26 commits with v2 fully contained, the only tree difference being `swift-host/`, and `app/` sitting in both. The Electron app is a directory, not a branch — `make-app.sh` reads `app/build/icon.icns` — so a second branch beside the trunk would have been a copy of the same CLI falling behind. v2 had stood still since 22.08. `v2` and `archive/draft-v1` are now the tags `v2-final` and `draft-v1`. The four PR branches stay on origin because deleting them there closes PRs silships#40, silships#41, silships#43 and silships#44; that is written down so nobody tidies them away later. Also noted: CI triggers on `branches: [main]`, which this fork has never had, so it has never run on a push here. Left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuvZuDad3hi3CVwNDbTvr2
silships
pushed a commit
that referenced
this pull request
Nov 19, 2026
Ported from PR #43 by clementcopper onto current main. The catch-block unmasking half of #43 already landed with #59, so only the fill sizing is ported here: - root frame w/h="fill" is set after appendChild when --parent is an auto-layout frame, warns otherwise instead of throwing - Rectangle / Ellipse / Image keep "fill" out of resize() and set layoutSizing* after appendChild (ignored in flex="none" parents) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
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.
Fixes #42.
Two commits, reviewable independently.
1. The
catchblock masked every render errorThe generated root-frame code declared
const frameinside thetryand calledframe.remove()from thecatch, where that binding is not in scope. So every failure — bad prop, unsupported sizing keyword, missing parent — surfaced asReferenceError: frame is not defined, and the[Node: …] <message>wrapper right below it was unreachable.frame.remove()never ran either, so a failed render left an orphan frame on the canvas.let frameis now hoisted out of thetryand the cleanup is guarded, so neither a throwingcreateFrame()nor a failingremove()can replace the original error.Before / after, same command:
…and no orphan node left behind in the second case.
2. The three
fillbugs the masking hid--parent.frame.layoutSizingHorizontal = 'FILL'was emitted near the top of the template, but__p.appendChild(frame)runs at the very end (deliberately, so an auto-layout parent measures real content rather than the seed size). FILL was set while the frame was still parentless, which Figma rejects — it could never have worked. The assignment now runs afterappendChild, guarded by a check that the parent actually uses auto-layout (with a layout warning if it does not).--parent. Nothing to fill. Emits a warning through the existing__layoutWarningschannel instead of throwing.<Rectangle>/<Ellipse>/<Image>. These passeditem.wstraight intoresize(), sow="fill"reached the Plugin API as the string"fill". They now follow the same shape as a Frame child: the keyword is kept out ofresize(), andlayoutSizing*plus__figHugWarnare emitted afterappendChild. In aflex="none"parent the keyword is ignored rather than emitted, matching Frame children.The decision logic sits in
src/lib/fill-sizing.jsas two pure functions (resolveLeafSizing,resolveRootFill) with unit tests, per the conventionbrowserDebugArgs/src/platform.jsestablished.Tests
tests/render-fill-errors.test.jsasserts on the generated code for every reproduction case in #42, including therender-batchpath (it shares the child generator, so the leaf fix lands there too).tests/flex-none.test.jsneeded a one-word anchor update (const frame = figma.createFrame→frame = figma.createFrame).543 tests pass, no Figma required.
Verified live against Figma Desktop (Yolo Mode, macOS):
Out of scope
generateBatchCodehas notry/catchat all — no masking there, but also no cleanup when a batch render fails midway. Left alone deliberately; happy to look at it separately if you want it.