Skip to content

The agent that grows with you

refactor(desktop): the Electron machine profile drops its NVIDIA and model reads

alt-glitchb01137173db7
diff --git a/apps/desktop/electron/machine-profile.test.ts b/apps/desktop/electron/machine-profile.test.ts
index a329f3c79e6..c2451fb5828 100644
--- a/apps/desktop/electron/machine-profile.test.ts
+++ b/apps/desktop/electron/machine-profile.test.ts
@@ -4,13 +4,12 @@ import * as os from 'node:os'
import { beforeEach, expect, it, vi } from 'vitest'
const host = vi.hoisted(() => ({
- getGPUInfo: vi.fn(),
getLocale: vi.fn((): string => 'fr-CA'),
handle: vi.fn()
}))
vi.mock('electron', () => ({
- app: { getGPUInfo: host.getGPUInfo, getLocale: host.getLocale },
+ app: { getLocale: host.getLocale },
ipcMain: { handle: host.handle }
}))
@@ -19,41 +18,27 @@ import { registerMachineProfile } from './machine-profile'
beforeEach((): void => {
host.handle.mockReset()
- host.getGPUInfo.mockReset()
host.getLocale.mockClear()
})
-function handler(): () => Promise<MachineProfile> {
+function handler(): () => MachineProfile {
registerMachineProfile()
const registration = host.handle.mock.calls.find(([channel]): boolean => channel === 'hermes:machine:profile')
expect(registration).toBeDefined()
- return registration![1] as () => Promise<MachineProfile>
+ return registration![1] as () => MachineProfile
}
-it('registers the renderer channel and reports native machine facts with the OS locale and GPU', async (): Promise<void> => {
- host.getGPUInfo.mockResolvedValue({ gpuDevice: [{ vendorId: 0x8086 }, { vendorId: 0x10de }] })
- const result = await handler()()
+it('registers the renderer channel and reports native machine facts with the OS locale', (): void => {
+ const result = handler()()
const { birthtimeMs } = statSync(os.homedir())
- expect(result).toMatchObject({
+ expect(result).toEqual({
ageDays: birthtimeMs > 0 ? Math.max(0, Math.floor((Date.now() - birthtimeMs) / 86_400_000)) : null,
arch: process.arch,
locale: 'fr-CA',
- nvidia: true,
platform: process.platform,
release: os.release(),
username: os.userInfo().username
})
- expect(typeof result.model).toBe('string')
- expect(host.getGPUInfo).toHaveBeenCalledWith('basic')
-})
-
-it('keeps machine facts available when Chromium cannot enumerate GPUs', async (): Promise<void> => {
- host.getGPUInfo.mockRejectedValue(new Error('GPU info unavailable'))
- const result = await handler()()
-
- expect(result.nvidia).toBe(false)
- expect(result.platform).toBe(process.platform)
- expect(result.locale).toBe('fr-CA')
})
diff --git a/apps/desktop/electron/machine-profile.ts b/apps/desktop/electron/machine-profile.ts
index 8d980139870..a08c9f5b9f0 100644
--- a/apps/desktop/electron/machine-profile.ts
+++ b/apps/desktop/electron/machine-profile.ts
@@ -7,8 +7,6 @@ export interface MachineProfile {
ageDays: number | null
arch: string
locale: string
- model: string
- nvidia: boolean
platform: NodeJS.Platform
release: string
username: string
@@ -18,7 +16,7 @@ export function registerMachineProfile(): void {
ipcMain.handle('hermes:machine:profile', readMachineProfile)
}
-async function readMachineProfile(): Promise<MachineProfile> {
+function readMachineProfile(): MachineProfile {
let ageDays: number | null = null
let username = ''
@@ -43,30 +41,8 @@ async function readMachineProfile(): Promise<MachineProfile> {
ageDays,
arch: process.arch,
locale: app.getLocale() || '',
- model: readHardwareModel(),
- nvidia: await hasNvidiaGpu(),
platform: process.platform,
release: os.release(),
username
}
}
-
-function readHardwareModel(): string {
- try {
- // ARM firmware supplies model names such as NVIDIA_DGX_Spark here.
- return fs.readFileSync('/proc/device-tree/model', 'utf8').replace(/\0/g, '').trim()
- } catch {
- return ''
- }
-}
-
-async function hasNvidiaGpu(): Promise<boolean> {
- try {
- // Chromium already enumerates GPUs; no vendor tools or subprocess are needed.
- const info = (await app.getGPUInfo('basic')) as { gpuDevice?: { vendorId?: number }[] }
-
- return (info.gpuDevice ?? []).some((device): boolean => device.vendorId === 0x10de)
- } catch {
- return false
- }
-}