Skip to content

feat(web): 2D directional dependency-graph renderer (TASK-1783) - #720

Merged
xarmian merged 2 commits into
mainfrom
feat/graph-2d-renderer
Jun 8, 2026
Merged

feat(web): 2D directional dependency-graph renderer (TASK-1783)#720
xarmian merged 2 commits into
mainfrom
feat/graph-2d-renderer

Conversation

@xarmian

@xarmian xarmian commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds ItemGraph.svelte — a reusable component that renders a single item's dependency neighborhood as a 2D layered/directional graph (parents above, children below) using dagre for layout and SVG for rendering. This is the renderer for the per-item graph view (PLAN-1780); the drawer + item-header button that mount it are the next task (TASK-1784).

Details

  • Lazy dagre: @dagrejs/dagre is dynamically imported inside the layout function, so it lands in its own chunk and stays out of the main bundle (verified).
  • Data: fetches via api.graph.getFocused (TASK-1782). Re-roots on an internal currentFocus — clicking a non-focus node navigates the dependency chain; clicking the focus node (or the Open ↗ button) calls onOpenItem. Depth (1–5) selector, include-done toggle, breadcrumb back to the original root.
  • Visuals: edge styling by type (hierarchy tethers, red directional blocks arrows with arrowhead markers, faint wiki-link dashes, muted others); collection-colored nodes with a focus highlight and dimmed terminals; pan (drag) + zoom (wheel) + fit-to-content; collection legend; truncation notice when the server capped the neighborhood.
  • Reactivity: follows CONVE-1688 (a loadToken guard so the load effect never read+writes the same rune; stale responses discarded) and CONVE-606 (data-load effect kept separate from the prop-sync effect).
  • Shared palette: extracted the collection-color palette into $lib/graph/palette.ts and pointed the existing 3D workspace graph at it too, so both views agree on which collection gets which color.

Context

Implements TASK-1783 under PLAN-1780. Consumes the backend (TASK-1781, #718) and client (TASK-1782, #719).

Test plan

  • cd web && npm run check — 0 errors (preexisting unrelated warnings only; none in the new files)
  • cd web && npm run build — clean; dagre confirmed in its own lazy chunk
  • Authored with the Svelte MCP autofixer (clean)
  • [n/a] go tests — no Go changes

xarmian added 2 commits June 8, 2026 22:27
Add ItemGraph.svelte — a reusable, self-contained component that renders a
single item's dependency neighborhood as a 2D layered graph (parents above,
children below) via dagre layout + SVG.

- Lazy-imports @dagrejs/dagre so the layout lib stays out of the main
  bundle (confirmed split into its own chunk).
- Fetches via api.graph.getFocused; re-roots on an internal currentFocus so
  clicking a non-focus node navigates the chain, clicking the focus node (or
  Open ↗) opens it. Depth (1–5) selector + include-done toggle; breadcrumb
  back to the original root.
- Edge styling by type (hierarchy tethers, red directional blocks arrows,
  faint wiki-link dashes, muted others); collection-colored nodes with
  focus highlight + dimmed terminals; pan/zoom + fit-to-content; legend and
  a truncation notice.
- Reactivity follows CONVE-1688 (loadToken guard, no read+write of one rune
  in an effect) and CONVE-606 (data-load effect split from prop-sync).

Extract the collection palette into a shared $lib/graph/palette.ts and point
the 3D workspace graph at it too, so both views agree on collection colors.

Parent: PLAN-1780.
…per Codex review (round 1)

- P1: 'parent'/'implements' edges are child→parent in the API, so feeding
  them to dagre as-is put children above parents under rankdir TB. Reverse
  those edges for layout ranking only; rendered edges keep true source→target
  so 'blocks' arrowheads still point correctly.
- P2: unfocused node border used a JS string literal with an un-interpolated
  {n.color}, yielding an invalid CSS color and a dropped stroke. Use a
  template literal so the collection tint actually applies.

Parent: PLAN-1780.
@xarmian
xarmian merged commit 771d102 into main Jun 8, 2026
4 checks passed
@xarmian
xarmian deleted the feat/graph-2d-renderer branch June 8, 2026 22:34
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