The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a restart strips the env only for our own image
Teknium282970d6d454
diff --git a/apps/desktop/electron/linux-sandbox-relaunch.test.ts b/apps/desktop/electron/linux-sandbox-relaunch.test.tsindex 3f88a6ed2ed..ecfe89cbc04 100644--- a/apps/desktop/electron/linux-sandbox-relaunch.test.ts+++ b/apps/desktop/electron/linux-sandbox-relaunch.test.ts@@ -138,6 +138,45 @@ describe('Linux runtime --no-sandbox relaunch', () => {}})+ // Hermes started from another app's AppImage (an IDE or terminal) inherits+ // that app's APPDIR/APPIMAGE and its mount on PATH and LD_LIBRARY_PATH;+ // app.relaunch kept them, so the restart must start Hermes with that env whole.+ it.skipIf(process.platform !== 'linux')("restarts with another app's AppImage env intact", async () => {+ const saved = { ...process.env }+ const mount = '/tmp/.mount_IdeAbC123'++ const foreign = {+ APPDIR: mount,+ APPIMAGE: '/home/u/Apps/Ide.AppImage',+ LD_LIBRARY_PATH: `${mount}/usr/lib`,+ PATH: `${mount}/usr/bin:/usr/local/bin:/usr/bin:/bin`,+ SHELL: `${mount}/usr/bin/zsh`+ }++ try {+ delete process.env.ELECTRON_DISABLE_SANDBOX+ delete process.env.HERMES_DESKTOP_TMPDIR+ Object.assign(process.env, foreign)+ vi.resetModules()+ const { relaunchIfNoSandboxCameTooLate } = await import('./linux-sandbox-relaunch')+ const relaunch = recordNextSpawn()++ const relaunched = relaunchIfNoSandboxCameTooLate(+ {+ commandLine: { hasSwitch: name => name === 'no-sandbox' },+ releaseSingleInstanceLock: () => undefined,+ exit: () => undefined+ },+ () => undefined+ )++ expect(relaunched).toBe(true)+ expect(relaunch.env).toMatchObject(foreign)+ } finally {+ restoreEnv(saved)+ }+ })+// 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.diff --git a/apps/desktop/electron/relaunch-target.ts b/apps/desktop/electron/relaunch-target.tsindex 5108115b28c..b4d1e182511 100644--- a/apps/desktop/electron/relaunch-target.ts+++ b/apps/desktop/electron/relaunch-target.ts@@ -170,10 +170,13 @@ export function relaunchNow(): void {host.releaseSingleInstanceLock()- // The executable of an unpacked or extracted app lives in a directory that- // outlives this process and that no AppRun re-enters: keep its environment.- const appDir = env.APPDIR && posix.resolve(env.APPDIR)- const childEnv = appDir && isInside(appDir, posix.resolve(target)) ? env : withoutMountEntries(env)+ // Only a restart of our own image file (relaunchTarget returns it only when+ // ownAppImage claims it) drops the dying mount. Any other target keeps the env+ // whole: the executable inside an extracted APPDIR (a plain directory, maybe+ // reached through a symlinked $TMPDIR) needs APPDIR/APPIMAGE, which no AppRun+ // restores, and another app's AppImage env is the user's, as app.relaunch kept it.+ const ownImage = env.APPIMAGE && posix.resolve(target) === posix.resolve(env.APPIMAGE)+ const childEnv = ownImage ? withoutMountEntries(env) : envconst child = spawn('/bin/sh', ['-c', EXEC_WITH_STDIO_ONLY, target, ...args], {detached: true,