Router that virtually distributes inference across connected devices in the home.
Go
fix(ui): show every GPU on a node card, not just the first (#34)
Aaron K. Clark54d2fe33067c
diff --git a/desktop/src/ui/components/NodeList/NodeCardDetails.tsx b/desktop/src/ui/components/NodeList/NodeCardDetails.tsxindex 4bc5012..f2e4ced 100644--- a/desktop/src/ui/components/NodeList/NodeCardDetails.tsx+++ b/desktop/src/ui/components/NodeList/NodeCardDetails.tsx@@ -100,6 +100,11 @@ function NodeCardDetails({ node }: NodeCardDetailsProps) {})}, [hasGpu, node, nodeMetrics])+ // Memoized so the label's segment list keeps a stable identity across+ // renders; NodeLabel observes its segments and would otherwise rebuild the+ // ResizeObserver every render.+ const gpuLabels = useMemo(() => gpuInfo.map(gpu => gpu.name), [gpuInfo])+const cpuFallbackInfo: CpuFallbackInfo | null = useMemo(() => {if (hasGpu) return nullconst ramTotal = node.topology.ram@@ -273,7 +278,7 @@ function NodeCardDetails({ node }: NodeCardDetailsProps) {<NodeLabelname={node.name}ipAddress={node.ipAddress}- gpuLabel={gpuInfo.length > 0 ? gpuInfo[0].name : undefined}+ gpuLabels={gpuLabels}isLocal={isLocal}/></div>diff --git a/desktop/src/ui/components/NodeList/NodeLabel.tsx b/desktop/src/ui/components/NodeList/NodeLabel.tsxindex 219ee88..b43ea8e 100644--- a/desktop/src/ui/components/NodeList/NodeLabel.tsx+++ b/desktop/src/ui/components/NodeList/NodeLabel.tsx@@ -4,37 +4,26 @@import { Flex, Text } from '@nvidia/foundations-react-core'import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'import { LocalBadge } from '@/ui/components/LocalBadge'--interface LabelSegment {- id: string- text: string-}+import { buildNodeLabelSegments } from '@/ui/utils/node-label-segments'export default function NodeLabel({name,ipAddress,- gpuLabel,+ gpuLabels,isLocal}: {name: stringipAddress: string- gpuLabel: string | undefined+ gpuLabels: string[]isLocal?: boolean}) {const segmentRefs = useRef<(HTMLDivElement | null)[]>([])const containerRef = useRef<HTMLDivElement | null>(null)const [separatorAfter, setSeparatorAfter] = useState<boolean[]>([])- const segments = useMemo(() => {- const primaryText = (name || ipAddress).toUpperCase()- const nextSegments: LabelSegment[] = [{ id: 'primary', text: primaryText }]- if (name && ipAddress) {- nextSegments.push({ id: 'ip', text: ipAddress })- }- if (gpuLabel) {- nextSegments.push({ id: 'gpu', text: gpuLabel })- }- return nextSegments- }, [gpuLabel, ipAddress, name])+ const segments = useMemo(+ () => buildNodeLabelSegments(name, ipAddress, gpuLabels),+ [gpuLabels, ipAddress, name]+ )const updateSeparators = useCallback(() => {const next = segments.map((_segment, index) => {diff --git a/desktop/src/ui/utils/node-label-segments.ts b/desktop/src/ui/utils/node-label-segments.tsnew file mode 100644index 0000000..c4d11ac--- /dev/null+++ b/desktop/src/ui/utils/node-label-segments.ts@@ -0,0 +1,42 @@+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.+// SPDX-License-Identifier: Apache-2.0++/** A single text run in a node card's header label. */+interface LabelSegment {+ id: string+ text: string+}++/**+ * Header-label segments for a node card: name, address, then one segment per+ * GPU.+ *+ * Each GPU gets its OWN segment rather than being folded into one joined+ * string, because `NodeLabel` applies wrapping, `·` separators and truncation+ * per segment. A joined string is a single segment, so on a narrow card it+ * truncates after the first card name and the rest of a multi-GPU host becomes+ * invisible — which is the failure this shape exists to prevent.+ *+ * Empty GPU names are dropped so a backend that reports a blank name cannot+ * render a stray separator with nothing after it.+ */+export function buildNodeLabelSegments(+ name: string,+ ipAddress: string,+ gpuLabels: string[]+): LabelSegment[] {+ const primaryText = (name || ipAddress).toUpperCase()+ const segments: LabelSegment[] = [{ id: 'primary', text: primaryText }]++ if (name && ipAddress) {+ segments.push({ id: 'ip', text: ipAddress })+ }++ gpuLabels.forEach((gpuLabel, index) => {+ if (gpuLabel) {+ segments.push({ id: `gpu-${index}`, text: gpuLabel })+ }+ })++ return segments+}diff --git a/desktop/tests/modular/node-label-segments.test.ts b/desktop/tests/modular/node-label-segments.test.tsnew file mode 100644index 0000000..1bc7231--- /dev/null+++ b/desktop/tests/modular/node-label-segments.test.ts@@ -0,0 +1,77 @@+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.+// SPDX-License-Identifier: Apache-2.0++import { describe, expect, it } from 'vitest'+import { buildNodeLabelSegments } from '@/ui/utils/node-label-segments'++// The node card header previously rendered `gpus[0].name` alone, so a host with+// more than one GPU was represented by its first card and every other card was+// invisible in the summary view. `buildNodeLabelSegments` emits one segment per+// GPU instead. These tests pin that every GPU survives, in order, at the counts+// real hosts actually have — including the 8-GPU servers this has to hold for.++const gpuTexts = (name: string, ip: string, gpus: string[]) =>+ buildNodeLabelSegments(name, ip, gpus)+ .filter(segment => segment.id.startsWith('gpu-'))+ .map(segment => segment.text)++describe('buildNodeLabelSegments', () => {+ it('puts the name first, uppercased, followed by the address', () => {+ const segments = buildNodeLabelSegments('pluto.local.tld', '172.16.24.46', [])+ expect(segments).toEqual([+ { id: 'primary', text: 'PLUTO.LOCAL.TLD' },+ { id: 'ip', text: '172.16.24.46' }+ ])+ })++ it('falls back to the address as the primary segment when there is no name', () => {+ const segments = buildNodeLabelSegments('', '172.16.24.46', [])+ expect(segments).toEqual([{ id: 'primary', text: '172.16.24.46' }])+ })++ it('renders a single-GPU host unchanged', () => {+ expect(gpuTexts('TELESTO', '172.16.29.18', ['NVIDIA GeForce GTX 1060 6GB'])).toEqual([+ 'NVIDIA GeForce GTX 1060 6GB'+ ])+ })++ it('renders BOTH cards of a dual-GPU host, in topology order', () => {+ // The reported case: only the first card was ever shown.+ expect(+ gpuTexts('pluto.local.tld', '172.16.24.46', [+ 'Tesla P100-PCIE-16GB',+ 'NVIDIA GeForce RTX 3060'+ ])+ ).toEqual(['Tesla P100-PCIE-16GB', 'NVIDIA GeForce RTX 3060'])+ })++ it.each([3, 4, 5, 6, 7, 8])('renders every GPU on a %i-GPU host', count => {+ const gpus = Array.from({ length: count }, (_, index) => `NVIDIA H100 80GB HBM3 #${index}`)+ const texts = gpuTexts('dgx-01', '10.0.0.10', gpus)++ expect(texts).toHaveLength(count)+ expect(texts).toEqual(gpus)+ })++ it('keeps ids unique and stable across an 8-GPU host so React can key them', () => {+ const gpus = Array.from({ length: 8 }, (_, index) => `NVIDIA A100-SXM4-80GB #${index}`)+ const ids = buildNodeLabelSegments('dgx-02', '10.0.0.11', gpus).map(segment => segment.id)++ expect(new Set(ids).size).toBe(ids.length)+ expect(ids).toEqual([+ 'primary',+ 'ip',+ ...Array.from({ length: 8 }, (_, index) => `gpu-${index}`)+ ])+ })++ it('drops blank GPU names without disturbing the indices of the rest', () => {+ // A blank name would otherwise render a separator with nothing after it.+ const texts = gpuTexts('mixed', '10.0.0.12', ['Tesla P100-PCIE-16GB', '', 'RTX 3060'])+ expect(texts).toEqual(['Tesla P100-PCIE-16GB', 'RTX 3060'])+ })++ it('emits no GPU segments for a host that reports none', () => {+ expect(gpuTexts('cpu-only', '10.0.0.13', [])).toEqual([])+ })+})