From 6de8417b5dad75446c94f9491d5a6dfed348619b Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 10 Sep 2025 17:45:44 -0700 Subject: [PATCH] minor adjustments --- src/components/StatusBar.tsx | 57 ++++++++++++++++------------------ src/main/modules/monitoring.ts | 14 ++++----- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/components/StatusBar.tsx b/src/components/StatusBar.tsx index cdb19ba..94901be 100644 --- a/src/components/StatusBar.tsx +++ b/src/components/StatusBar.tsx @@ -6,7 +6,6 @@ import { Tooltip, Badge, Group, - useMantineTheme, useComputedColorScheme, } from '@mantine/core'; import { Settings } from 'lucide-react'; @@ -38,7 +37,6 @@ export const StatusBar = ({ ); const [gpuMetrics, setGpuMetrics] = useState(null); const [settingsModalOpen, setSettingsModalOpen] = useState(false); - const theme = useMantineTheme(); const colorScheme = useComputedColorScheme('light', { getInitialValueInEffect: true, }); @@ -75,15 +73,10 @@ export const StatusBar = ({ }; }, [maxDataPoints]); - if (!cpuMetrics || !memoryMetrics) { - return null; - } - return ( - - - - CPU: {cpuMetrics.usage.toFixed(1)}% - - + + {cpuMetrics && memoryMetrics && ( + <> + + + CPU: {cpuMetrics.usage.toFixed(1)}% + + - - - RAM: {memoryMetrics.usage.toFixed(1)}% - - + + + RAM: {memoryMetrics.usage.toFixed(1)}% + + + + )} {gpuMetrics?.gpus.map((gpu, index) => ( - + | null = null; let memoryInterval: ReturnType | null = null; let gpuInterval: ReturnType | null = null; let isRunning = false; -const cpuUpdateFrequency = 1000; -const memoryUpdateFrequency = 1000; -const gpuUpdateFrequency = 2000; +const updateFrequency = 2000; let mainWindow: BrowserWindow | null = null; export function startMonitoring(window: BrowserWindow) { @@ -59,17 +57,17 @@ export function startMonitoring(window: BrowserWindow) { collectAndSendCpuMetrics(); cpuInterval = setInterval(() => { collectAndSendCpuMetrics(); - }, cpuUpdateFrequency); + }, updateFrequency); collectAndSendMemoryMetrics(); memoryInterval = setInterval(() => { collectAndSendMemoryMetrics(); - }, memoryUpdateFrequency); + }, updateFrequency); collectAndSendGpuMetrics(); gpuInterval = setInterval(() => { collectAndSendGpuMetrics(); - }, gpuUpdateFrequency); + }, updateFrequency); } export function stopMonitoring() { @@ -109,8 +107,8 @@ async function collectAndSendMemoryMetrics() { const usedBytes = memData.active || memData.used; const totalBytes = memData.total; const metrics: MemoryMetrics = { - used: Math.round(usedBytes / (1024 * 1024 * 1024) * 10) / 10, - total: Math.round(totalBytes / (1024 * 1024 * 1024) * 10) / 10, + used: Math.round((usedBytes / (1024 * 1024 * 1024)) * 10) / 10, + total: Math.round((totalBytes / (1024 * 1024 * 1024)) * 10) / 10, usage: (usedBytes / totalBytes) * 100, };