fix: preserve edge connection points in YAML export/import (#208)

YAML round-trip dropped every edge's handles: export never wrote them
and import hardcoded sourceHandle='bottom'/targetHandle='top-t'. After
import all connections collapsed onto slot 0 ("converge at a single
point"). Per-side handle counts were dropped too, so the extra bottom
slots did not even exist to attach to.

- yaml types: add sourceHandle/targetHandle to connections and
  top/bottom/left/rightHandles to nodes
- export: write each edge's real handles + per-side counts (only above
  the side default); orient parent-edge handles parent->child
- import: restore handle counts onto node data and use the stored
  handles, falling back to the legacy defaults for pre-existing YAML

Positions remain dagre-managed (unchanged); this restores connection
points only.

ha-relevant: yes
This commit is contained in:
Pouzor
2026-07-07 11:16:29 +02:00
parent 65a1f49f93
commit 7bc3e5d8a0
5 changed files with 148 additions and 7 deletions
+11
View File
@@ -4,6 +4,10 @@ export interface YamlNodeConnection {
label: string
linkType?: EdgeType
linkLabel?: string
// Connection points (React Flow handle IDs) the edge attaches to. Preserved so
// a manual layout round-trips instead of collapsing every edge onto slot 0.
sourceHandle?: string
targetHandle?: string
}
export interface YamlNode {
@@ -23,4 +27,11 @@ export interface YamlNode {
cpuCore?: number
ram?: number
disk?: number
// Per-side connection-point counts. Only written when a side has more than its
// default (top/bottom 1, left/right 0) so the referenced handle slot exists on
// re-import — without it React Flow falls back to slot 0.
topHandles?: number
bottomHandles?: number
leftHandles?: number
rightHandles?: number
}