fix: address feedback

This commit is contained in:
Nate 2025-08-24 13:24:57 -07:00
parent 144341e9c3
commit f5065abf41
3 changed files with 12 additions and 13 deletions

View file

@ -1,4 +1,5 @@
import { exec } from "child_process";
import * as os from "os";
import { promisify } from "util";
import { logger } from "../util/logger.js";
@ -265,10 +266,7 @@ class ResourceMonitoringService {
private getLoadAverage(): number[] {
try {
return process.platform !== "win32" &&
typeof (process as any).loadavg === "function"
? (process as any).loadavg()
: [0, 0, 0];
return process.platform === "win32" ? [0, 0, 0] : os.loadavg();
} catch {
return [0, 0, 0];
}
@ -284,9 +282,7 @@ class ResourceMonitoringService {
private getFreeMemory(): number {
try {
return typeof (process as any).freemem === "function"
? (process as any).freemem()
: 0;
return os.freemem();
} catch {
return 0;
}
@ -294,11 +290,9 @@ class ResourceMonitoringService {
private getTotalMemory(): number {
try {
return typeof (process as any).totalmem === "function"
? (process as any).totalmem()
: 1024 * 1024 * 1024; // 1GB default
return os.totalmem();
} catch {
return 1024 * 1024 * 1024; // 1GB default
return 1024 * 1024 * 1024; // 1GB default fallback
}
}

View file

@ -15,6 +15,7 @@ import {
MCPServiceState,
ModelServiceState,
} from "../services/types.js";
import { logger } from "../util/logger.js";
import { BottomStatusBar } from "./components/BottomStatusBar.js";
import { ResourceDebugBar } from "./components/ResourceDebugBar.js";
@ -64,7 +65,7 @@ async function loadAndSetSession(
// Load the session history
const sessionHistory = loadSessionById(sessionId);
if (!sessionHistory) {
console.error(`Session ${sessionId} could not be loaded.`);
logger.error(`Session ${sessionId} could not be loaded.`);
return;
}

View file

@ -50,7 +50,7 @@ export function ResourceDebugBar({ visible }: ResourceDebugBarProps) {
};
}, [visible]);
if (!visible || !resourceData) {
if (!visible) {
return null;
}
@ -62,6 +62,10 @@ export function ResourceDebugBar({ visible }: ResourceDebugBarProps) {
);
}
if (!resourceData) {
return null;
}
const memoryPercent =
(resourceData.memory.rss / resourceData.system.totalMemory) * 100;
const cpuPercent = resourceData.cpu.percent || 0;