diff --git a/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts b/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts index 39639a36b49..352a54d76bd 100644 --- a/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts +++ b/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts @@ -1,6 +1,6 @@ // Why: stdin ownership is a cross-agent process contract; one executable // matrix catches an unread early exit without duplicating template assertions. -import { describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { spawn } from 'node:child_process' import { mkdtempSync, readFileSync, readdirSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' @@ -47,6 +47,25 @@ import { createAgentHookMemorySftp } from './agent-hook-memory-sftp.test-fixture const REMOTE_HOME = '/home/dev' const LARGE_PAYLOAD = Buffer.alloc(1_000_000, 'x') +let isolatedUserDataDir = '' +let previousUserDataPath: string | undefined + +beforeEach(() => { + previousUserDataPath = process.env.ORCA_USER_DATA_PATH + isolatedUserDataDir = mkdtempSync(join(tmpdir(), 'orca-hook-stdin-user-data-')) + // Why: Orca-managed Codex hooks resolve through ORCA_USER_DATA_PATH before + // the mocked home; an inherited live path would let this test rewrite them. + process.env.ORCA_USER_DATA_PATH = isolatedUserDataDir +}) + +afterEach(() => { + if (previousUserDataPath === undefined) { + delete process.env.ORCA_USER_DATA_PATH + } else { + process.env.ORCA_USER_DATA_PATH = previousUserDataPath + } + rmSync(isolatedUserDataDir, { recursive: true, force: true }) +}) const REMOTE_INSTALLERS = [ { agent: 'antigravity', @@ -200,6 +219,9 @@ describe('Windows managed hook stdin structure', () => { expect(entry.install().state, `${entry.agent} install status`).toBe('installed') } }) + expect( + readFileSync(join(isolatedUserDataDir, 'codex-runtime-home', 'home', 'hooks.json'), 'utf8') + ).toContain('WindowsPowerShell') const hooksDir = join(home, '.orca', 'agent-hooks') const fileNames = readdirSync(hooksDir) const mainBatchScripts = fileNames.filter(