minor adjustments

This commit is contained in:
Egor 2025-09-10 17:45:44 -07:00
parent cc636250da
commit 6de8417b5d
2 changed files with 33 additions and 38 deletions

View file

@ -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<GpuMetrics | null>(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 (
<Box
px="xs"
style={{
borderTop: `1px solid ${colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,
backgroundColor:
colorScheme === 'dark'
? 'var(--mantine-color-dark-8)'
@ -91,32 +84,36 @@ export const StatusBar = ({
}}
>
<Flex align="center" justify="space-between">
<Group gap="xs" wrap="nowrap">
<Tooltip label={`${cpuMetrics.usage.toFixed(1)}%`} position="top">
<Badge
size="sm"
variant="light"
style={{ minWidth: '5rem', textAlign: 'center' }}
>
CPU: {cpuMetrics.usage.toFixed(1)}%
</Badge>
</Tooltip>
<Group gap="xs">
{cpuMetrics && memoryMetrics && (
<>
<Tooltip label={`${cpuMetrics.usage.toFixed(1)}%`} position="top">
<Badge
size="sm"
variant="light"
style={{ minWidth: '5rem', textAlign: 'center' }}
>
CPU: {cpuMetrics.usage.toFixed(1)}%
</Badge>
</Tooltip>
<Tooltip
label={`${memoryMetrics.used.toFixed(1)} GB / ${memoryMetrics.total.toFixed(1)} GB (${memoryMetrics.usage.toFixed(1)}%)`}
position="top"
>
<Badge
size="sm"
variant="light"
style={{ minWidth: '5rem', textAlign: 'center' }}
>
RAM: {memoryMetrics.usage.toFixed(1)}%
</Badge>
</Tooltip>
<Tooltip
label={`${memoryMetrics.used.toFixed(1)} GB / ${memoryMetrics.total.toFixed(1)} GB (${memoryMetrics.usage.toFixed(1)}%)`}
position="top"
>
<Badge
size="sm"
variant="light"
style={{ minWidth: '5rem', textAlign: 'center' }}
>
RAM: {memoryMetrics.usage.toFixed(1)}%
</Badge>
</Tooltip>
</>
)}
{gpuMetrics?.gpus.map((gpu, index) => (
<Group key={`gpu-${index}`} gap={4} wrap="nowrap">
<Group gap="xs" key={`gpu-${index}`}>
<Tooltip label={`${gpu.usage.toFixed(1)}%`} position="top">
<Badge
size="sm"

View file

@ -45,9 +45,7 @@ let cpuInterval: ReturnType<typeof setInterval> | null = null;
let memoryInterval: ReturnType<typeof setInterval> | null = null;
let gpuInterval: ReturnType<typeof setInterval> | 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,
};