Skip to content

Commit cd102ef

Browse files
committed
test: isolate Codex native item release guard
1 parent 38e1654 commit cd102ef

1 file changed

Lines changed: 17 additions & 66 deletions

File tree

‎extensions/codex/src/app-server/run-attempt.test.ts‎

Lines changed: 17 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,74 +3309,25 @@ describe("runCodexAppServerAttempt", () => {
33093309
).toBe("release-pending-terminal");
33103310
});
33113311

3312-
it("waits for active native items before terminal dynamic tool release", async () => {
3313-
const harness = createStartedThreadHarness();
3314-
testing.setOpenClawCodingToolsFactoryForTests(() => [
3315-
{
3316-
...createRuntimeDynamicTool("image_generate"),
3317-
execute: vi.fn(async () => ({
3318-
content: [{ type: "text" as const, text: "Background task started." }],
3319-
details: { async: true, status: "started", taskId: "task-1" },
3320-
terminate: true,
3321-
})),
3322-
},
3323-
]);
3324-
3325-
const params = createParams(
3326-
path.join(tempDir, "session.jsonl"),
3327-
path.join(tempDir, "workspace"),
3328-
);
3329-
params.disableTools = false;
3330-
params.runtimePlan = createCodexRuntimePlanFixture();
3331-
3332-
const run = runCodexAppServerAttempt(params);
3333-
await harness.waitForMethod("turn/start");
3334-
await harness.notify({
3335-
method: "item/started",
3336-
params: {
3337-
threadId: "thread-1",
3338-
turnId: "turn-1",
3339-
item: { type: "commandExecution", id: "cmd-1", status: "inProgress" },
3340-
},
3341-
});
3342-
3343-
await expect(
3344-
harness.handleServerRequest({
3345-
id: "request-image-generate",
3346-
method: "item/tool/call",
3347-
params: {
3348-
threadId: "thread-1",
3349-
turnId: "turn-1",
3350-
callId: "call-image-1",
3351-
namespace: null,
3352-
tool: "image_generate",
3353-
arguments: { prompt: "lighthouse" },
3354-
},
3312+
it("waits for active native items before terminal dynamic tool release", () => {
3313+
expect(
3314+
testing.resolveTerminalDynamicToolBatchAction({
3315+
activeAppServerTurnRequests: 0,
3316+
activeTurnItemIdsCount: 1,
3317+
pendingOpenClawDynamicToolCompletionIdsCount: 0,
3318+
currentTurnHadNonTerminalDynamicToolResult: false,
3319+
hasPendingTerminalDynamicToolRelease: true,
33553320
}),
3356-
).resolves.toEqual({
3357-
success: true,
3358-
contentItems: [{ type: "inputText", text: "Background task started." }],
3359-
});
3360-
expect(harness.requests.some((request) => request.method === "turn/interrupt")).toBe(false);
3361-
3362-
await harness.notify({
3363-
method: "item/completed",
3364-
params: {
3365-
threadId: "thread-1",
3366-
turnId: "turn-1",
3367-
item: { type: "commandExecution", id: "cmd-1", status: "completed" },
3368-
},
3369-
});
3370-
3371-
const result = await run;
3372-
expect(result.timedOut).toBe(false);
3321+
).toBe("wait");
33733322
expect(
3374-
harness.requests.some(
3375-
(request) =>
3376-
request.method === "turn/interrupt" &&
3377-
(request.params as { turnId?: string } | undefined)?.turnId === "turn-1",
3378-
),
3379-
).toBe(true);
3323+
testing.resolveTerminalDynamicToolBatchAction({
3324+
activeAppServerTurnRequests: 0,
3325+
activeTurnItemIdsCount: 0,
3326+
pendingOpenClawDynamicToolCompletionIdsCount: 0,
3327+
currentTurnHadNonTerminalDynamicToolResult: false,
3328+
hasPendingTerminalDynamicToolRelease: true,
3329+
}),
3330+
).toBe("release-pending-terminal");
33803331
});
33813332

33823333
it("emits request-boundary terminal diagnostics when a wrapped dynamic tool does not", async () => {

0 commit comments

Comments
 (0)