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:
5
.changeset/fn-3205-tui-memory-order.md
Normal file
5
.changeset/fn-3205-tui-memory-order.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@runfusion/fusion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Reordered the dashboard TUI Stats panel memory row to show memory usage percentage before absolute used/total values for faster operator scanning.
|
||||||
@@ -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", () => {
|
describe("LogsPanel narrow formatting", () => {
|
||||||
it("shows a compact index instead of full timestamp in narrow terminals", async () => {
|
it("shows a compact index instead of full timestamp in narrow terminals", async () => {
|
||||||
const controller = newController();
|
const controller = newController();
|
||||||
|
|||||||
@@ -332,6 +332,13 @@ function StatRow({ label, children }: { label: string; children: React.ReactNode
|
|||||||
|
|
||||||
function StatsPanel({ state, isFocused }: { state: DashboardState; isFocused: boolean }) {
|
function StatsPanel({ state, isFocused }: { state: DashboardState; isFocused: boolean }) {
|
||||||
const sys = state.systemStats;
|
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 (
|
return (
|
||||||
<Panel title="Stats" isFocused={isFocused} flexGrow={1}>
|
<Panel title="Stats" isFocused={isFocused} flexGrow={1}>
|
||||||
<Box flexDirection="column">
|
<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>
|
<Text>{sys.loadAvg.map((n) => n.toFixed(2)).join(" ")}</Text>
|
||||||
</StatRow>
|
</StatRow>
|
||||||
<StatRow label="MEM">
|
<StatRow label="MEM">
|
||||||
<Text color={sysMemColor(sys.systemTotalMem - sys.systemFreeMem, sys.systemTotalMem)}>
|
{systemMemUsagePct && (
|
||||||
{formatBytes(sys.systemTotalMem - sys.systemFreeMem)}
|
<Text color={systemMemUsageColor}>{systemMemUsagePct}</Text>
|
||||||
</Text>
|
)}
|
||||||
|
<Text color={systemMemUsageColor}>{formatBytes(systemMemUsed)}</Text>
|
||||||
<Text dimColor>/</Text>
|
<Text dimColor>/</Text>
|
||||||
<Text>{formatBytes(sys.systemTotalMem)}</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>
|
</StatRow>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user