Skip to content

Add annotations API for persisting node positions - #1

Draft
ldrozdz93 wants to merge 2 commits into
mainfrom
feature/annotations-endpoint-for-ui-persistance
Draft

Add annotations API for persisting node positions#1
ldrozdz93 wants to merge 2 commits into
mainfrom
feature/annotations-endpoint-for-ui-persistance

Conversation

@ldrozdz93

@ldrozdz93 ldrozdz93 commented Mar 23, 2026

Copy link
Copy Markdown
Owner

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/annotations endpoints to the clab graph HTTP server that persist node position data to .clab-topo-editor.json next 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 topoViewer position storage:

{
  "nodeAnnotations": [
    { "id": "srl1", "position": { "x": 100, "y": 200 } }
  ]
}

API

  • GET /api/v1/annotations — returns saved positions, or {"nodeAnnotations":[]} if the file doesn't exist
  • POST /api/v1/annotations — writes the request body JSON to .clab-topo-editor.json

lukasz-drozdz-codilime and others added 2 commits March 23, 2026 09:39
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>
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.

2 participants