diff --git a/src/codex/home.ts b/src/codex/home.ts index 9440d5aec47..71a2ad0a0a9 100644 --- a/src/codex/home.ts +++ b/src/codex/home.ts @@ -145,11 +145,11 @@ export function defaultCodexHome(deps: CodexHomeDeps = {}): string { return findWslWindowsCodexHome(deps) ?? defaultHome; } -/** Files and directories Codex itself writes into a home it is using. */ -const LOCAL_CODEX_STATE = ["config.toml", "auth.json", "sessions", "history.jsonl"] as const; - function localCodexHomeInUse(home: string, deps: CodexHomeDeps): boolean { - return LOCAL_CODEX_STATE.some(entry => pathPresent(join(home, entry), deps)); + // Files and directories Codex itself writes into a home it is using. Kept local: defaultCodexHome + // runs during other modules' initialisation (the storage workers reach it through an import + // cycle), and a module-level const declared below it is still in its temporal dead zone then. + return ["config.toml", "auth.json", "sessions", "history.jsonl"].some(entry => pathPresent(join(home, entry), deps)); } /** stat-based presence: an unexpected stat error counts as present, never as a reason to switch homes. */ diff --git a/tests/providers/codebuddy-mcp-server.test.ts b/tests/providers/codebuddy-mcp-server.test.ts index d5d1a5d4b16..3deac6e24a4 100644 --- a/tests/providers/codebuddy-mcp-server.test.ts +++ b/tests/providers/codebuddy-mcp-server.test.ts @@ -1,9 +1,10 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import { afterEach, describe, expect, test } from "bun:test"; -import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; import { CODEBUDDY_TOOL_LIMITS } from "../../src/adapters/codebuddy/tool-bridge"; import { codeBuddyMcpInvocation } from "../../src/adapters/coding-agent/turn"; @@ -49,7 +50,10 @@ async function rejectedCatalog(rawCatalog: string): Promise { afterEach(() => { for (const dir of tempDirs.splice(0)) { - rmSync(dir, { recursive: true, force: true }); + // Windows keeps the compiled ocx executable locked for a moment after its process exits, so + // a plain rmSync fails with EBUSY; the shared helper waits on the same bounded schedule as + // every other fixture teardown. + removeTreeWithRetry(dir); } });