Skip to content

Commit 54d2fe3

Browse files
CryptoJonesclaude
andauthored
fix(ui): show every GPU on a node card, not just the first (#34)
Closes #33. ## Problem `NodeCardDetails.tsx:276` passed only the first GPU to the node card header: ```tsx gpuLabel={gpuInfo.length > 0 ? gpuInfo[0].name : undefined} ``` `NodeLabel` took a single `gpuLabel: string | undefined`, so every GPU after the first was unrepresentable by construction. A host with a Tesla P100 **and** an RTX 3060 rendered identically to one with only the 3060, with no count or overflow hint that anything was missing. The data was never wrong — `/v1/node-info` reports every GPU, `inferenceHardwareIds` was absent (which by the contract in `gpu-inference.ts` means "show every GPU"), and the detailed performance view already charts all of them. Only the header dropped them. ## Change Emit **one label segment per GPU**. Segments are the right unit rather than a joined string: `NodeLabel` applies wrapping, `·` separators and truncation *per segment*, so `gpus.join(' · ')` would be a single segment that truncates after the first name on a narrow card — the same blind spot in a new shape. Per-GPU segments keep the existing layout behavior and let each name wrap and truncate on its own. Three supporting details: - The segment builder moves to `ui/utils/node-label-segments.ts`. The unit project runs `environment: 'node'` with no DOM and deliberately excludes components, so a pure helper is testable there without adding jsdom/testing-library to the tree. It also lands inside the existing coverage scope ("the renderer's helper and constant modules"). - `gpuLabels` is memoized in `NodeCardDetails`. Building the array inline gave it a new identity every render, and `NodeLabel` observes its segments — that would have torn down and rebuilt the `ResizeObserver` on every render. - Blank GPU names are skipped, so a backend reporting an empty name cannot render a separator with nothing after it. Behavior for 0- and 1-GPU hosts is unchanged. ## Tests `desktop/tests/modular/node-label-segments.test.ts` — 13 cases: - name/address ordering, and the address-as-primary fallback - single-GPU host unchanged - the reported dual-GPU regression, asserting topology order - `it.each([3, 4, 5, 6, 7, 8])` — every GPU present, in order, at each count; 8-GPU servers are the case that matters most here - unique, stable `gpu-N` ids across an 8-GPU host so React keys do not collide - blank names dropped without disturbing the rest - no GPU segments for a host reporting none ## Verification Run from `desktop/`, all green on this branch: | Gate | Result | |---|---| | `npm run lint` | exit 0 (one pre-existing warning in `node-info-poller.ts`, untouched here) | | `npm run typecheck` | exit 0 | | `npm run dead-code:check` | exit 0 — no dead code | | `npm run test:unit` | 38 files, 221 tests passed | --- *Proudly Made in Nebraska. Go Big Red! 🌽 <https://xkcd.com/2347/>* Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent fe8533c commit 54d2fe3

4 files changed

Lines changed: 132 additions & 19 deletions

File tree

‎desktop/src/ui/components/NodeList/NodeCardDetails.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ function NodeCardDetails({ node }: NodeCardDetailsProps) {
100100
})
101101
}, [hasGpu, node, nodeMetrics])
102102

103+
// Memoized so the label's segment list keeps a stable identity across
104+
// renders; NodeLabel observes its segments and would otherwise rebuild the
105+
// ResizeObserver every render.
106+
const gpuLabels = useMemo(() => gpuInfo.map(gpu => gpu.name), [gpuInfo])
107+
103108
const cpuFallbackInfo: CpuFallbackInfo | null = useMemo(() => {
104109
if (hasGpu) return null
105110
const ramTotal = node.topology.ram
@@ -273,7 +278,7 @@ function NodeCardDetails({ node }: NodeCardDetailsProps) {
273278
<NodeLabel
274279
name={node.name}
275280
ipAddress={node.ipAddress}
276-
gpuLabel={gpuInfo.length > 0 ? gpuInfo[0].name : undefined}
281+
gpuLabels={gpuLabels}
277282
isLocal={isLocal}
278283
/>
279284
</div>

‎desktop/src/ui/components/NodeList/NodeLabel.tsx‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,26 @@
44
import { Flex, Text } from '@nvidia/foundations-react-core'
55
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
66
import { LocalBadge } from '@/ui/components/LocalBadge'
7-
8-
interface LabelSegment {
9-
id: string
10-
text: string
11-
}
7+
import { buildNodeLabelSegments } from '@/ui/utils/node-label-segments'
128

139
export default function NodeLabel({
1410
name,
1511
ipAddress,
16-
gpuLabel,
12+
gpuLabels,
1713
isLocal
1814
}: {
1915
name: string
2016
ipAddress: string
21-
gpuLabel: string | undefined
17+
gpuLabels: string[]
2218
isLocal?: boolean
2319
}) {
2420
const segmentRefs = useRef<(HTMLDivElement | null)[]>([])
2521
const containerRef = useRef<HTMLDivElement | null>(null)
2622
const [separatorAfter, setSeparatorAfter] = useState<boolean[]>([])
27-
const segments = useMemo(() => {
28-
const primaryText = (name || ipAddress).toUpperCase()
29-
const nextSegments: LabelSegment[] = [{ id: 'primary', text: primaryText }]
30-
if (name && ipAddress) {
31-
nextSegments.push({ id: 'ip', text: ipAddress })
32-
}
33-
if (gpuLabel) {
34-
nextSegments.push({ id: 'gpu', text: gpuLabel })
35-
}
36-
return nextSegments
37-
}, [gpuLabel, ipAddress, name])
23+
const segments = useMemo(
24+
() => buildNodeLabelSegments(name, ipAddress, gpuLabels),
25+
[gpuLabels, ipAddress, name]
26+
)
3827

3928
const updateSeparators = useCallback(() => {
4029
const next = segments.map((_segment, index) => {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/** A single text run in a node card's header label. */
5+
interface LabelSegment {
6+
id: string
7+
text: string
8+
}
9+
10+
/**
11+
* Header-label segments for a node card: name, address, then one segment per
12+
* GPU.
13+
*
14+
* Each GPU gets its OWN segment rather than being folded into one joined
15+
* string, because `NodeLabel` applies wrapping, `·` separators and truncation
16+
* per segment. A joined string is a single segment, so on a narrow card it
17+
* truncates after the first card name and the rest of a multi-GPU host becomes
18+
* invisible — which is the failure this shape exists to prevent.
19+
*
20+
* Empty GPU names are dropped so a backend that reports a blank name cannot
21+
* render a stray separator with nothing after it.
22+
*/
23+
export function buildNodeLabelSegments(
24+
name: string,
25+
ipAddress: string,
26+
gpuLabels: string[]
27+
): LabelSegment[] {
28+
const primaryText = (name || ipAddress).toUpperCase()
29+
const segments: LabelSegment[] = [{ id: 'primary', text: primaryText }]
30+
31+
if (name && ipAddress) {
32+
segments.push({ id: 'ip', text: ipAddress })
33+
}
34+
35+
gpuLabels.forEach((gpuLabel, index) => {
36+
if (gpuLabel) {
37+
segments.push({ id: `gpu-${index}`, text: gpuLabel })
38+
}
39+
})
40+
41+
return segments
42+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, expect, it } from 'vitest'
5+
import { buildNodeLabelSegments } from '@/ui/utils/node-label-segments'
6+
7+
// The node card header previously rendered `gpus[0].name` alone, so a host with
8+
// more than one GPU was represented by its first card and every other card was
9+
// invisible in the summary view. `buildNodeLabelSegments` emits one segment per
10+
// GPU instead. These tests pin that every GPU survives, in order, at the counts
11+
// real hosts actually have — including the 8-GPU servers this has to hold for.
12+
13+
const gpuTexts = (name: string, ip: string, gpus: string[]) =>
14+
buildNodeLabelSegments(name, ip, gpus)
15+
.filter(segment => segment.id.startsWith('gpu-'))
16+
.map(segment => segment.text)
17+
18+
describe('buildNodeLabelSegments', () => {
19+
it('puts the name first, uppercased, followed by the address', () => {
20+
const segments = buildNodeLabelSegments('pluto.local.tld', '172.16.24.46', [])
21+
expect(segments).toEqual([
22+
{ id: 'primary', text: 'PLUTO.LOCAL.TLD' },
23+
{ id: 'ip', text: '172.16.24.46' }
24+
])
25+
})
26+
27+
it('falls back to the address as the primary segment when there is no name', () => {
28+
const segments = buildNodeLabelSegments('', '172.16.24.46', [])
29+
expect(segments).toEqual([{ id: 'primary', text: '172.16.24.46' }])
30+
})
31+
32+
it('renders a single-GPU host unchanged', () => {
33+
expect(gpuTexts('TELESTO', '172.16.29.18', ['NVIDIA GeForce GTX 1060 6GB'])).toEqual([
34+
'NVIDIA GeForce GTX 1060 6GB'
35+
])
36+
})
37+
38+
it('renders BOTH cards of a dual-GPU host, in topology order', () => {
39+
// The reported case: only the first card was ever shown.
40+
expect(
41+
gpuTexts('pluto.local.tld', '172.16.24.46', [
42+
'Tesla P100-PCIE-16GB',
43+
'NVIDIA GeForce RTX 3060'
44+
])
45+
).toEqual(['Tesla P100-PCIE-16GB', 'NVIDIA GeForce RTX 3060'])
46+
})
47+
48+
it.each([3, 4, 5, 6, 7, 8])('renders every GPU on a %i-GPU host', count => {
49+
const gpus = Array.from({ length: count }, (_, index) => `NVIDIA H100 80GB HBM3 #${index}`)
50+
const texts = gpuTexts('dgx-01', '10.0.0.10', gpus)
51+
52+
expect(texts).toHaveLength(count)
53+
expect(texts).toEqual(gpus)
54+
})
55+
56+
it('keeps ids unique and stable across an 8-GPU host so React can key them', () => {
57+
const gpus = Array.from({ length: 8 }, (_, index) => `NVIDIA A100-SXM4-80GB #${index}`)
58+
const ids = buildNodeLabelSegments('dgx-02', '10.0.0.11', gpus).map(segment => segment.id)
59+
60+
expect(new Set(ids).size).toBe(ids.length)
61+
expect(ids).toEqual([
62+
'primary',
63+
'ip',
64+
...Array.from({ length: 8 }, (_, index) => `gpu-${index}`)
65+
])
66+
})
67+
68+
it('drops blank GPU names without disturbing the indices of the rest', () => {
69+
// A blank name would otherwise render a separator with nothing after it.
70+
const texts = gpuTexts('mixed', '10.0.0.12', ['Tesla P100-PCIE-16GB', '', 'RTX 3060'])
71+
expect(texts).toEqual(['Tesla P100-PCIE-16GB', 'RTX 3060'])
72+
})
73+
74+
it('emits no GPU segments for a host that reports none', () => {
75+
expect(gpuTexts('cpu-only', '10.0.0.13', [])).toEqual([])
76+
})
77+
})

0 commit comments

Comments
 (0)