Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring
TypeScript diagramhomelabhomelab-infrastructure-observabilitynetworkproxmox-veself-hostedzigbeezwavezwave-js
fix(proxmox): no host link for a guest nested in container mode
Pouzor54176983b658
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 249f016..5992b73 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -972,8 +972,11 @@ export default function App() {}addNode(newNode)})- // Host → guest links render as 'virtual' edges (VM/LXC ↔ host).+ // Host → guest links render as 'virtual' edges (VM/LXC ↔ host). A nested+ // guest gets none: sitting inside the host already says it runs there, and+ // the edge just loops out of the box and back (#399 follow-up).pmEdges.forEach((pe) => {+ if (hostOfChild[pe.target] === pe.source && mode === 'container') returnonConnect({source: pe.source,sourceHandle: 'bottom',diff --git a/frontend/src/components/modals/DeviceInventoryModal.tsx b/frontend/src/components/modals/DeviceInventoryModal.tsxindex 799d534..a4e96d0 100644--- a/frontend/src/components/modals/DeviceInventoryModal.tsx+++ b/frontend/src/components/modals/DeviceInventoryModal.tsx@@ -459,7 +459,13 @@ export function DeviceInventoryModal({ open, onClose, highlightId, initialStatusdata: { ...data, ...(nested && hostNodeId ? { parent_id: hostNodeId } : {}) },})})- injectAutoEdges(res.data.edges)+ // A nested guest needs no edge back to its host — being inside the box+ // already says it runs there, and the edge only loops out and back in.+ const nestedIds = new Set(nested ? guestNodeIds : [])+ injectAutoEdges(res.data.edges.filter((e) => !(+ (e.source === hostNodeId && nestedIds.has(e.target))+ || (e.target === hostNodeId && nestedIds.has(e.source))+ )))setSelected(null)await load()toast.success(diff --git a/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx b/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsxindex 4d8ca2c..ec88fe2 100644--- a/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx+++ b/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx@@ -844,6 +844,55 @@ describe('DeviceInventoryModal — Proxmox host approval', () => {})})+ it('drops the host→guest edges when the guests are nested', async () => {+ mockBulkApprove.mockResolvedValue({+ data: {+ approved: 3,+ node_ids: ['n-host', 'n-g1', 'n-g2'],+ device_ids: ['dev-pve', 'dev-g1', 'dev-g2'],+ edges: [+ { id: 'e1', source: 'n-host', target: 'n-g1', type: 'virtual' },+ { id: 'e2', source: 'n-g2', target: 'n-host', type: 'virtual' },+ { id: 'e3', source: 'n-other', target: 'n-g1', type: 'ethernet' },+ ],+ edges_created: 3, skipped: 0, skipped_devices: [],+ },+ })+ await openProxmoxPrompt()+ fireEvent.click(screen.getByRole('button', { name: /add 3 to canvas/i }))+ await waitFor(() => expect(mockBulkApprove).toHaveBeenCalled())+ // injectAutoEdges runs through the store's setState; assert on what it got.+ const setState = vi.mocked(+ (useCanvasStore as unknown as { setState: (fn: unknown) => void }).setState,+ )+ expect(setState).toHaveBeenCalled()+ const updater = setState.mock.calls.at(-1)![0] as (s: unknown) => { edges: { id: string }[] }+ const next = updater({ nodes: [], edges: [] })+ // Only the unrelated edge survives; both host↔guest links are dropped.+ expect(next.edges.map((e) => e.id)).toEqual(['e3'])+ })++ it('keeps the host→guest edges in linked mode', async () => {+ mockBulkApprove.mockResolvedValue({+ data: {+ approved: 3,+ node_ids: ['n-host', 'n-g1', 'n-g2'],+ device_ids: ['dev-pve', 'dev-g1', 'dev-g2'],+ edges: [{ id: 'e1', source: 'n-host', target: 'n-g1', type: 'virtual' }],+ edges_created: 1, skipped: 0, skipped_devices: [],+ },+ })+ await openProxmoxPrompt()+ fireEvent.click(screen.getByRole('radio', { name: /separate nodes linked to the host/i }))+ fireEvent.click(screen.getByRole('button', { name: /add 3 to canvas/i }))+ await waitFor(() => expect(mockBulkApprove).toHaveBeenCalled())+ const setState = vi.mocked(+ (useCanvasStore as unknown as { setState: (fn: unknown) => void }).setState,+ )+ const updater = setState.mock.calls.at(-1)![0] as (s: unknown) => { edges: { id: string }[] }+ expect(updater({ nodes: [], edges: [] }).edges.map((e) => e.id)).toEqual(['e1'])+ })+it('leaves the guests unnested in linked mode', async () => {await openProxmoxPrompt()fireEvent.click(screen.getByRole('radio', { name: /separate nodes linked to the host/i }))