Raven-1/ui-web/package.json
xfng-sd 711f262d79
fix(ui-web): route dag edges around the layers they skip (#761)
## Summary

The task board's DAG layout centred every layer on the graph's midline
and drew each edge as a single curve between box centres. An edge that
skips a layer therefore ran straight through the box centred in that
layer. In a real research-to-deck run (`ppt_build` depends on
`ppt_outline` and on the three research nodes `ppt_outline` already
depends on), the `research_rl_algo -> ppt_build` edge was drawn exactly
under `ppt_outline` and its own edge, so it could not be seen at all.

- `graph.ts`: `layout()` now uses `@dagrejs/dagre` (about 48 KB
minified, synchronous) for in-layer ordering and edge routing, and
returns an `edges` list of routes alongside the node positions.
- Layers stay depth-by-longest-path, forced through each edge's
`minlen`, so a root always sits on the first layer instead of drifting
down beside the one node it feeds.
- An edge that skips a layer bends through the gap dagre leaves in that
layer, clear of every box.
- Edges meeting one face of a box get their own ports, sorted by the
direction they head off in, instead of all landing on the midpoint.
- dagre often returns a fan-out mirrored; the layout flips it back when
that reads closer to the server's node order (mirroring changes no
crossing).
- `DagGraph.tsx`: draws each route as flow-axis curves through its
points. Arrowheads and classes are unchanged.
- `Board.tsx` (pan/zoom) and `TasksPage` are untouched. React Flow was
considered and rejected: it does no layout itself, and would replace the
working viewport without fixing this.
- The offline tasks fixture gains this graph on session `c`, so the
board can be checked with `?stub=1`.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `npm run type-check`: clean
- `npx eslint src/features/dag src/rpc/fixtures/tasks.ts`: clean
- `npx vitest run`: 2947 passed, 1 failed. The failure is
`scripts/gates/settings-drawer-css.test.mjs`, which builds a malformed
Windows path (`D:\D:\...`) and is unrelated to this change.
- Every existing layout test passes unedited. New tests, in both flows:
- no segment of any edge route passes through a box, for this graph and
for a mixed one; removing the bends makes 4 of them fail
  - edges into and out of one box land at distinct ports
  - a root that feeds only a deep node stays on the first layer
- `npx vite build`: succeeds
- Eyeballed on the stub data: open session `c` -> Tasks tab -> "Survey
recent RL progress and build a slide deck"

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

- [x] Security impact considered (a new client-side layout dependency
only)
- [x] Backward compatibility considered (`DagLayout` gains a field; no
caller reads it besides `DagGraph`)
- [x] Rollback path is clear for risky changes (revert this one commit)

## Related Issues

N/A

Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
2026-09-24 20:23:26 +08:00

44 lines
1.2 KiB
JSON

{
"name": "raven-ui",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"gen": "node scripts/gen-rpc-client.mjs",
"gen:check": "node scripts/gen-rpc-client.mjs --check",
"type-check": "tsc --noEmit -p tsconfig.json",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest run",
"build": "vite build"
},
"devDependencies": {
"@eslint/js": "^9.39.4",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.18",
"@types/react-dom": "^19.2.4",
"@typescript-eslint/eslint-plugin": "^8.59.3",
"@typescript-eslint/parser": "^8.59.3",
"@vitejs/plugin-react": "^6.0.5",
"eslint": "^9.39.4",
"eslint-plugin-perfectionist": "^5.9.0",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-unused-imports": "^4.4.1",
"globals": "^16.5.0",
"happy-dom": "^20.11.2",
"json-schema-to-typescript": "^15.0.4",
"typescript": "^5.7.0",
"vite": "^8.2.1",
"vitest": "^4.1.3"
},
"dependencies": {
"@dagrejs/dagre": "^3.1.1",
"@hugeicons/core-free-icons": "^4.3.5",
"@hugeicons/react": "^1.1.10",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"shiki": "^4.4.3",
"temml": "^0.13.5"
}
}