feat: interrupt canceled codex app-server turns
This commit is contained in:
@@ -1284,6 +1284,54 @@ test("codex app-server runner steers an active turn when a target turn id is pre
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner interrupts the active turn when the task is canceled while running", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_WAIT_FOR_INTERRUPT;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_WAIT_FOR_INTERRUPT = "1";
|
||||
try {
|
||||
const interruptChecks = [];
|
||||
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
|
||||
codexAppServerEnabled: true,
|
||||
codexAppServerCommand: process.execPath,
|
||||
codexAppServerArgs: ["tests/fixtures/codex-app-server-runtime.mjs"],
|
||||
codexAppServerWorkdir: repoRoot,
|
||||
codexAppServerTimeoutMs: 5000,
|
||||
});
|
||||
|
||||
const result = await executeCodexAppServerTask(
|
||||
{
|
||||
...runnerConfig,
|
||||
interruptPollIntervalMs: 10,
|
||||
shouldInterruptActiveTurn: async (activeTurn) => {
|
||||
interruptChecks.push(activeTurn);
|
||||
return activeTurn.taskId === "task-turn-interrupt";
|
||||
},
|
||||
},
|
||||
{
|
||||
taskId: "task-turn-interrupt",
|
||||
taskType: "conversation_reply",
|
||||
targetCodexThreadRef: "active-thread-2",
|
||||
targetCodexFolderRef: repoRoot,
|
||||
executionPrompt: "继续执行一个可取消的长任务",
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(result.status, "interrupted");
|
||||
assert.equal(result.threadId, "active-thread-2");
|
||||
assert.equal(result.turnId, "turn-fixture");
|
||||
assert.equal(result.turnControl, "interrupt");
|
||||
assert.equal(result.replyBody, "已按用户要求中断当前 Codex turn。");
|
||||
assert.equal(interruptChecks[0]?.taskId, "task-turn-interrupt");
|
||||
assert.equal(interruptChecks[0]?.threadId, "active-thread-2");
|
||||
assert.equal(interruptChecks[0]?.turnId, "turn-fixture");
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_WAIT_FOR_INTERRUPT;
|
||||
} else {
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_WAIT_FOR_INTERRUPT = previous;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server config exposes ws transport without mutating stdio defaults", () => {
|
||||
const previousTransport = process.env.BOSS_CODEX_APP_SERVER_TRANSPORT;
|
||||
const previousUrl = process.env.BOSS_CODEX_APP_SERVER_URL;
|
||||
|
||||
Reference in New Issue
Block a user