From 089bb32886c8c18f7fa20182c7bf8826d6935ac5 Mon Sep 17 00:00:00 2001 From: "hermes-seaeye[bot]" <307254004+hermes-seaeye[bot]@users.noreply.github.com> Date: Sun, 6 Sep 2026 10:15:23 +0000 Subject: [PATCH] fmt(js): `npm run fix` on merge (#104210) Co-authored-by: github-actions[bot] --- .../desktop/electron/remote-lifecycle.test.ts | 107 ++++++++++-------- .../desktop/src/store/statusbar-prefs.test.ts | 5 +- 2 files changed, 63 insertions(+), 49 deletions(-) diff --git a/apps/desktop/electron/remote-lifecycle.test.ts b/apps/desktop/electron/remote-lifecycle.test.ts index 6cd596ae85..408cd9e27a 100644 --- a/apps/desktop/electron/remote-lifecycle.test.ts +++ b/apps/desktop/electron/remote-lifecycle.test.ts @@ -1849,55 +1849,66 @@ test('cleanupStale keeps the lockfile when even SIGKILL cannot confirm the pid d // The record must survive so the next connect's reap pass retries. assert.ok(!ssh.calls.some(c => /rm -f .*backend\.lock\.json/.test(c))) }) -test.skipIf(process.platform === 'win32')('buildSpawnCommand quotes expandRemotePath fragments exactly once (real sh parse)', async () => { - // expandRemotePath() output is pre-quoted; a second shq() ships literal quote - // characters to the remote python. Parse the composed command with a real sh, - // as the remote login shell does, and require every path to come out clean. - const cmd = buildSpawnCommand('/x/hermes', 'work', { - hermesHome: '~/.hermes', - logPath: spawnLogPath(OWNERSHIP_ID, SPAWN_NONCE), - ownershipId: OWNERSHIP_ID, - reservationNonce: SPAWN_NONCE, - spawnNonce: SPAWN_NONCE, - tokenFilePath: spawnTokenPath(OWNERSHIP_ID, SPAWN_NONCE), - lockMetadata: { ownershipId: OWNERSHIP_ID, spawnNonce: SPAWN_NONCE } - }) - - // Capture the argv a remote shell would hand to python3, via a shim on PATH. - const root = await mkdtemp(path.join(os.tmpdir(), 'hermes-argv-shim-')) - try { - const shimDir = path.join(root, 'shim') - const fakeHome = path.join(root, 'home') - await mkdir(shimDir) - await mkdir(fakeHome) - const argvFile = path.join(shimDir, 'argv') - await writeFile(path.join(shimDir, 'python3'), `#!/bin/sh\nprintf '%s\\0' "$@" > '${argvFile}'\n`, { mode: 0o755 }) - await exec(cmd, { - env: { ...process.env, PATH: `${shimDir}:${process.env.PATH}`, HOME: fakeHome } +test.skipIf(process.platform === 'win32')( + 'buildSpawnCommand quotes expandRemotePath fragments exactly once (real sh parse)', + async () => { + // expandRemotePath() output is pre-quoted; a second shq() ships literal quote + // characters to the remote python. Parse the composed command with a real sh, + // as the remote login shell does, and require every path to come out clean. + const cmd = buildSpawnCommand('/x/hermes', 'work', { + hermesHome: '~/.hermes', + logPath: spawnLogPath(OWNERSHIP_ID, SPAWN_NONCE), + ownershipId: OWNERSHIP_ID, + reservationNonce: SPAWN_NONCE, + spawnNonce: SPAWN_NONCE, + tokenFilePath: spawnTokenPath(OWNERSHIP_ID, SPAWN_NONCE), + lockMetadata: { ownershipId: OWNERSHIP_ID, spawnNonce: SPAWN_NONCE } }) - const argv = (await readFile(argvFile, 'utf8')).split('\0') - // argv: ['-c', , , ] - assert.equal( - argv[2], - `${fakeHome}/.hermes/.hermes-update-in-progress.mutex`, - 'mutex path must reach python fully expanded, with no quote characters' - ) + // Capture the argv a remote shell would hand to python3, via a shim on PATH. + const root = await mkdtemp(path.join(os.tmpdir(), 'hermes-argv-shim-')) - // The payload assigns reservation/lock/owner_file before its mkdir loop. - // Evaluate only that prefix the way the remote sh does; never the loop itself. - const payload = argv[3] - const loopStart = payload.indexOf('i=0;') - assert.ok(loopStart > 0, 'payload prefix sentinel missing') - const { stdout } = await exec(`${payload.slice(0, loopStart)} printf '%s\\n' "$reservation" "$lock" "$owner_file"`, { - env: { ...process.env, HOME: fakeHome } - }) - const [reservation, lock, ownerFile] = stdout.split('\n') - const base = `${fakeHome}/.hermes/desktop-ssh/${OWNERSHIP_ID}` - assert.equal(reservation, `${base}/.connect.lock`) - assert.equal(lock, `${base}/backend.lock.json`) - assert.equal(ownerFile, `${base}/.connect.lock/owner`) - } finally { - await rm(root, { recursive: true, force: true }) + try { + const shimDir = path.join(root, 'shim') + const fakeHome = path.join(root, 'home') + await mkdir(shimDir) + await mkdir(fakeHome) + const argvFile = path.join(shimDir, 'argv') + await writeFile(path.join(shimDir, 'python3'), `#!/bin/sh\nprintf '%s\\0' "$@" > '${argvFile}'\n`, { + mode: 0o755 + }) + await exec(cmd, { + env: { ...process.env, PATH: `${shimDir}:${process.env.PATH}`, HOME: fakeHome } + }) + const argv = (await readFile(argvFile, 'utf8')).split('\0') + + // argv: ['-c', , , ] + assert.equal( + argv[2], + `${fakeHome}/.hermes/.hermes-update-in-progress.mutex`, + 'mutex path must reach python fully expanded, with no quote characters' + ) + + // The payload assigns reservation/lock/owner_file before its mkdir loop. + // Evaluate only that prefix the way the remote sh does; never the loop itself. + const payload = argv[3] + const loopStart = payload.indexOf('i=0;') + assert.ok(loopStart > 0, 'payload prefix sentinel missing') + + const { stdout } = await exec( + `${payload.slice(0, loopStart)} printf '%s\\n' "$reservation" "$lock" "$owner_file"`, + { + env: { ...process.env, HOME: fakeHome } + } + ) + + const [reservation, lock, ownerFile] = stdout.split('\n') + const base = `${fakeHome}/.hermes/desktop-ssh/${OWNERSHIP_ID}` + assert.equal(reservation, `${base}/.connect.lock`) + assert.equal(lock, `${base}/backend.lock.json`) + assert.equal(ownerFile, `${base}/.connect.lock/owner`) + } finally { + await rm(root, { recursive: true, force: true }) + } } -}) +) diff --git a/apps/desktop/src/store/statusbar-prefs.test.ts b/apps/desktop/src/store/statusbar-prefs.test.ts index a8f67417d9..afe111e4f0 100644 --- a/apps/desktop/src/store/statusbar-prefs.test.ts +++ b/apps/desktop/src/store/statusbar-prefs.test.ts @@ -38,7 +38,10 @@ describe('statusbar hidden items', () => { }) it('surfaces the approval pill for installs that hid it under the v1 defaults, keeping their other choices', async () => { - window.localStorage.setItem('hermes.desktop.statusbarHidden', JSON.stringify(['approval-mode', 'cron', 'gateway-health'])) + window.localStorage.setItem( + 'hermes.desktop.statusbarHidden', + JSON.stringify(['approval-mode', 'cron', 'gateway-health']) + ) const { $statusbarHiddenIds } = await loadStore()