Optimize topology canvas per the 2026-10-12 plan.

Save path: one atomic POST /views/{id}/commit (edges, ports, styles, node
add/remove, positions) replaces the multi-request save. Edge styles and
manual-edge port edits now go through dirty/undo/save instead of writing
immediately; non-manual edge ports are read-only.

Data safety: UI saves no longer clear MCP node locks or freeze the device
name into the placement label (label_override + omit-means-keep semantics,
also applied to the MCP positions tool). Adding NEs/neighbors with unsaved
edits now saves first instead of silently dropping them. Positions no longer
bypass membership caps, except persisting synthesized child-region icons.

Fixes found in acceptance: nodes added in the same commit kept (40,40)
under autoflush=False; edits on edges deleted in the same save 404'd the
whole save; box-selection drags and arrow-key moves were not marked dirty;
large canvases far from the origin opened blank and locate did nothing
because fitView waits for measurement that onlyRenderVisibleElements never
does (now fitBounds from known geometry).

Also: batch N+1 lookups in graph/positions, deterministic truncation,
outside-peer scan excludes internal edges, split TopologyPage into hooks,
fix flaky UME/LLDP port test, add scripts/topology_clear_frozen_labels.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
oliver 2026-10-12 22:11:22 +08:00
parent 60a0ea6021
commit f301544b99
40 changed files with 5587 additions and 1916 deletions

View file

@ -38,6 +38,8 @@ from .topology_schemas import (
TopologyPlaceholderCreate,
TopologyViewCreate,
TopologyViewUpdate,
FabricEdgePortsPatch,
ViewCommitIn,
ViewEdgeStylePatch,
ViewNodesAdd,
ViewNodesRemove,
@ -61,6 +63,7 @@ from .topology_fabric import (
from .topology_views import (
add_nodes_to_view,
bootstrap_topology_tree,
commit_view_changes,
create_folder,
create_topology_placeholder_on_view,
create_view,
@ -69,6 +72,7 @@ from .topology_views import (
get_topology_tree,
get_view_graph,
list_views,
patch_manual_edge_ports,
patch_view_edge_style,
patch_view_positions,
populate_view,
@ -481,6 +485,32 @@ def api_edge_style(
return patch_view_edge_style(db, view_id, body).model_dump()
@router.post("/views/{view_id}/commit")
def api_commit_view(
view_id: str, body: ViewCommitIn, db: Session = Depends(get_db)
) -> dict[str, Any]:
return commit_view_changes(db, view_id, body).model_dump()
@router.patch("/fabric/edges/{edge_id}")
def api_patch_fabric_edge_ports(
edge_id: str, body: FabricEdgePortsPatch, db: Session = Depends(get_db)
) -> dict[str, Any]:
edge = patch_manual_edge_ports(
db, edge_id, a_port=body.a_port, b_port=body.b_port, commit=True
)
return {
"id": edge.id,
"a_node_id": edge.a_node_id,
"b_node_id": edge.b_node_id,
"a_port": edge.a_port or "",
"b_port": edge.b_port or "",
"source": edge.source or "manual",
"status": edge.status or "active",
"layer": edge.layer or "physical",
}
# --- Classify rules / slices / search ---------------------------------------