Files
Understand-Anything/understand-anything-plugin/packages/dashboard/src/utils
AnnulusLabsandClaude Opus 4.6 7bfcba677b fix: move dagre layout to Web Worker for large graphs
Fixes #14 — dashboard becomes unusable with large knowledge graphs (2,700+ nodes).

- Web Worker for dagre layout: graphs above 200 nodes compute layout off the
  main thread via a dedicated Web Worker, keeping the UI responsive
- Request ID correlation: concurrent layout calls are routed by incrementing
  request ID, preventing race conditions where results cross-wire
- Worker error handling: onerror rejects pending promises; GraphView catches
  errors and clears the loading spinner
- Cancellation cleanup: effect cleanup clears layouting state to prevent
  stuck spinners when the graph switches below the async threshold
- Topology/visual split: dagre only re-runs when graph structure changes;
  node selection, tour highlights, and search results are applied as a
  cheap O(n) overlay without triggering relayout
- React.memo on CustomNode: prevents O(n) re-renders when selecting
  individual nodes in large graphs
- Zero overhead for small graphs: below 200 nodes, the original synchronous
  layout path is used unchanged

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 10:37:12 -06:00
..