feat(FN-3205): add changeset documenting TUI memory ordering changes
Merges the changeset documenting the TUI memory ordering feature (FN-3205), completing the final delivery step for this work. Fusion-Task-Id: FN-3205
This commit is contained in:
@@ -668,6 +668,45 @@ describe("StatusModeGrid layout stability", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("StatsPanel memory row", () => {
|
||||
it("renders memory percentage before absolute values", async () => {
|
||||
const controller = newController();
|
||||
controller.setSystemInfo(makeSystemInfo());
|
||||
controller.setActiveSection("stats");
|
||||
controller.setSystemStats({
|
||||
rss: 0,
|
||||
heapUsed: 0,
|
||||
heapTotal: 0,
|
||||
heapLimit: 1,
|
||||
external: 0,
|
||||
arrayBuffers: 0,
|
||||
cpuPercent: 0,
|
||||
loadAvg: [0, 0, 0],
|
||||
cpuCount: 1,
|
||||
systemTotalMem: 8 * 1024 * 1024 * 1024,
|
||||
systemFreeMem: 2 * 1024 * 1024 * 1024,
|
||||
pid: process.pid,
|
||||
nodeVersion: process.version,
|
||||
platform: `${process.platform}/${process.arch}`,
|
||||
});
|
||||
|
||||
const rendered = render(renderDashboardAppNode(controller));
|
||||
setTerminalSize(rendered, 120, 24);
|
||||
rendered.rerender(renderDashboardAppNode(controller));
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
|
||||
const frame = rendered.lastFrame() ?? "";
|
||||
const pctIndex = frame.indexOf("75.0%");
|
||||
const usedIndex = frame.indexOf("6.00 GB");
|
||||
|
||||
expect(pctIndex).toBeGreaterThanOrEqual(0);
|
||||
expect(usedIndex).toBeGreaterThanOrEqual(0);
|
||||
expect(pctIndex).toBeLessThan(usedIndex);
|
||||
|
||||
rendered.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe("LogsPanel narrow formatting", () => {
|
||||
it("shows a compact index instead of full timestamp in narrow terminals", async () => {
|
||||
const controller = newController();
|
||||
|
||||
@@ -332,6 +332,13 @@ function StatRow({ label, children }: { label: string; children: React.ReactNode
|
||||
|
||||
function StatsPanel({ state, isFocused }: { state: DashboardState; isFocused: boolean }) {
|
||||
const sys = state.systemStats;
|
||||
const systemMemUsed = sys ? sys.systemTotalMem - sys.systemFreeMem : 0;
|
||||
const systemMemUsageColor = sys ? sysMemColor(systemMemUsed, sys.systemTotalMem) : undefined;
|
||||
const systemMemUsagePct =
|
||||
sys && sys.systemTotalMem > 0
|
||||
? `${((systemMemUsed / sys.systemTotalMem) * 100).toFixed(1)}%`
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Panel title="Stats" isFocused={isFocused} flexGrow={1}>
|
||||
<Box flexDirection="column">
|
||||
@@ -362,16 +369,12 @@ function StatsPanel({ state, isFocused }: { state: DashboardState; isFocused: bo
|
||||
<Text>{sys.loadAvg.map((n) => n.toFixed(2)).join(" ")}</Text>
|
||||
</StatRow>
|
||||
<StatRow label="MEM">
|
||||
<Text color={sysMemColor(sys.systemTotalMem - sys.systemFreeMem, sys.systemTotalMem)}>
|
||||
{formatBytes(sys.systemTotalMem - sys.systemFreeMem)}
|
||||
</Text>
|
||||
{systemMemUsagePct && (
|
||||
<Text color={systemMemUsageColor}>{systemMemUsagePct}</Text>
|
||||
)}
|
||||
<Text color={systemMemUsageColor}>{formatBytes(systemMemUsed)}</Text>
|
||||
<Text dimColor>/</Text>
|
||||
<Text>{formatBytes(sys.systemTotalMem)}</Text>
|
||||
{sys.systemTotalMem > 0 && (
|
||||
<Text color={sysMemColor(sys.systemTotalMem - sys.systemFreeMem, sys.systemTotalMem)}>
|
||||
{((sys.systemTotalMem - sys.systemFreeMem) / sys.systemTotalMem * 100).toFixed(1)}%
|
||||
</Text>
|
||||
)}
|
||||
</StatRow>
|
||||
</>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user