The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(installer): isolate Linux update Electron route
ethernetaed7ffd82195
diff --git a/tests-js/scripts/launch-from-spec.test.ts b/tests-js/scripts/launch-from-spec.test.tsnew file mode 100644index 00000000000..0e7c5071de3--- /dev/null+++ b/tests-js/scripts/launch-from-spec.test.ts@@ -0,0 +1,41 @@+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'++import { expect, test } from 'vitest'++import { isolateUpdateWindowEnvironment } from '../../tests/install/e2e-assets/smoke-env.mjs'++test('the update window clones userData without inheriting another Electron singleton', (): void => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'update-window-userdata-'))+ const userData = path.join(root, 'electron-user-data')+ fs.mkdirSync(userData)+ fs.writeFileSync(path.join(userData, 'connections.json'), '{"primary":"local"}\n')++ for (const name of ['SingletonLock', 'SingletonSocket', 'SingletonCookie']) {+ fs.symlinkSync(path.join(root, `${name}-target`), path.join(userData, name))+ }++ const captured = {+ HERMES_HOME: path.join(root, 'hermes-home'),+ HERMES_DESKTOP_USER_DATA_DIR: userData,+ PATH: process.env.PATH || '',+ }++ try {+ const isolated = isolateUpdateWindowEnvironment(captured)+ const isolatedUserData = isolated.HERMES_DESKTOP_USER_DATA_DIR++ expect(isolatedUserData).not.toBe(userData)+ expect(captured.HERMES_DESKTOP_USER_DATA_DIR).toBe(userData)+ expect(isolated.HERMES_HOME).toBe(captured.HERMES_HOME)+ expect(fs.readFileSync(path.join(isolatedUserData, 'connections.json'), 'utf8')).toBe('{"primary":"local"}\n')++ for (const name of ['SingletonLock', 'SingletonSocket', 'SingletonCookie']) {+ expect(() => fs.lstatSync(path.join(isolatedUserData, name))).toThrow()+ expect(fs.lstatSync(path.join(userData, name)).isSymbolicLink()).toBe(true)+ }+ } finally {+ fs.rmSync(root, { recursive: true, force: true })+ }+})diff --git a/tests/install/e2e-assets/launch-from-spec.mjs b/tests/install/e2e-assets/launch-from-spec.mjsindex 1e566f9c5e4..9fe75ff3363 100644--- a/tests/install/e2e-assets/launch-from-spec.mjs+++ b/tests/install/e2e-assets/launch-from-spec.mjs@@ -33,7 +33,7 @@ import { prepareWindowForInput } from './window-input.cjs';import { pickAppWindow, openAbout, waitForUpdate } from './update-ui.cjs';import { observeSourceUpdate } from './source-update-observer.mjs';import { runUpdateWindowChat } from './update-window-chat.mjs';-import { updateWindowEnvironment } from './smoke-env.mjs';+import { isolateUpdateWindowEnvironment, updateWindowEnvironment } from './smoke-env.mjs';/*** @typedef {{argv: string[], cwd: string, env: Record<string, string>,@@ -146,9 +146,10 @@ async function main() {/** @type {LaunchSpec} */const spec = JSON.parse(fs.readFileSync(values.spec, 'utf8'));const launch = resolveLaunch(spec);- const launchEnv = updateWindowEnvironment(launch.env, values['repo-dir'], 'source');- settleSourceRuntime(values['repo-dir'], launchEnv);- log(`launching ${launch.executablePath} (shape: ${spec.matchedShape})`);+ const capturedEnv = updateWindowEnvironment(launch.env, values['repo-dir'], 'source');+ settleSourceRuntime(values['repo-dir'], capturedEnv);+ const launchEnv = isolateUpdateWindowEnvironment(capturedEnv);+ log(`launching ${launch.executablePath} (shape: ${spec.matchedShape}, isolated userData: ${launchEnv.HERMES_DESKTOP_USER_DATA_DIR})`);phase('launch');const app = await _electron.launch({diff --git a/tests/install/e2e-assets/smoke-env.d.mts b/tests/install/e2e-assets/smoke-env.d.mtsindex 3a9c40808b8..8907af9dbcc 100644--- a/tests/install/e2e-assets/smoke-env.d.mts+++ b/tests/install/e2e-assets/smoke-env.d.mts@@ -12,4 +12,7 @@ export interface SmokeEnvironment extends Record<string, string> {export function within(root: string, candidate: string): booleanexport function smokeEnvironment(inherited: NodeJS.ProcessEnv, home: string, userData: string): SmokeEnvironment+export function isolateUpdateWindowEnvironment<T extends Record<string, string>>(+ env: T & { HERMES_DESKTOP_USER_DATA_DIR: string },+): T & { HERMES_DESKTOP_USER_DATA_DIR: string }export function updateWindowEnvironment(inherited: NodeJS.ProcessEnv, root: string, origin: 'source' | 'bundled'): SmokeEnvironmentdiff --git a/tests/install/e2e-assets/smoke-env.mjs b/tests/install/e2e-assets/smoke-env.mjsindex 8d4c55dadd4..3cd1df65502 100644--- a/tests/install/e2e-assets/smoke-env.mjs+++ b/tests/install/e2e-assets/smoke-env.mjs@@ -53,6 +53,30 @@ export function smokeEnvironment(inherited, home, userData) {};}+const SINGLETON_FILES = new Set(['SingletonLock', 'SingletonSocket', 'SingletonCookie']);++/**+ * Give the independently driven update window its own Electron instance route.+ * The cloned state keeps the real connection and desktop preferences, while+ * HERMES_HOME remains shared so the app updates the actual installed runtime.+ *+ * @template {Record<string, string>} T+ * @param {T & {HERMES_DESKTOP_USER_DATA_DIR: string}} env+ * @returns {T & {HERMES_DESKTOP_USER_DATA_DIR: string}}+ */+export function isolateUpdateWindowEnvironment(env) {+ const source = env.HERMES_DESKTOP_USER_DATA_DIR;+ const isolated = fs.mkdtempSync(path.join(path.dirname(source), `${path.basename(source)}-app-update-`));+ fs.cpSync(source, isolated, {+ recursive: true,+ filter: (candidate) => {+ const relative = path.relative(source, candidate);+ return relative === '' || relative.includes(path.sep) || !SINGLETON_FILES.has(relative);+ },+ });+ return { ...env, HERMES_DESKTOP_USER_DATA_DIR: isolated };+}+// Source updater processes still need the git redirect; smokeEnvironment keeps// it while removing driver activation, credentials and remote/backend overrides./** @param {NodeJS.ProcessEnv} inherited @param {string} root @param {'source'|'bundled'} origin */