Commit a914d4b
committed
feat(vbgui-fb): React Flow canvas + 25 brick + 6 adapter custom nodes
Stage F-B of the Visual Builder GUI epic (cppmega-mlx-o0k). New
vbgui/ workspace scaffolds the frontend per VisualBuilderPlan.md §3.1
and §4.1-4.2.
Stack: Vite + React 18 + @xyflow/react v12 + TypeScript +
ELK.js for auto-layout + vitest/jsdom for tests.
Components:
- BrickNode — generic brick renderer parametrised by kind. Reads
category color from CATEGORY_COLORS, renders resolved shape badge,
memory bar, side-channel warning when missing.
- AdapterNode — dashed border + ghost preview support.
- Palette — left-rail draggable source, brick tiles grouped by
category, adapter tiles below. Emits application/x-cppmega-brick
and application/x-cppmega-adapter mime types on dragstart.
- FlowCanvas — React Flow root with onConnect / onDropBrick callbacks,
edge styling by severity (green/amber/red) + dashed grey for adapter.
- App — wires Palette into FlowCanvas, drag-drop adds a node and edge
creation populates with severity=info.
Library modules:
- lib/types.ts — handwritten TS mirror of cppmega_v4.jsonrpc.schema
Pydantic models (SCHEMA_VERSION 1.0.0).
- lib/bricks.ts — 25 BRICKS (matches BLOCK_BUILDERS post-GalCov-B) +
6 ADAPTERS + 8 category colors. brickFor/adapterFor lookups.
- lib/rpc.ts — JSON-RPC 2.0 client over fetch POST /rpc with abort
controller for timeout, RpcError envelope.
- lib/elk.ts — layoutFlow helper (synchronous; F-C moves to worker).
Tests (29 across 6 files, vitest + jsdom + Testing Library):
- bricks: 22-minimum-25-actual count, unique kinds, 6-adapter lock,
color coverage, fall-through lookups.
- rpc: envelope shape, id increment, error envelope, HTTP failure,
abort/timeout.
- BrickNode/AdapterNode: label render, shape badge, memory bar,
side-channel warning, unknown-kind fallback.
- Palette: every brick + adapter renders draggable; dragstart mimes.
- FlowCanvas: empty mount, drop event delivery, brick mime parsing.
- elk: chained nodes laid out left-to-right; empty graph identity.
Build: vite build emits 537kB JS / 16kB CSS (gzip 167kB / 2.6kB).
jsdom shims for ResizeObserver + DOMMatrixReadOnly added in
tests/setup.ts so React Flow runs under vitest.
Closes cppmega-mlx-o0k.2.1 parent 7422406 commit a914d4b
23 files changed
Lines changed: 5178 additions & 0 deletions
File tree
- vbgui
- src
- components
- lib
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments