Add annotations API for persisting node positions - #1
Draft
ldrozdz93 wants to merge 2 commits into
Draft
Conversation
Add GET/POST /api/v1/annotations endpoints to ServeTopoGraph that read and write node position data to .clab-topo-editor.json next to the topology file. Compatible with the VSCode containerlab extension format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Auto-fixed by golangci-lint fmt, gofumpt, and godot to satisfy make format before the annotations PR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Notes
This is a draft PR to gather feedback from maintainers. A companion React-based UI that consumes this API exists but is not part of this PR — the endpoints are useful independently for any custom frontend or tooling.
Code will be thoroughly reviewed and improved before the PR is marked ready for review.
Summary
Add
GET/POST /api/v1/annotationsendpoints to theclab graphHTTP server that persist node position data to.clab-topo-editor.jsonnext to the topology file.This enables interactive graph UI frontends to save and restore node positions across browser sessions — for example after dragging nodes into a preferred layout, positions survive a page refresh.
The file format is intentionally compatible with the VSCode containerlab extension's
topoViewerposition storage:{ "nodeAnnotations": [ { "id": "srl1", "position": { "x": 100, "y": 200 } } ] }API
GET /api/v1/annotations— returns saved positions, or{"nodeAnnotations":[]}if the file doesn't existPOST /api/v1/annotations— writes the request body JSON to.clab-topo-editor.json