Files
Netcatty/components/terminal/TerminalServerStats.test.ts
T
604e11d239 feat(terminal): show per-GPU usage in the server stats bar (#3781)
* feat(terminal): show per-GPU usage in the server stats bar

Keep the existing single nvidia-smi poll and carry each card's index, name,
utilization, and VRAM into the same hover-card layout used for CPU cores.

Closes #3745

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

* fix(terminal): wrap GPU names and stretch a single card

Names use two lines plus the native title instead of an 88px clip, and one
GPU fills the hover card so the bar sits with the title.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
2026-10-20 12:54:49 +08:00

35 lines
1.4 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
test("CPU per-core stats list can scroll when many cores are reported", () => {
const source = readFileSync(new URL("./TerminalServerStats.tsx", import.meta.url), "utf8");
assert.match(
source,
/className="grid gap-1\.5 max-h-\[\d+px\] overflow-y-auto/,
);
});
test("server stats stay subscribed while the terminal is in the background", () => {
const source = readFileSync(new URL("./TerminalServerStats.tsx", import.meta.url), "utf8");
assert.doesNotMatch(source, /usePaneVisible/);
assert.doesNotMatch(source, /isVisible,/);
});
test("GPU chip only renders when the remote reports GPU utilization", () => {
const source = readFileSync(new URL("./TerminalServerStats.tsx", import.meta.url), "utf8");
// Conditional render — hosts without nvidia-smi must not show an empty GPU chip.
assert.match(source, /\{serverStats\.gpu !== null && \(/);
// Sits directly after the CPU chip, before the memory chip.
assert.match(
source,
/terminal\.serverStats\.gpu[\s\S]{0,2000}terminal\.serverStats\.memory/,
);
// Same hover card as CPU: compact aggregate trigger, per-device body.
assert.match(source, /HoverCardTrigger asChild[\s\S]*terminal\.serverStats\.gpu[\s\S]*<TerminalGpuCards/);
assert.match(source, /className="w-auto p-3"[\s\S]*side="bottom"[\s\S]*align="start"[\s\S]*sideOffset=\{8\}[\s\S]*<TerminalGpuCards/);
});