feat(marker): add optional color field to marker data model

Add a user-chosen hex color (e.g. '#ff5722') to each marker, stored in
Link._markers alongside bpf/tag/enabled. The color:

- Is serialized with the link (asdict) and persisted in the topology, so
  it survives project reload and is consistent across devices.
- Never reaches uBridge (compute ignores it) — it is purely a Web UI
  concern.
- Can be updated independently of the BPF (color-only changes skip the
  ubridge round-trip).

MarkerCreate schema gains color: Optional[str]; start_marker and
update_marker carry it through; REST create/update endpoints pass it.

The marker.match WebSocket event stays lean (no color) — the Web UI maps
filter -> color from the link state it already holds.
This commit is contained in:
YueGuobin committed 2026-07-16 00:39:51 +08:00
1 parent b8f49696cc
commit 3f15ac38f6
3 files changed
+27 -7

No files matched your search

+5 -2
View File
@@ -454,12 +454,14 @@ async def create_marker(
Required privilege: Link.Modify
"""
name = marker_data.name or f"marker-{link.id[:8]}"
await link.start_marker(
name=marker_data.name or f"marker-{link.id[:8]}",
name=name,
bpf=marker_data.bpf,
tag=marker_data.tag,
color=marker_data.color,
)
return link.markers.get(marker_data.name, {})
return link.markers.get(name, {})
@router.delete(
@@ -499,6 +501,7 @@ async def update_marker(
name=marker_name,
bpf=marker_data.bpf if marker_data.bpf else None,
tag=marker_data.tag,
color=marker_data.color,
)
return link.markers.get(marker_name, {})