Skip to content

fix(builder): canvas cards no longer stay hidden after a burst of layout updates - #450

Open
QSchlegel wants to merge 1 commit into
preprodfrom
claude/daily-2026-11-22-builder-canvas-measured
Open

QSchlegel wants to merge 1 commit into
preprodfrom
claude/daily-2026-11-22-builder-canvas-measured

Conversation

@QSchlegel

Copy link
Copy Markdown
Collaborator

What

The transaction builder canvas could leave every card hidden for good (empty canvas, no edges) while the page around it had loaded. This PR fixes that. It is the root cause of the playwright-browser failure on #449: builder-imported-pending.spec.ts › via deep link waited 120 s for the Signer 1 output, and Playwright reported "element is not visible" the whole time.

Why it happened

  • React Flow renders a node with visibility: hidden until the node has a measured size.
  • It re-observes a node's DOM element only when the node goes from measured to unmeasured in a committed render (useNodeObserver, deps [isInitialized, hidden]).
  • BuilderCanvas replaced its nodes on every layout recompute with setNodes(computedNodes), using copies that carry no measurement.
  • When two recomputes land before the measured state is committed, the ResizeObserver has already delivered its single callback and nothing re-observes the element, so the card stays hidden. This happens when wallet, label and UTxO data arrive one after another while a deep-linked transaction loads.

Fix

  • syncMeasuredNodes (in token-flow/measured-nodes.ts) carries measured over for cards that still exist. The canvas now applies it as a functional update, so a queued dimensions change can no longer be overwritten. Brand-new cards are still measured on mount.
  • Keeping measurements would leave stale handle bounds on a card whose connector dots move without the card resizing (a change in port count or protocol ports). For those cards, RemeasureMovedHandles calls useUpdateNodeInternals after the commit. Changes that resize a card were already caught by React Flow's ResizeObserver.

No changes to transactions, signing or the draft model. This only affects how the canvas is rendered.

Tests

npx tsc --noEmit ✅
npx jest src/__tests__/tokenFlowMeasuredNodes.test.ts 8/8 ✅
node scripts/run-tests.mjs (full unit run) 2361 passed, 2 skipped (186 suites); ESM 140/140 ✅
New isolated browser spec e2e/risk-components/builder-canvas.spec.ts (real BuilderCanvas + React Flow in Chromium; 4 rounds of new recipient + 40 macrotask-spaced recomputes) old canvas: 5/5 fail (all 5 cards hidden, 0 edges) · new: 5/5 pass
Same spec with the fix but without RemeasureMovedHandles 1/2 fail (edge to the new port dropped), so the re-measure path is needed and covered
npx playwright test -c e2e/risk-components.config.ts --repeat-each 3 (whole config) 75/75 ✅
SKIP_ENV_VALIDATION=1 npx next build --webpack + check-bundle-budget.mjs --report ✅ Within budget (shared 193.7 KB gz)

A cold review by a separate agent found no blockers. I applied two of its nits: a redundant unit case was removed, and the harness hook now lives in a useEffect.

Not verified


Generated by Claude Code

…out updates

React Flow renders a node with visibility:hidden until it has a `measured`
size, and only re-observes the node's element when it goes from measured to
unmeasured in a committed render. The builder canvas replaced its nodes with
measurement-less copies on every layout recompute (setNodes(computedNodes)),
so two recomputes landing before the measured state was committed left every
card - and therefore every edge - hidden for good. That is the empty canvas in
the deep-link failure of builder-imported-pending.spec.ts on #449.

The sync now carries `measured` over for cards that still exist (functional
update, so queued dimension changes are not overwritten) and asks React Flow
to re-measure the cards whose connector dots moved without a resize.

Tests: unit spec for syncMeasuredNodes, and an isolated browser spec that
fails 5/5 on the old canvas and passes 5/5 with the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017rkSXFA7AZFzsUvB1Cgq4K
@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
multisig Ready Ready Preview Nov 22, 2026 6:20am UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 247bee1e Deployed Nov 22, 2026 by vercel[bot]
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