mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 22:03:22 +08:00
Project discover neighbors from scanned seeds only.
Accept optional seed ids on project-neighbors; canvas discover passes scanned fabric nodes and places new peers near them. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7cd89aaae9
commit
03ef9eb39a
9 changed files with 137 additions and 18 deletions
|
|
@ -1620,13 +1620,16 @@ export function TopologyPage() {
|
|||
throw new Error(job.error || "discover_failed");
|
||||
}
|
||||
const projected = discoverProjectNeighbors
|
||||
? await projectTopologyNeighbors(mapId)
|
||||
? await projectTopologyNeighbors(mapId, {
|
||||
seed_fabric_node_ids: scoped.map((n) => n.id),
|
||||
})
|
||||
: await fetchTopologyGraph(mapId);
|
||||
queryClient.setQueryData(queryKeys.topologyGraph(mapId), projected);
|
||||
appliedMapIdRef.current = mapId;
|
||||
let { rfNodes, rfEdges } = graphToFlow(projected.nodes, projected.edges, edgeDefaults);
|
||||
// Keep existing node positions when we did not auto-layout.
|
||||
const localPos = new Map(nodes.map((n) => [n.id, n.position]));
|
||||
const beforeIds = new Set(nodes.map((n) => n.id));
|
||||
rfNodes = rfNodes.map((n) => {
|
||||
const p = localPos.get(n.id);
|
||||
return p ? { ...n, position: { ...p } } : n;
|
||||
|
|
@ -1649,7 +1652,8 @@ export function TopologyPage() {
|
|||
setNodes(rfNodes);
|
||||
setEdges(rfEdges);
|
||||
historyLockRef.current = false;
|
||||
if (didAutoLayout) {
|
||||
const addedNodes = rfNodes.filter((n) => !beforeIds.has(n.id)).length;
|
||||
if (didAutoLayout || addedNodes > 0) {
|
||||
needsInitialFitRef.current = true;
|
||||
scheduleFitView(FIT_VIEW_OPTS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue