Skip to content

refactor(frontend): extract GraphCanvas's incremental placement into layout.ts - #32

Merged
MCR-3 merged 2 commits into
mainfrom
30-graphcanvas-placement-layout
Sep 22, 2026
Merged

MCR-3 merged 2 commits into
mainfrom
30-graphcanvas-placement-layout

Conversation

@MCR-3

@MCR-3 MCR-3 commented Sep 22, 2026

Copy link
Copy Markdown
Member

Summary

  • The "pop a new card in next to its active caller" placement algorithm lived as a closure inside GraphCanvas's node-rebuild effect, closing over refs and DOM state, with no seam reachable outside the mounted component.
  • Extracted it as placeIncrementally() in frontend/src/layout.ts, alongside layoutGraph/layoutFolderGraph, taking the viewport-center fallback as a plain Point instead of reading it internally.
  • No behavior change: pure extraction surfaced by an architecture review.

Test plan

  • npm run build and npm run lint pass
  • Verified live via docker compose up: activating a function places its card next to an already-visible active caller or callee without disturbing existing positions, and falls back to the viewport center when there's no visible neighbor; no console errors

Closes #30

…layout.ts

The "pop a new card in next to its active caller" placement algorithm
lived as a closure inside GraphCanvas's node-rebuild effect, closing
over refs and DOM state, with no seam reachable outside the mounted
component. layout.ts's other two layout functions (layoutGraph,
layoutFolderGraph) are already pure and independently reasoned about;
placeIncrementally joins them, taking the viewport-center fallback as a
plain Point instead of reading it internally.

Verified via npm run build / npm run lint, and live in the browser:
activating a function places its card next to an already-visible active
caller or callee without disturbing existing positions, and falls back
to the viewport center when there's no visible neighbor.

Closes #30
@MCR-3
MCR-3 merged commit ed61b69 into main Sep 22, 2026
2 checks passed
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.

Extract GraphCanvas's incremental card-placement algorithm into layout.ts

1 participant