Skip to content

feat(viewer): render SGCR annotations — overlay layer, layer toggle, addAnnotation patch op (#202)#205

Merged
ivanmkc merged 2 commits into
masterfrom
feat/annotations-viewer
Jun 22, 2026
Merged

feat(viewer): render SGCR annotations — overlay layer, layer toggle, addAnnotation patch op (#202)#205
ivanmkc merged 2 commits into
masterfrom
feat/annotations-viewer

Conversation

@ivanmkc

@ivanmkc ivanmkc commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Closes #202. Wires the layered annotation engine (#197) into the viewer.

What

A flow spec with engine:"sgcr" may carry annotations: [{id, anchor, text, layer, priority?, color?, prefer?}] (anchor = a node, an edge midpoint, or a point). The viewer runs placeAnnotations against the measured layout and renders each placed annotation (box + dashed leader to its anchor) as a ViewportPortal overlay — pan/zoom-aware and fully decoupled from the node-state machinery, so it never disturbs the measured re-pass. Boxes are coloured by layer (palette + per-annotation override); a top-left panel toggles each layer (placement always runs over all layers, so toggling never shifts a box). fitView was upgraded to frame the union of node + annotation bounds so peripheral annotations aren't clipped.

Live/iterative: addAnnotation / removeAnnotation patch ops let an agent annotate a living diagram across turns; the placer defers cleanly when there's no room.

Verified live (deployed rev 00095-kg8)

Pushed an annotated state-machine and scraped the real DOM: 5 annotations rendered, 0 overlaps with nodes (P10 in the browser), 0 clipped, 3 layers, and the risk toggle hid 2 (5→3). Screenshot: badges/owner-tags/latency-chip with leaders, all clean.

Tests

Follow-up (separate): annotations for the dagre engine (no polyline edges / no P10 guarantee there).

…patch op

Wires the layered annotation engine (#197) into the viewer. A `flow` spec
with `engine:"sgcr"` may carry `annotations: [{id, anchor, text, layer, …}]`;
the viewer runs placeAnnotations against the measured layout and renders each
placed annotation (box + dashed leader to its anchor) as a ViewportPortal
overlay — pan/zoom-aware and decoupled from the node-state machinery, so it
never disturbs the measured re-pass. Boxes are coloured by `layer` (palette +
optional per-annotation override); a top-left panel toggles each layer's
visibility (placement always runs over all layers, so toggling never shifts a
box). Anchor a node, an edge (placed near its midpoint), or a point.

Live/iterative: `addAnnotation` / `removeAnnotation` patch ops (flow-patch.ts)
let an agent annotate a living diagram across turns; the placer defers cleanly
when there's no room.

Overlap-freedom (P10) is proven by the engine and re-checked live: a new
e2e (`npm run test:annotations`) renders an annotated spec in a real browser
and asserts no annotation box overlaps a node + the layer toggle hides a layer.
Plus flow-patch unit tests for the new ops.
@ivanmkc ivanmkc merged commit 337bf6c into master Jun 22, 2026
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.

feat(viewer): wire the SGCR annotation placer into the viewer (overlay layer + addAnnotation patch op)

2 participants