The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): the --no-sandbox early restart no longer forces SwiftShader on NVIDIA
Teknium7cf69d327227
diff --git a/apps/desktop/electron/linux-sandbox-relaunch.test.ts b/apps/desktop/electron/linux-sandbox-relaunch.test.tsindex e851272c9a2..1ff0d668e96 100644--- a/apps/desktop/electron/linux-sandbox-relaunch.test.ts+++ b/apps/desktop/electron/linux-sandbox-relaunch.test.ts@@ -4,6 +4,8 @@ import path from 'node:path'import { describe, expect, it, vi } from 'vitest'+import { createLinuxGpuBootWindow } from './linux-gpu-fallback'+import { createNvidiaEglRecovery } from './linux-nvidia-egl-recovery'import { linuxNoSandboxRelaunch } from './linux-sandbox-relaunch'const argv = ['/opt/Hermes/hermes', '--ozone-platform=x11', 'hermes://session/abc']@@ -90,14 +92,17 @@ describe('Linux runtime --no-sandbox relaunch', () => {let relaunchEnv: NodeJS.ProcessEnv = {}- const relaunched = relaunchIfNoSandboxCameTooLate({- commandLine: { hasSwitch: name => name === 'no-sandbox' },- relaunch: () => {- relaunchEnv = { ...process.env }+ const relaunched = relaunchIfNoSandboxCameTooLate(+ {+ commandLine: { hasSwitch: name => name === 'no-sandbox' },+ relaunch: () => {+ relaunchEnv = { ...process.env }+ },+ releaseSingleInstanceLock: () => undefined,+ exit: () => undefined},- releaseSingleInstanceLock: () => undefined,- exit: () => undefined- })+ () => undefined+ )expect(relaunched).toBe(true)expect(relaunchEnv.TMPDIR).toBe(shortDir)@@ -107,6 +112,52 @@ describe('Linux runtime --no-sandbox relaunch', () => {}})+ // main.ts wires the NVIDIA recovery's cleanExit in: the restart happens after+ // createNvidiaEglRecovery wrote its `booting` witness, and the next launch+ // must not read that deliberate exit as a GPU abort mid-boot.+ it.skipIf(process.platform !== 'linux')('restarts without leaving the next launch a GPU-abort witness', async () => {+ const saved = { ...process.env }+ const userData = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-sandbox-relaunch-gpu-'))++ const launch = () =>+ createNvidiaEglRecovery({+ bootWindow: createLinuxGpuBootWindow({ platform: 'linux' }),+ userData,+ driverMajor: 600,+ driverVersion: '600.1.2',+ appVersion: '0.0.0',+ platform: 'linux',+ env: {},+ primary: true,+ relaunch: () => undefined,+ log: () => undefined+ })++ try {+ delete process.env.ELECTRON_DISABLE_SANDBOX+ delete process.env.APPIMAGE+ vi.resetModules()+ const { relaunchIfNoSandboxCameTooLate } = await import('./linux-sandbox-relaunch')+ const recovery = launch()++ const relaunched = relaunchIfNoSandboxCameTooLate(+ {+ commandLine: { hasSwitch: name => name === 'no-sandbox' },+ relaunch: () => undefined,+ releaseSingleInstanceLock: () => undefined,+ exit: () => undefined+ },+ () => recovery.cleanExit()+ )++ expect(relaunched).toBe(true)+ expect(launch().decision.enable).toBe(false)+ } finally {+ restoreEnv(saved)+ fs.rmSync(userData, { recursive: true, force: true })+ }+ })+// Electron's relauncher execs its target with PR_SET_NO_NEW_PRIVS: the image's// runtime then cannot FUSE-mount, and the old mount dies with this process.it.skipIf(process.platform !== 'linux')(@@ -138,12 +189,15 @@ describe('Linux runtime --no-sandbox relaunch', () => {process.env.APPIMAGE = imageprocess.env.APPDIR = path.dirname(process.execPath)- relaunchIfNoSandboxCameTooLate({- commandLine: { hasSwitch: name => name === 'no-sandbox' },- relaunch: () => events.push('relaunch'),- releaseSingleInstanceLock: () => events.push('release'),- exit: () => events.push('exit')- })+ relaunchIfNoSandboxCameTooLate(+ {+ commandLine: { hasSwitch: name => name === 'no-sandbox' },+ relaunch: () => events.push('relaunch'),+ releaseSingleInstanceLock: () => events.push('release'),+ exit: () => events.push('exit')+ },+ () => undefined+ )await vi.waitFor(() => expect(fs.existsSync(report)).toBe(true), { timeout: 5000 })const [args, session, tmpdir, readyFd] = fs.readFileSync(report, 'utf8').split('\n')diff --git a/apps/desktop/electron/linux-sandbox-relaunch.ts b/apps/desktop/electron/linux-sandbox-relaunch.tsindex ea4a14a67b9..4e51a526d64 100644--- a/apps/desktop/electron/linux-sandbox-relaunch.ts+++ b/apps/desktop/electron/linux-sandbox-relaunch.ts@@ -76,8 +76,11 @@ interface SandboxRelaunchHost extends RelaunchHost {}// Call once, in the lock-owning instance, after every runtime switch source-// (sandbox ladder, config.yaml) has run and before `ready`.-export function relaunchIfNoSandboxCameTooLate(host: SandboxRelaunchHost): boolean {+// (sandbox ladder, config.yaml) has run and before `ready`. `beforeExit` runs+// only when this instance exits for the relaunch: a deliberate restart this+// early must clear what a mid-boot abort would leave behind (the NVIDIA boot+// witness), or the next launch reads it as a GPU failure.+export function relaunchIfNoSandboxCameTooLate(host: SandboxRelaunchHost, beforeExit: () => void): boolean {const relaunch = linuxNoSandboxRelaunch({platform: process.platform,runtimeNoSandbox: host.commandLine.hasSwitch('no-sandbox'),@@ -97,6 +100,8 @@ export function relaunchIfNoSandboxCameTooLate(host: SandboxRelaunchHost): boole// file reuses that descriptor.delete process.env[LAUNCHER_READY_FD_ENV]restoreLaunchTmpdir(process.env)+ // Before the relaunch: an AppImage target starts at once and reads the witness.+ beforeExit()relaunchNow(host, relaunch.args, relaunch.strategy, process.env)host.exit(0)diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 9cba2f32f3b..08c2f86f3f5 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -1284,7 +1284,7 @@ let desktopSshPathOverride = ''// Linux: a runtime `--no-sandbox` kills renderers on /dev/shm (linux-sandbox-relaunch.ts).if (isPrimaryInstance) {- relaunchIfNoSandboxCameTooLate(app)+ relaunchIfNoSandboxCameTooLate(app, () => nvidiaEglRecovery.cleanExit())}// ACTIVE_HERMES_ROOT — the canonical mutable Hermes install. Same pathdiff --git a/apps/desktop/electron/relaunch-target.test.ts b/apps/desktop/electron/relaunch-target.test.tsindex 83223300587..8dd298ff637 100644--- a/apps/desktop/electron/relaunch-target.test.ts+++ b/apps/desktop/electron/relaunch-target.test.ts@@ -68,12 +68,15 @@ describe('relaunchNow', () => {const { relaunchIfNoSandboxCameTooLate } = await import('./linux-sandbox-relaunch')expect(- relaunchIfNoSandboxCameTooLate({- commandLine: { hasSwitch: name => name === 'no-sandbox' },- relaunch: () => events.push('relaunch'),- releaseSingleInstanceLock: () => events.push('release'),- exit: () => events.push('exit')- })+ relaunchIfNoSandboxCameTooLate(+ {+ commandLine: { hasSwitch: name => name === 'no-sandbox' },+ relaunch: () => events.push('relaunch'),+ releaseSingleInstanceLock: () => events.push('release'),+ exit: () => events.push('exit')+ },+ () => events.push('beforeExit')+ )).toBe(false)expect(events).toEqual([])expect(process.env.TMPDIR).toBe(dir)