From 6c3886ad24b9d5aa6d65a456faa74e59b976685f Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 31 Jan 2026 15:57:59 +0100 Subject: [PATCH] Update virtual-machines.tsx --- AppImage/components/virtual-machines.tsx | 48 +++++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/AppImage/components/virtual-machines.tsx b/AppImage/components/virtual-machines.tsx index 07f842c8..a94dbf20 100644 --- a/AppImage/components/virtual-machines.tsx +++ b/AppImage/components/virtual-machines.tsx @@ -453,10 +453,18 @@ export function VirtualMachines() { const safeVMData = vmData || [] + // Total allocated RAM for ALL VMs/LXCs (running + stopped) const totalAllocatedMemoryGB = useMemo(() => { return (safeVMData.reduce((sum, vm) => sum + (vm.maxmem || 0), 0) / 1024 ** 3).toFixed(1) }, [safeVMData]) + // Allocated RAM only for RUNNING VMs/LXCs (this is what actually matters for overcommit) + const runningAllocatedMemoryGB = useMemo(() => { + return (safeVMData + .filter((vm) => vm.status === "running") + .reduce((sum, vm) => sum + (vm.maxmem || 0), 0) / 1024 ** 3).toFixed(1) + }, [safeVMData]) + const { data: systemData } = useSWR<{ memory_total: number; memory_used: number; memory_usage: number }>( "/api/system", fetcher, @@ -470,7 +478,9 @@ export function VirtualMachines() { const usedMemoryGB = systemData?.memory_used ?? null const memoryUsagePercent = systemData?.memory_usage ?? null const allocatedMemoryGB = Number.parseFloat(totalAllocatedMemoryGB) - const isMemoryOvercommit = physicalMemoryGB !== null && allocatedMemoryGB > physicalMemoryGB + const runningAllocatedGB = Number.parseFloat(runningAllocatedMemoryGB) + // Overcommit warning should be based on RUNNING VMs allocation, not total + const isMemoryOvercommit = physicalMemoryGB !== null && runningAllocatedGB > physicalMemoryGB const getMemoryUsageColor = (percent: number | null) => { if (percent === null) return "bg-blue-500" @@ -758,13 +768,21 @@ export function VirtualMachines() { )} - {/* Allocated RAM (configured) */} + {/* Allocated RAM (configured) - Split into Running and Total */}
- {/* Layout para desktop (sin cambios) */} + {/* Layout para desktop */}
-
-
{totalAllocatedMemoryGB} GB
-
Allocated RAM
+
+ {/* Running allocation - most important */} +
+
{runningAllocatedMemoryGB} GB
+
Running Allocated
+
+ {/* Total allocation */} +
+
{totalAllocatedMemoryGB} GB
+
Total Allocated
+
{physicalMemoryGB !== null && (
@@ -781,10 +799,20 @@ export function VirtualMachines() { )}
- {/* Layout para móvil (44.0 GB solo, Allocated RAM en otra línea, badge en tercera línea) */} -
-
{totalAllocatedMemoryGB} GB
-
Allocated RAM
+ {/* Layout para movil */} +
+
+ {/* Running allocation */} +
+
{runningAllocatedMemoryGB} GB
+
Running
+
+ {/* Total allocation */} +
+
{totalAllocatedMemoryGB} GB
+
Total
+
+
{physicalMemoryGB !== null && (
{isMemoryOvercommit ? (