diff --git a/apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts b/apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts index c1e714a131b..975f3d7c24b 100644 --- a/apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts +++ b/apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts @@ -197,7 +197,7 @@ describe("agent-wrappers copilot", () => { expect(wrapper).toContain('_superset_emit_event "Start"'); expect(wrapper).toContain('_superset_emit_event "PermissionRequest"'); expect(wrapper).toContain( - `"$REAL_BIN" -c 'notify=["bash","${path.join(TEST_HOOKS_DIR, "notify.sh")}"]' "$@"`, + `"$REAL_BIN" --enable codex_hooks -c 'notify=["bash","${path.join(TEST_HOOKS_DIR, "notify.sh")}"]' "$@"`, ); expect(wrapper).toContain("SUPERSET_CODEX_START_WATCHER_PID"); expect(wrapper).toContain('kill "$SUPERSET_CODEX_START_WATCHER_PID"'); @@ -209,6 +209,46 @@ describe("agent-wrappers copilot", () => { expect(wrapper).toContain(execLine); }); + it("forwards codex_hooks enablement through the codex wrapper for manual launches", () => { + const realBinDir = path.join(TEST_ROOT, "real-bin"); + const realCodex = path.join(realBinDir, "codex"); + const wrapperPath = path.join(TEST_BIN_DIR, "codex"); + const argsFile = path.join(TEST_ROOT, "codex-args.txt"); + + mkdirSync(realBinDir, { recursive: true }); + writeFileSync( + realCodex, + `#!/bin/bash +printf '%s\n' "$@" > "${argsFile}" +exit 0 +`, + { mode: 0o755 }, + ); + chmodSync(realCodex, 0o755); + + createCodexWrapper(); + + execFileSync(wrapperPath, ["exec", "Reply with exactly OK."], { + env: { + ...process.env, + PATH: `${TEST_BIN_DIR}:${realBinDir}:${process.env.PATH || ""}`, + SUPERSET_TAB_ID: "tab-1", + }, + encoding: "utf-8", + }); + + expect(readFileSync(argsFile, "utf-8")).toBe( + `${[ + "--enable", + "codex_hooks", + "-c", + `notify=["bash","${path.join(TEST_HOOKS_DIR, "notify.sh")}"]`, + "exec", + "Reply with exactly OK.", + ].join("\n")}\n`, + ); + }); + it("creates mastracode wrapper passthrough", () => { createMastraWrapper(); diff --git a/apps/desktop/src/main/lib/agent-setup/templates/codex-wrapper-exec.template.sh b/apps/desktop/src/main/lib/agent-setup/templates/codex-wrapper-exec.template.sh index 42124f3184a..8aa12395105 100644 --- a/apps/desktop/src/main/lib/agent-setup/templates/codex-wrapper-exec.template.sh +++ b/apps/desktop/src/main/lib/agent-setup/templates/codex-wrapper-exec.template.sh @@ -72,7 +72,7 @@ if [ -n "$SUPERSET_TAB_ID" ] && [ -f "{{NOTIFY_PATH}}" ]; then SUPERSET_CODEX_START_WATCHER_PID=$! fi -"$REAL_BIN" -c 'notify=["bash","{{NOTIFY_PATH}}"]' "$@" +"$REAL_BIN" --enable codex_hooks -c 'notify=["bash","{{NOTIFY_PATH}}"]' "$@" SUPERSET_CODEX_STATUS=$? if [ -n "$SUPERSET_CODEX_START_WATCHER_PID" ]; then