Skip to content

Render and CLI fixes: Icon slashes, real error messages, auto-split, timeout re-runs - #59

Closed
hakamfaza wants to merge 4 commits into
silships:mainfrom
hakamfaza:fix/cli-render-errors
Closed

hakamfaza wants to merge 4 commits into
silships:mainfrom
hakamfaza:fix/cli-render-errors

Conversation

@hakamfaza

Copy link
Copy Markdown
Contributor

Four render/CLI fixes found while building a full design system with figma-cli. Each one has a test that fails before the fix and passes after it. npm test: 564/564.

1. <Icon> dropped when a quoted value contains /

The Icon regex stopped at the first /, so a slash-named variable made the whole tag disappear without an error.

Repro

figma-cli render '<Frame name="Row" flex="row"><Icon name="lucide:arrow-right" size={16} color="var:color/fg" /></Frame>'
  • Before: Warning: Frame has content but no elements were parsed, and an empty frame.
  • After: the icon renders with its stroke bound to color/fg.

Fix: quoted values (single or double) may contain /. parseProps reads single-quoted values. An <Icon> tag that still can't be parsed throws instead of vanishing.
Tests: tests/figma-client.test.js ("<Icon> attributes containing slashes").

2. Every render error reported as ReferenceError: frame is not defined

The single-render wrapper declared const frame inside the try block and called frame.remove() in the catch block, where frame is out of scope. The ReferenceError replaced the real message and skipped the cleanup, so half-built frames stayed on the canvas.

Repro (any component set without the requested variant):

figma-cli render '<Frame name="T"><Instance component="Tag" variant="State=does-not-exist" /></Frame>'
  • Before: ✗ Render failed: ReferenceError: frame is not defined, and a partial frame is left behind.
  • After: No variant of "Tag" matches {"State":"does-not-exist"}. Axes: State=default|hover|active, and the partial frame is removed.

Fix: declare the frame before the try block, remove it if it exists, and rethrow the original error with its node context.
Tests: tests/render-error-path.test.js runs the generated render code in a node:vm sandbox against a mock component set. tests/flex-none.test.js gets a one-line anchor update.

3. Auto-split breaks wrappers whose children fill them

detectWrapperSplit turned any layout-only <Frame> with two or more <Frame> children into separate canvas items. That breaks real structure:

  • Children with w="fill", h="fill" or grow lose the parent they size against.
  • A variant-named frame (Type=grid, Size=desktop) becomes only its first row.

Repro

figma-cli render '<Frame name="Gallery" w={600} flex="col" gap={24}><Frame name="Row" w="fill" flex="row"><Frame w={100} h={50} bg="#000" /></Frame><Frame name="Row" w="fill" flex="row"><Frame w={100} h={50} bg="#000" /></Frame></Frame>'
  • Before: ↳ outer flex wrapper detected — splitting to 2 standalone items. The two rows land on the canvas without the Gallery frame.
  • After: one Gallery frame with both rows inside.

Fix: don't split when a direct child fills or grows, or when the outer frame is variant-named. The "N cards in a bag" split is unchanged.
Tests: tests/wrapper-split.test.js.

4. Timeouts hide their cause and re-run code that is still executing

Code sent to Figma keeps running after the caller stops waiting, but three places treated a timeout as "nothing happened":

  • render sends its generated code through the daemon's eval action, so it got the 30s eval budget, never the 90s render budget.
  • daemonExec relabelled every error containing "timeout" as Execution timeout (90s). Try reconnecting. A 30s daemon limit read as 90s.
  • figma-cli eval and fastEval fell back to the direct connection on a timeout and ran the same code again. That duplicated whatever the first run was still building.

Repro

figma-cli eval '(async()=>{globalThis.__runs=(globalThis.__runs||0)+1; await new Promise(r=>setTimeout(r,35000)); return "done"})()'
# wait ~10s, then:
figma-cli eval 'globalThis.__runs'
  • Before:
    • After 30s: Execution timeout (90s). Try reconnecting.
    • Then: ⚠ Daemon error, trying sync path....
    • __runs is 2: the code ran twice.
  • After:
    • Figma did not answer within 30s. The command may still be running in Figma and finish on its own: check the canvas before running it again.
    • __runs is 1.

Fix:

  • A new src/lib/timeouts.js holds the shared policy: error classification, the message, and a clamped budget.
  • The daemon's eval accepts a bounded timeoutMs, and render asks for 90s.
  • daemonExec only relabels its own abort.
  • The eval fallbacks run only on real connection errors, never on timeouts.

Tests: tests/timeouts.test.js. The daemonExec case stubs fetch and fails against the old cli-core.js.


Live checks, Figma Desktop 126.9 in Yolo mode:

  • The icon renders, bound to its variable.
  • A missing variant reports the real message, with no partial frame left.
  • A wrapper whose children fill it is kept.
  • A 35s eval reports the 30s budget and runs once.

🤖 Generated with Claude Code

hakamfaza and others added 4 commits October 27, 2026 08:25
The Icon regex stopped at the first '/', so color="var:color/fg" dropped
the icon silently. Quoted values (single or double) may now contain '/',
parseProps reads single-quoted values, and an <Icon> tag that still cannot
be parsed throws instead of vanishing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The single-render wrapper declared the root frame with const inside the
try block, so the catch could not see it: frame.remove() threw a
ReferenceError that replaced the real message (e.g. a missing variant)
and skipped the cleanup, leaving half-built frames on the canvas.
The frame is now declared before the try, removed when present, and the
original error is rethrown with its node context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flex-wrapper auto-split turned any layout-only <Frame> with 2+ <Frame>
children into standalone canvas items. That broke real structure: children
with w="fill", h="fill" or grow lost the parent they size against, and a
variant-named frame ("Type=desktop-screens, Size=desktop") became its
first row. Both cases now keep the wrapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A timeout does not stop code that is already running in Figma, but three
places treated it as "nothing happened":

- render sent its generated code through the daemon's eval action and got
  the 30s eval budget instead of the render one; it now asks for 90s.
- daemonExec relabelled every error containing "timeout" with its own
  90s and "Try reconnecting", so a 30s daemon limit read as 90s.
- the eval command and fastEval fell back to the direct connection on a
  timeout and ran the same code again, which duplicated whatever the first
  run was still building.

Timeouts now keep their real budget, say the command may still finish,
and never trigger a second run. The daemon's eval accepts a bounded
timeoutMs for long, mutating callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
silships pushed a commit that referenced this pull request Nov 19, 2026
…e-runs (#59)

Ported from PR #59 by hakamfaza onto current main:
- <Icon> tags with "/" in quoted values no longer vanish; parseProps reads single quotes
- render catch block no longer masks errors as "frame is not defined" and removes the partial frame
- auto-split keeps wrappers whose children fill/grow, and variant-named frames
- timeouts: render gets the 90s budget, daemonExec keeps the real budget, eval/fastEval never re-run code after a timeout

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
@silships

Copy link
Copy Markdown
Owner

Thank you! This is in figma-cli 2.4.0 on npm: the Icon slash fix, the real render errors, the auto-split guard and the timeout handling. Commit 793485f keeps you as the author

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.

2 participants