Skip to content

Commit b2e87af

Browse files
committed
fix: add missing timestamp field to ToolCallEndEvent schema and usages
1 parent 82e5233 commit b2e87af

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

src/browser/utils/messages/StreamingMessageAggregator.status.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
4141
toolCallId,
4242
toolName: "status_set",
4343
result: { success: true, emoji: "🔍", message: "Analyzing code" },
44+
timestamp: Date.now(),
4445
});
4546

4647
const status = aggregator.getAgentStatus();
@@ -81,6 +82,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
8182
toolCallId: "tool1",
8283
toolName: "status_set",
8384
result: { success: true, emoji: "🔍", message: "Analyzing" },
85+
timestamp: Date.now(),
8486
});
8587

8688
expect(aggregator.getAgentStatus()?.emoji).toBe("🔍");
@@ -104,6 +106,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
104106
toolCallId: "tool2",
105107
toolName: "status_set",
106108
result: { success: true, emoji: "📝", message: "Writing" },
109+
timestamp: Date.now(),
107110
});
108111

109112
expect(aggregator.getAgentStatus()?.emoji).toBe("📝");
@@ -142,6 +145,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
142145
toolCallId: "tool1",
143146
toolName: "status_set",
144147
result: { success: true, emoji: "🔍", message: "Working" },
148+
timestamp: Date.now(),
145149
});
146150

147151
expect(aggregator.getAgentStatus()).toBeDefined();
@@ -193,6 +197,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
193197
toolCallId: "tool1",
194198
toolName: "status_set",
195199
result: { success: false, error: "Something went wrong" },
200+
timestamp: Date.now(),
196201
});
197202

198203
// Status should remain undefined
@@ -229,6 +234,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
229234
toolCallId: "tool1",
230235
toolName: "status_set",
231236
result: { success: true, emoji: "🔍", message: "First task" },
237+
timestamp: Date.now(),
232238
});
233239

234240
expect(aggregator.getAgentStatus()?.message).toBe("First task");
@@ -292,6 +298,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
292298
toolCallId: "tool1",
293299
toolName: "status_set",
294300
result: { success: false, error: "emoji must be a single emoji character" },
301+
timestamp: Date.now(),
295302
});
296303

297304
// End the stream to finalize message
@@ -350,6 +357,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
350357
toolCallId: "tool1",
351358
toolName: "status_set",
352359
result: { success: true, emoji: "🔍", message: "Analyzing code" },
360+
timestamp: Date.now(),
353361
});
354362

355363
// End the stream to finalize message
@@ -533,6 +541,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
533541
toolCallId,
534542
toolName: "status_set",
535543
result: { success: true, emoji: "✅", message: truncatedMessage },
544+
timestamp: Date.now(),
536545
});
537546

538547
// Should use truncated message from output, not the original input
@@ -576,6 +585,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
576585
toolCallId,
577586
toolName: "status_set",
578587
result: { success: true, emoji: "🔗", message: "PR submitted", url: testUrl },
588+
timestamp: Date.now(),
579589
});
580590

581591
const status = aggregator.getAgentStatus();
@@ -618,6 +628,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
618628
toolCallId: "tool1",
619629
toolName: "status_set",
620630
result: { success: true, emoji: "🔗", message: "PR submitted", url: testUrl },
631+
timestamp: Date.now(),
621632
});
622633

623634
expect(aggregator.getAgentStatus()?.url).toBe(testUrl);
@@ -641,6 +652,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
641652
toolCallId: "tool2",
642653
toolName: "status_set",
643654
result: { success: true, emoji: "✅", message: "Done" },
655+
timestamp: Date.now(),
644656
});
645657

646658
const statusAfterUpdate = aggregator.getAgentStatus();
@@ -668,6 +680,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
668680
toolCallId: "tool3",
669681
toolName: "status_set",
670682
result: { success: true, emoji: "🔄", message: "New PR", url: newUrl },
683+
timestamp: Date.now(),
671684
});
672685

673686
const finalStatus = aggregator.getAgentStatus();
@@ -709,6 +722,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
709722
toolCallId: "tool1",
710723
toolName: "status_set",
711724
result: { success: true, emoji: "🔗", message: "PR submitted", url: testUrl },
725+
timestamp: Date.now(),
712726
});
713727

714728
expect(aggregator.getAgentStatus()?.url).toBe(testUrl);
@@ -754,6 +768,7 @@ describe("StreamingMessageAggregator - Agent Status", () => {
754768
toolCallId: "tool2",
755769
toolName: "status_set",
756770
result: { success: true, emoji: "✅", message: "Tests passed" },
771+
timestamp: Date.now(),
757772
});
758773

759774
const finalStatus = aggregator.getAgentStatus();

src/browser/utils/messages/StreamingMessageAggregator.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ describe("StreamingMessageAggregator", () => {
175175
toolCallId: "tool1",
176176
toolName: "todo_write",
177177
result: { success: true },
178+
timestamp: Date.now(),
178179
});
179180

180181
// Verify todos are set
@@ -230,6 +231,7 @@ describe("StreamingMessageAggregator", () => {
230231
toolCallId: "tool1",
231232
toolName: "todo_write",
232233
result: { success: true },
234+
timestamp: Date.now(),
233235
});
234236

235237
expect(aggregator.getCurrentTodos()).toHaveLength(1);
@@ -363,6 +365,7 @@ describe("StreamingMessageAggregator", () => {
363365
toolCallId: "tool1",
364366
toolName: "todo_write",
365367
result: { success: true },
368+
timestamp: Date.now(),
366369
});
367370

368371
// TODOs should be set

src/common/orpc/schemas/stream.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export const ToolCallEndEventSchema = z.object({
151151
toolCallId: z.string(),
152152
toolName: z.string(),
153153
result: z.unknown(),
154+
timestamp: z.number().meta({ description: "When tool call completed (Date.now())" }),
154155
});
155156

156157
export const ReasoningStartEventSchema = z.object({

src/node/services/mock/mockScenarioPlayer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export class MockScenarioPlayer {
315315
toolCallId: event.toolCallId,
316316
toolName: event.toolName,
317317
result: event.result,
318+
timestamp: Date.now(),
318319
};
319320
this.deps.aiService.emit("tool-call-end", payload);
320321
break;

src/node/services/streamManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ export class StreamManager extends EventEmitter {
408408
toolCallId: part.toolCallId,
409409
toolName: part.toolName,
410410
result: part.output,
411+
timestamp: Date.now(),
411412
});
412413
}
413414
}
@@ -655,6 +656,7 @@ export class StreamManager extends EventEmitter {
655656
toolCallId,
656657
toolName,
657658
result: output,
659+
timestamp: Date.now(),
658660
} as ToolCallEndEvent);
659661

660662
// Schedule partial write

0 commit comments

Comments
 (0)