The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): the --no-sandbox early restart no longer makes software rendering sticky
Tekniumd9e3b5cd75f5
diff --git a/apps/desktop/electron/linux-gpu-fallback.ts b/apps/desktop/electron/linux-gpu-fallback.tsindex 203526de81f..c4b897d930d 100644--- a/apps/desktop/electron/linux-gpu-fallback.ts+++ b/apps/desktop/electron/linux-gpu-fallback.ts@@ -210,6 +210,24 @@ export function linuxGpuMarkerAfterSuccessfulBoot(options: {return linuxGpuFallbackMarker('gpu-launch-failure', options.appVersion)}+/**+ * A deliberate exit before the first window (a clean quit mid-boot, the runtime --no-sandbox+ * restart) settles this launch's `booting` witness as `ok`. Left behind, the next launch reads+ * it as a boot abort or a failed re-probe and engages software rendering. A sticky fallback+ * keeps its marker.+ */+export function clearLinuxGpuBootMarker(userDataDir: string, fallbackSticky: boolean): void {+ if (fallbackSticky) {+ return+ }++ try {+ writeLinuxGpuMarker(userDataDir, linuxGpuMarkerAfterSuccessfulBoot({ fallbackActive: false }))+ } catch {+ void 0+ }+}+export interface LinuxGpuLaunchDecision {enable: booleanreason: string | nulldiff --git a/apps/desktop/electron/linux-sandbox-relaunch.test.ts b/apps/desktop/electron/linux-sandbox-relaunch.test.tsindex e32c9e1ede6..3f88a6ed2ed 100644--- a/apps/desktop/electron/linux-sandbox-relaunch.test.ts+++ b/apps/desktop/electron/linux-sandbox-relaunch.test.ts@@ -6,7 +6,14 @@ import path from 'node:path'import { describe, expect, it, vi } from 'vitest'-import { createLinuxGpuBootWindow } from './linux-gpu-fallback'+import {+ clearLinuxGpuBootMarker,+ createLinuxGpuBootWindow,+ decideLinuxGpuLaunch,+ linuxGpuFallbackMarker,+ readLinuxGpuMarker,+ writeLinuxGpuMarker+} from './linux-gpu-fallback'import { createNvidiaEglRecovery } from './linux-nvidia-egl-recovery'import { linuxNoSandboxRelaunch } from './linux-sandbox-relaunch'@@ -177,6 +184,66 @@ describe('Linux runtime --no-sandbox relaunch', () => {}})+ // main.ts wires the generic ladder's cleanup in too: its `booting` witness was+ // written before the restart, and a re-probe after an update or one earlier+ // interrupted boot would otherwise turn the deliberate exit into sticky+ // software rendering on any Linux GPU.+ it.skipIf(process.platform !== 'linux')(+ 'restarts without leaving the generic GPU ladder a boot-abort witness',+ async () => {+ const saved = { ...process.env }+ const userData = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-sandbox-relaunch-linux-gpu-'))++ const launch = () => {+ const decision = decideLinuxGpuLaunch({+ argv: ['/opt/Hermes/hermes'],+ env: {},+ marker: readLinuxGpuMarker(userData),+ appVersion: '2.0.0',+ remoteDisplayReason: null,+ nvidiaFallbackActive: false+ })++ writeLinuxGpuMarker(userData, decision.nextMarker)++ return decision+ }++ try {+ delete process.env.ELECTRON_DISABLE_SANDBOX+ delete process.env.APPIMAGE+ vi.resetModules()+ const { relaunchIfNoSandboxCameTooLate } = await import('./linux-sandbox-relaunch')++ // An update re-probing an older version's fallback; one boot interrupted earlier;+ // and a genuine fallback of this version, which must stay sticky.+ for (const [prior, engagedAfter] of [+ [linuxGpuFallbackMarker('gpu-crash', '1.0.0'), false],+ [{ state: 'booting' as const }, false],+ [linuxGpuFallbackMarker('gpu-crash', '2.0.0'), true]+ ] as const) {+ writeLinuxGpuMarker(userData, prior)+ const decision = launch()+ recordNextSpawn()++ relaunchIfNoSandboxCameTooLate(+ {+ commandLine: { hasSwitch: name => name === 'no-sandbox' },+ releaseSingleInstanceLock: () => undefined,+ exit: () => undefined+ },+ () => clearLinuxGpuBootMarker(userData, decision.nextMarker.state === 'fallback')+ )++ expect(launch().enable).toBe(engagedAfter)+ }+ } finally {+ restoreEnv(saved)+ fs.rmSync(userData, { recursive: true, force: true })+ }+ }+ )+// Electron's relauncher execs with PR_SET_NO_NEW_PRIVS, inherited by the// backend and the agent's terminal: sudo and pkexec would stop working for// good. An unpacked app restarts as an ordinary child instead.diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 08c2f86f3f5..854e94a1058 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -329,6 +329,7 @@ import { applyLaunchProfileOverride } from './launch-profile'import { fetchLinkTitle, resolveFaviconCached } from './link-metadata'import { CHROMIUM_LOG_FILENAME, enableLinuxCrashDiagnostics, linuxCrashDiagnostics } from './linux-crash-diagnostics'import {+ clearLinuxGpuBootMarker,createLinuxGpuBootWindow,decideLinuxGpuLaunch,disableGpuSwitchNeededForReason,@@ -1284,7 +1285,11 @@ let desktopSshPathOverride = ''// Linux: a runtime `--no-sandbox` kills renderers on /dev/shm (linux-sandbox-relaunch.ts).if (isPrimaryInstance) {- relaunchIfNoSandboxCameTooLate(app, () => nvidiaEglRecovery.cleanExit())+ // A deliberate restart is no GPU failure: settle both ladders' boot witnesses before it.+ relaunchIfNoSandboxCameTooLate(app, () => {+ nvidiaEglRecovery.cleanExit()+ clearLinuxGpuBootMarker(app.getPath('userData'), linuxGpuFallbackSticky)+ })}// ACTIVE_HERMES_ROOT — the canonical mutable Hermes install. Same path@@ -18197,13 +18202,8 @@ app.on('before-quit', event => {}// #124843: a clean quit mid-boot must not trip next-launch --disable-gpu.- // Keyed on sticky (not active) so an engaged fallback keeps its marker.- if (process.platform === 'linux' && !linuxGpuFallbackSticky) {- try {- writeLinuxGpuMarker(app.getPath('userData'), linuxGpuMarkerAfterSuccessfulBoot({ fallbackActive: false }))- } catch {- void 0- }+ if (process.platform === 'linux') {+ clearLinuxGpuBootMarker(app.getPath('userData'), linuxGpuFallbackSticky)}// The always-on-top overlay isn't a "real" app window; close it so a stray