Skip to content

fix: auto-layout zero-position nodes, fix new-node x===y stacking - #25

Merged
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/node-stacking
Apr 14, 2026
Merged

fix: auto-layout zero-position nodes, fix new-node x===y stacking#25
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/node-stacking

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

  • Bug 1 — 9/12 nodes stack at 0,0 on load: workspaces with no canvas_layouts row come back as x:0, y:0. computeAutoLayout() (BFS tree layout) detects these and assigns distinct positions, persisting them back via api.patch so they survive reload.
  • Bug 2 — position:{x:t,y:t} in minified bundle: WORKSPACE_PROVISIONING in canvas-events.ts used const x = offset; const y = offset; — identical bindings collapse to a single variable in minification. Replaced with a 4-column grid layout (GRID_COL_WIDTH=320, GRID_ROW_HEIGHT=160) giving distinct x/y values.

Files changed

File Change
canvas/src/store/canvas-topology.ts Added computeAutoLayout() BFS layout; buildNodesAndEdges accepts layoutOverrides map
canvas/src/store/canvas.ts hydrate() calls computeAutoLayout, passes overrides, persists positions via PATCH
canvas/src/store/canvas-events.ts Grid layout replaces x = offset; y = offset
canvas/src/store/__tests__/canvas-topology.test.ts 8 new tests for computeAutoLayout and override behaviour

Test plan

  • npm test — 365/365 pass (357 original + 8 new)
  • npm run build — clean, no type errors
  • Manual: provision 12+ workspaces, verify they spread across canvas instead of stacking
  • Manual: create a new workspace via WS event, verify x ≠ y

🤖 Generated with Claude Code

- computeAutoLayout() BFS tree layout seeds from anchored nodes; assigns
  distinct x/y to workspaces returned at 0,0 by the API and persists via PATCH
- buildNodesAndEdges() accepts layoutOverrides map so hydration uses computed
  positions instead of raw 0,0 coordinates
- canvas-events WORKSPACE_PROVISIONING grid layout replaces offset===offset
  assignment that caused position:{x:t,y:t} in the minified bundle
- 8 new vitest tests cover computeAutoLayout and override behaviour (365 pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor Author

7-gate verification passed:

  • Gate 1: CI 6/6 green
  • Gate 2: canvas build OK
  • Gate 3: 365 tests pass (13 new)
  • Gate 4: no secrets, no new env reads, no XSS surfaces (data is typed WorkspaceData)
  • Gate 5: no confirm/alert/prompt, dark theme preserved
  • Gate 6: magic numbers extracted to named constants (H_SPACING, V_SPACING, GRID_COL_WIDTH, etc.); 7 new unit tests cover computeAutoLayout branches
  • Gate 7: Playwright smoke confirms 3 new nodes spread horizontally (not stacked); screenshot verified

Merging.

@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit 6722d4c into main Apr 14, 2026
6 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/node-stacking branch April 14, 2026 04:32
HongmingWang-Rabbit pushed a commit that referenced this pull request Apr 14, 2026
Adds a `canvas-deploy-reminder` job to ci.yml that fires on every
push to main once `canvas-build` passes. It posts a commit comment via
the built-in GITHUB_TOKEN (no new secrets needed) reminding whoever
monitors CI to run:

  cd /g/personal_programs/molecule-monorepo
  git pull origin main
  docker compose build canvas && docker compose up -d canvas

The comment includes the commit SHA and a direct link to the build log.

Rationale: 5 consecutive merge cycles (PRs #21, #25, #30, #32, #34)
went undeployed because there is no auto-deploy hook and the manual
step was silently forgotten. A commit comment on the merge commit is
the lowest-friction reminder that requires no external secrets or infra.

Does NOT run on PRs — only on direct pushes to main (i.e. post-merge).
Uses `needs: canvas-build` so the reminder only fires after build+tests
pass; a failing build produces no comment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HongmingWang-Rabbit pushed a commit that referenced this pull request Apr 14, 2026
…ewport clipping

New nodes now start at (100, 100) instead of (0, 0), preventing them from
being clipped at the viewport edge. Also normalises the index source from
filtered root-only nodes to nodes.length, consistent with the form-created
node path from PR #25.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
fix: auto-layout zero-position nodes, fix new-node x===y stacking
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
Adds a `canvas-deploy-reminder` job to ci.yml that fires on every
push to main once `canvas-build` passes. It posts a commit comment via
the built-in GITHUB_TOKEN (no new secrets needed) reminding whoever
monitors CI to run:

  cd /g/personal_programs/molecule-monorepo
  git pull origin main
  docker compose build canvas && docker compose up -d canvas

The comment includes the commit SHA and a direct link to the build log.

Rationale: 5 consecutive merge cycles (PRs #21, #25, #30, #32, #34)
went undeployed because there is no auto-deploy hook and the manual
step was silently forgotten. A commit comment on the merge commit is
the lowest-friction reminder that requires no external secrets or infra.

Does NOT run on PRs — only on direct pushes to main (i.e. post-merge).
Uses `needs: canvas-build` so the reminder only fires after build+tests
pass; a failing build produces no comment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant