Skip to content

refactor(web): Phase C — consolidate to one Force Graph plugin#367

Merged
aaronsb merged 3 commits into
mainfrom
refactor/consolidate-force-graph
May 14, 2026
Merged

refactor(web): Phase C — consolidate to one Force Graph plugin#367
aaronsb merged 3 commits into
mainfrom
refactor/consolidate-force-graph

Conversation

@aaronsb
Copy link
Copy Markdown
Owner

@aaronsb aaronsb commented May 14, 2026

Summary

Phase C of the unified-engine work (ADR-702). Three force-graph plugin entries collapse to one. Projection is now a user-facing setting on the single plugin, not a separate explorer type. The d3 `react-force-graph-2d` dependency goes away.

End state:

  • One sidebar entry: Force Graph
  • One canonical route: `/explore/graph` (with redirects from `/explore/2d` and `/explore/3d` that preserve query params)
  • One plugin in the registry: `ForceGraphExplorer`
  • 2D ↔ 3D toggle lives in the plugin's settings panel

Commits

  1. `b87d58a6` `refactor(web): retire d3 ForceGraph2D plugin and dead support code` — deletes `ForceGraph2D/`, drops `react-force-graph-2d`, removes the now-unused `graphTransform.ts`, `GraphSettingsPanel.tsx`, `usePrefetchSubgraph`, and the `force-2d` special-case in `ExplorerView`. ~2.9k lines deleted.
  2. `e836f683` `refactor(web): consolidate to single Force Graph plugin with projection toggle` — collapses the two unified-engine registrations (`force-3d`, `force-2d-v2`) into one `force-graph` plugin, adds canonical route + legacy redirects, updates the sidebar and home-screen NavigationGraph.
  3. `5707bae3` `refactor(web): rename ForceGraph3D to ForceGraph and scrub V1/V2 framing` — directory, component, and types renamed (the `3D` suffix became misleading once 2D shared the engine). All renames are git-tracked moves so blame history follows. Way docs updated.

Manual verification (recommended before merge)

The vitest suite and `tsc --noEmit` are clean, but neither exercises the runtime paths this PR touches. Worth checking in the browser:

  • `/explore/2d?c=<concept_id>&d=2` redirects to `/explore/graph?c=<concept_id>&d=2` (query params preserved)
  • `/explore/3d` redirects to `/explore/graph`
  • Sidebar shows a single "Force Graph" entry; clicking it lands on `/explore/graph`
  • Settings panel projection dropdown toggles between 2D and 3D
  • "Send to Reports" produces a report whose representation matches the active projection (`force_graph_2d` vs `force_graph_3d`)
  • Home-screen NavigationGraph shows one Force Graph node (no collisions in the explore category)

`kg-web-dev` HMR may need a one-time `docker restart kg-web-dev` after pulling — a whole-dir rename plus symbol renames can leave the Vite module graph stale.

Notes

  • `/explore/2d-v2` was dropped without a redirect — it was a dev-only route from PR feat(web): add 2D projection to the unified engine (force-2d-v2) #366 with no bookmarks to honor. Per `.claude/ways/kg/web/evolution/evolution.md` ("Skip Redirects for Never-Public Routes").
  • Persisted Zustand `selectedExplorer` may hold stale `'force-2d'` / `'force-3d'` for existing users. Nothing branches on it outside `graphStore.ts` (`ExplorerView` calls `setSelectedExplorer('force-graph')` on mount), so no migration is needed — the value is overwritten on first explorer visit.
  • The d3 ForceGraph2D interaction model (left-pan, right-context) is preserved in the R3F 2D projection. Documented in `.claude/ways/kg/web/explorers/explorers.md`.

References

aaronsb added 3 commits May 14, 2026 08:31
The unified r3f engine now serves both 2D and 3D projections (ADR-702),
so the d3 `react-force-graph-2d` plugin has no remaining role.

Removed:
- `web/src/explorers/ForceGraph2D/` — entire plugin
- `react-force-graph-2d` dependency
- `web/src/utils/graphTransform.ts` — only consumed by the d3 plugin and
  one unused `usePrefetchSubgraph` hook
- `web/src/explorers/common/GraphSettingsPanel.tsx` — last consumer was
  the d3 plugin's ProfilePanel
- `usePrefetchSubgraph` in `useGraphData.ts` — never called

Cleaned the `force-2d` special-case out of `ExplorerView` (the legacy
GraphSettingsPanel branch), the sidebar entry in `AppLayout`, the
`/explore/2d` route in `App.tsx`, and the `'force-2d'` member of the
`VisualizationType` union. The Zustand default falls back to
`'force-3d'` until plugin consolidation lands.

`/explore/2d-v2` and `/explore/3d` remain as the unified-engine routes
during the consolidation step that follows.
…on toggle

Three plugin entries (force-2d-v2, force-3d, plus the now-retired d3
force-2d) collapse into one `force-graph` plugin backed by the unified
r3f + GPU engine (ADR-702). Projection is a user-facing setting inside
the plugin — the engine dispatches camera, drag plane, and sim axis
count from `settings.projection`.

User-visible changes:
- Sidebar shows a single "Force Graph" entry (was two)
- Canonical route is `/explore/graph`
- Legacy `/explore/2d` and `/explore/3d` redirect to `/explore/graph`
  via a small `RedirectPreservingSearch` helper, so bookmarked concept
  ids and depth params carry over
- `/explore/2d-v2` removed without a redirect — it was an in-flight
  dev-only route from PR #366

Code changes:
- VisualizationType: drop `force-2d-v2`, `force-3d`; add `force-graph`
- `ForceGraph3D/index.ts`: drop the `createForceGraphPlugin` factory;
  export a single `ForceGraphExplorer`
- Reports record the active projection from settings (not from the
  explorer type, which is no longer 2D/3D-discriminated)
- Home screen NavigationGraph replaces the two 2D/3D nodes with one
  Force Graph node
- AppLayout drops the now-unused Boxes and Map icons; uses Network for
  the consolidated explorer
- Zustand `selectedExplorer` defaults to `'force-graph'`
After consolidation (previous commit), the engine handles both
projections — the `3D` suffix on the directory, file, component, and
type names became misleading. Renamed:

- `web/src/explorers/ForceGraph3D/` → `web/src/explorers/ForceGraph/`
- `ForceGraph3D.tsx` → `ForceGraph.tsx`
- Component `ForceGraph3D` → `ForceGraph`
- Type `ForceGraph3DData` → `ForceGraphData`
- Type `ForceGraph3DSettings` → `ForceGraphSettings`
- On-canvas debug label "ForceGraph3D" → "Force Graph"

git tracks all moves as renames (no content drift), so blame history
follows.

Comment scrub for transitional V1/V2/d3-coexistence framing in
`common/useGraphContextMenu.ts`, `common/nodeColors.ts`,
`ForceGraph/scene/EdgeLabels.tsx`, and `ForceGraph/scene/Scene.tsx` —
those readers no longer have a V1 to compare against.

Ways updated to match: `web/explorers/explorers.md` references the new
path and rewords the interaction-model section now that d3
ForceGraph2D is gone; `web/evolution/evolution.md` adds a Phase C
reference.

Per `.claude/ways/kg/web/evolution/evolution.md` ("Drop Transitional
Framing Post-Promotion").
@aaronsb aaronsb merged commit b716d81 into main May 14, 2026
3 checks passed
@aaronsb aaronsb deleted the refactor/consolidate-force-graph branch May 14, 2026 14:49
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