From aa69ad719d1a818191544a055dda98ae29f71bcd Mon Sep 17 00:00:00 2001 From: Louis Le Date: Mon, 12 Aug 2024 19:53:15 +0700 Subject: [PATCH 1/3] chore: add back GPU information to system monitoring bar --- core/src/types/events/resource.event.ts | 6 ++++++ electron/package.json | 2 +- .../BottomPanel/SystemMonitor/index.tsx | 21 +++++++++++++------ web/helpers/atoms/SystemBar.atom.ts | 3 ++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/core/src/types/events/resource.event.ts b/core/src/types/events/resource.event.ts index 54cc9a4691..6bb5aa7970 100644 --- a/core/src/types/events/resource.event.ts +++ b/core/src/types/events/resource.event.ts @@ -7,9 +7,15 @@ export interface ResourceStatus { cpu: { usage: number } + gpus: GpuInfo[] } export interface UsedMemInfo { total: number used: number } + +export interface GpuInfo { + name: string | undefined + vram: UsedMemInfo +} diff --git a/electron/package.json b/electron/package.json index c003b1406e..6e32a2bdbb 100644 --- a/electron/package.json +++ b/electron/package.json @@ -123,7 +123,7 @@ "request": "^2.88.2", "request-progress": "^3.0.0", "@kirillvakalov/nut-tree__nut-js": "4.2.1-2", - "cortexso": "v0.5.0-40" + "cortexso": "v0.5.0-43" }, "devDependencies": { "@types/js-yaml": "4.0.9", diff --git a/web/containers/Layout/BottomPanel/SystemMonitor/index.tsx b/web/containers/Layout/BottomPanel/SystemMonitor/index.tsx index d056862857..54c7bf7659 100644 --- a/web/containers/Layout/BottomPanel/SystemMonitor/index.tsx +++ b/web/containers/Layout/BottomPanel/SystemMonitor/index.tsx @@ -35,7 +35,7 @@ const SystemMonitor: React.FC = () => { const [usedRam, setUsedRam] = useAtom(usedRamAtom) const [totalRam, setTotalRam] = useAtom(totalRamAtom) const [cpuUsage, setCpuUsage] = useAtom(cpuUsageAtom) - const gpus = useAtomValue(gpusAtom) + const [gpus, setGpus] = useAtom(gpusAtom) const [showFullScreen, setShowFullScreen] = useState(false) const [showSystemMonitorPanel, setShowSystemMonitorPanel] = useAtom( @@ -63,13 +63,18 @@ const SystemMonitor: React.FC = () => { setUsedRam(resourceEvent.mem.used) setTotalRam(resourceEvent.mem.total) setCpuUsage(resourceEvent.cpu.usage) + setGpus( + resourceEvent.gpus?.filter( + (gpu) => gpu.name && gpu.vram.used && gpu.vram.total + ) ?? [] + ) } catch (err) { console.error(err) } }, signal: abortControllerRef.current.signal, }) - }, [host, setTotalRam, setUsedRam, setCpuUsage]) + }, [host, setTotalRam, setUsedRam, setCpuUsage, setGpus]) const unregister = useCallback(() => { if (!abortControllerRef.current) return @@ -195,8 +200,7 @@ const SystemMonitor: React.FC = () => {
- {gpu.memoryTotal - gpu.memoryFree}/ - {gpu.memoryTotal} + {gpu.vram.used}/{gpu.vram.total} MB
@@ -205,12 +209,17 @@ const SystemMonitor: React.FC = () => {
- {gpu.utilization}% + {Math.round( + (gpu.vram.used / Math.max(gpu.vram.total, 1)) * 100 + )} + %
diff --git a/web/helpers/atoms/SystemBar.atom.ts b/web/helpers/atoms/SystemBar.atom.ts index f8de0688c1..2ece2a8498 100644 --- a/web/helpers/atoms/SystemBar.atom.ts +++ b/web/helpers/atoms/SystemBar.atom.ts @@ -1,3 +1,4 @@ +import { GpuInfo } from '@janhq/core/.' import { atom } from 'jotai' export const totalRamAtom = atom(0) @@ -5,7 +6,7 @@ export const usedRamAtom = atom(0) export const cpuUsageAtom = atom(0) -export const gpusAtom = atom[]>([]) +export const gpusAtom = atom([]) export const nvidiaTotalVramAtom = atom(0) export const availableVramAtom = atom(0) From 0524dae663e8b5b104d5016954736c5e7b7a13f0 Mon Sep 17 00:00:00 2001 From: Van Pham <64197333+Van-QA@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:07:32 +0700 Subject: [PATCH 2/3] update template name --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index a6fa42e2db..451d0ae074 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,7 @@ --- -name: Bug report +name: report about: Create a report to help us improve Jan -title: 'bug: [DESCRIPTION]' +title: 'bug: ' labels: 'type: bug' assignees: '' From 9041143cea936db2966a5d60557635da2f7b9598 Mon Sep 17 00:00:00 2001 From: Van Pham <64197333+Van-QA@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:07:57 +0700 Subject: [PATCH 3/3] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 451d0ae074..1d9687ac30 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,5 +1,5 @@ --- -name: report +name: Report about: Create a report to help us improve Jan title: 'bug: ' labels: 'type: bug'