Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export class CodexEventHandler {
if (this.activeImageGenerationItems.delete(event.item.id)) {
return createImageGenerationCompleteUpdate(event.item);
}
return createImageGenerationUpdate(event.item);
return createImageGenerationUpdate(event.item, { terminalStatus: true });
case "reasoning":
if (this.seenReasoningDeltaItemIds.delete(event.item.id)) {
return null;
Expand Down
23 changes: 20 additions & 3 deletions src/CodexToolCallMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,24 @@ export function createImageGenerationCompleteUpdate(
return {
sessionUpdate: "tool_call_update",
toolCallId: item.id,
status: imageGenerationToolStatus(item.status),
status: imageGenerationTerminalStatus(item.status),
content: imageGenerationContent(item),
rawOutput: imageGenerationRawOutput(item),
};
}

export function createImageGenerationUpdate(
item: ThreadItem & { type: "imageGeneration" }
item: ThreadItem & { type: "imageGeneration" },
options?: { terminalStatus?: boolean },
): UpdateSessionEvent {
return {
sessionUpdate: "tool_call",
toolCallId: item.id,
kind: "other",
title: "Image generation",
status: imageGenerationToolStatus(item.status),
status: options?.terminalStatus
? imageGenerationTerminalStatus(item.status)
: imageGenerationToolStatus(item.status),
content: imageGenerationContent(item),
rawOutput: imageGenerationRawOutput(item),
};
Expand Down Expand Up @@ -624,6 +627,20 @@ function imageGenerationToolStatus(status: string): AcpToolCallStatus {
}
}

function imageGenerationTerminalStatus(status: string): AcpToolCallStatus {
switch (status) {
case "failed":
return "failed";
case "completed":
case "generating":
case "in_progress":
case "inProgress":
case "incomplete":
default:
return "completed";
}
}

function imageGenerationContent(
item: ThreadItem & { type: "imageGeneration" }
): ToolCallContent[] {
Expand Down
5 changes: 2 additions & 3 deletions src/StdUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {Readable, Writable} from "node:stream";
import {Disposable} from "vscode-jsonrpc";
import type {PartialMessageInfo} from "vscode-jsonrpc/lib/common/messageReader";
import {Emitter, Message, MessageReader, MessageWriter} from "vscode-jsonrpc/node";
import type {DataCallback} from "vscode-jsonrpc/node";
import type {DataCallback, PartialMessageInfo} from "vscode-jsonrpc/node";
import * as acp from "@agentclientprotocol/sdk";

//TODO ask to include proper jsonrpc field and remove
Expand Down Expand Up @@ -70,4 +69,4 @@ export function createJsonStream(readable: Readable, writable: Writable){
const input = Writable.toWeb(writable);
const output = Readable.toWeb(readable) as ReadableStream<Uint8Array>;
return acp.ndJsonStream(input, output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
],
"rawOutput": {
"status": "completed",
"status": "generating",
"revisedPrompt": null,
"result": "iVBORw0KGgo="
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
],
"rawOutput": {
"status": "completed",
"status": "generating",
"revisedPrompt": "A tiny blue square",
"result": "iVBORw0KGgo=",
"savedPath": "/tmp/codex/generated-blue-square.png"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/CodexACPAgent/image-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("CodexEventHandler - image events", () => {
item: {
type: "imageGeneration",
id: "image-generation-1",
status: "completed",
status: "generating",
revisedPrompt: "A tiny blue square",
result: "iVBORw0KGgo=",
savedPath: "/tmp/codex/generated-blue-square.png",
Expand All @@ -71,7 +71,7 @@ describe("CodexEventHandler - image events", () => {
item: {
type: "imageGeneration",
id: "image-generation-completed-only",
status: "completed",
status: "generating",
revisedPrompt: null,
result: "iVBORw0KGgo=",
},
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "ES2022",
"moduleResolution": "Bundler",
"target": "ES2022",
"types": ["node"],

"sourceMap": true,
"declaration": true,
Expand Down