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
12 changes: 2 additions & 10 deletions src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class CodexEventHandler {
private readonly connection: acp.AgentSideConnection;
private readonly sessionState: SessionState;
private failure: RequestError | null = null;
private readonly terminalOutputs: Map<string, string> = new Map();

constructor(connection: acp.AgentSideConnection, sessionState: SessionState) {
this.connection = connection;
Expand Down Expand Up @@ -73,7 +72,6 @@ export class CodexEventHandler {
return null;
case "turn/completed":
this.sessionState.currentTurnId = null;
this.terminalOutputs.clear();
return null;
case "thread/tokenUsage/updated":
this.handleTokenUsageUpdated(notification.params);
Expand Down Expand Up @@ -197,25 +195,19 @@ export class CodexEventHandler {
}

private createCommandOutputDeltaEvent(event: CommandExecutionOutputDeltaNotification): UpdateSessionEvent {
const accumulated = (this.terminalOutputs.get(event.itemId) ?? "") + event.delta;
this.terminalOutputs.set(event.itemId, accumulated);

return {
sessionUpdate: "tool_call_update",
toolCallId: event.itemId,
_meta: {
terminal_output: {
data: accumulated,
terminal_output_delta: {
data: event.delta,
terminal_id: event.itemId
}
}
}
}

private completeCommandExecutionEvent(item: ThreadItem & { "type": "commandExecution" }): UpdateSessionEvent {
// Clean up accumulator
this.terminalOutputs.delete(item.id);

return {
sessionUpdate: "tool_call_update",
toolCallId: item.id,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/CodexACPAgent/data/terminal-full-flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"sessionUpdate": "tool_call_update",
"toolCallId": "command-flow",
"_meta": {
"terminal_output": {
"terminal_output_delta": {
"data": "hello\n",
"terminal_id": "command-flow"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"sessionUpdate": "tool_call_update",
"toolCallId": "command-123",
"_meta": {
"terminal_output": {
"terminal_output_delta": {
"data": "file1.txt\nfile2.txt\n",
"terminal_id": "command-123"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"sessionUpdate": "tool_call_update",
"toolCallId": "command-accumulate",
"_meta": {
"terminal_output": {
"terminal_output_delta": {
"data": "line1\n",
"terminal_id": "command-accumulate"
}
Expand All @@ -25,8 +25,8 @@
"sessionUpdate": "tool_call_update",
"toolCallId": "command-accumulate",
"_meta": {
"terminal_output": {
"data": "line1\nline2\n",
"terminal_output_delta": {
"data": "line2\n",
"terminal_id": "command-accumulate"
}
}
Expand All @@ -43,8 +43,8 @@
"sessionUpdate": "tool_call_update",
"toolCallId": "command-accumulate",
"_meta": {
"terminal_output": {
"data": "line1\nline2\nline3\n",
"terminal_output_delta": {
"data": "line3\n",
"terminal_id": "command-accumulate"
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/CodexACPAgent/terminal-output-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe('CodexEventHandler - terminal output events', () => {
);
});

it('should accumulate terminal output across multiple deltas', async () => {
it('should stream multiple terminal output deltas without accumulation', async () => {
const delta1: ServerNotification = {
method: 'item/commandExecution/outputDelta',
params: {
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('CodexEventHandler - terminal output events', () => {
await setupAndSendNotifications([delta1, delta2, delta3]);

await expect(mockFixture.getAcpConnectionDump([])).toMatchFileSnapshot(
'data/terminal-output-accumulated.json'
'data/terminal-output-multiple-deltas.json'
);
});
});