feat(viewer): render SGCR annotations — overlay layer, layer toggle, addAnnotation patch op (#202)#205
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #202. Wires the layered annotation engine (#197) into the viewer.
What
A
flowspec withengine:"sgcr"may carryannotations: [{id, anchor, text, layer, priority?, color?, prefer?}](anchor = a node, an edge midpoint, or a point). The viewer runsplaceAnnotationsagainst 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 bylayer(palette + per-annotation override); a top-left panel toggles each layer (placement always runs over all layers, so toggling never shifts a box).fitViewwas upgraded to frame the union of node + annotation bounds so peripheral annotations aren't clipped.Live/iterative:
addAnnotation/removeAnnotationpatch 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
npm run test:annotations(real viewer: renders + asserts no overlap + toggle hides a layer)Follow-up (separate): annotations for the dagre engine (no polyline edges / no P10 guarantee there).