From 9d0f29fb225da2168466ad7792a036d92c417368 Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Fri, 20 Nov 2026 04:03:46 +0100 Subject: [PATCH] fix(header): the two review items of #824 The format check passes again (Prettier breaks the createCpuUsageMeter call one argument per line), and the load-average fallback answers 0 instead of dividing by a core count of 0 on the platform it exists for, where cpus() is empty. Co-Authored-By: Claude Opus 5.5 --- src/web/routes/system-routes.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/web/routes/system-routes.ts b/src/web/routes/system-routes.ts index 93e29173..3bce5998 100644 --- a/src/web/routes/system-routes.ts +++ b/src/web/routes/system-routes.ts @@ -95,8 +95,12 @@ const SCREENSHOTS_DIR = dataPath('screenshots'); const CPU_COUNT = cpus().length; /** Header CPU use; the 1-minute load average per core only when the platform reports no core times. */ -const cpuUsagePercent = createCpuUsageMeter(cpus, () => performance.now(), () => - Math.min(100, Math.round((loadavg()[0] / CPU_COUNT) * 100)) +const cpuUsagePercent = createCpuUsageMeter( + cpus, + () => performance.now(), + () => + // That is also the platform where cpus() is empty, so CPU_COUNT can be 0 here. + CPU_COUNT > 0 ? Math.min(100, Math.round((loadavg()[0] / CPU_COUNT) * 100)) : 0 ); function parseOptionalNumber(value: string | undefined): number | undefined {