Compare commits

...

2 Commits

Author SHA1 Message Date
J
5e71df77c7 test(transcript): cover coalesce created_at behavior
Lock in that coalescing streaming fragments carries the latest
created_at, and falls back to the previous timestamp when the merged
fragment has none.

Co-authored-by: multica-agent <github@multica.ai>
2026-06-09 19:54:50 +08:00
J
6aa946a7f0 refactor(transcript): reuse taskMessageToPayload in WS broadcast
The ReportTaskMessages WebSocket broadcast hand-built the payload and
duplicated the created_at formatting that taskMessageToPayload already
does. Reuse the helper with the just-inserted row, which carries the
same redacted values and the DB-assigned timestamp.

Co-authored-by: multica-agent <github@multica.ai>
2026-06-09 19:54:49 +08:00
2 changed files with 27 additions and 15 deletions

View File

@@ -76,4 +76,29 @@ describe("task transcript timeline", () => {
expect(items[0]?.content).not.toContain("abc123xyz");
expect(items[0]?.content).not.toContain("def456");
});
it("keeps the latest created_at when coalescing streaming fragments", () => {
const items = coalesceTimelineItems([
{ seq: 1, type: "text", content: "hello ", created_at: "2026-06-09T09:00:00.000Z" },
{ seq: 2, type: "text", content: "world", created_at: "2026-06-09T09:00:05.000Z" },
]);
expect(items).toEqual([
expect.objectContaining({
seq: 1,
type: "text",
content: "hello world",
created_at: "2026-06-09T09:00:05.000Z",
}),
]);
});
it("falls back to the previous created_at when the merged fragment has none", () => {
const items = coalesceTimelineItems([
{ seq: 1, type: "text", content: "hello ", created_at: "2026-06-09T09:00:00.000Z" },
{ seq: 2, type: "text", content: "world" },
]);
expect(items[0]?.created_at).toBe("2026-06-09T09:00:00.000Z");
});
});

View File

@@ -2096,21 +2096,8 @@ func (h *Handler) ReportTaskMessages(w http.ResponseWriter, r *http.Request) {
}
if workspaceID != "" {
createdAt := ""
if created.CreatedAt.Valid {
createdAt = created.CreatedAt.Time.UTC().Format(time.RFC3339Nano)
}
h.publishTask(protocol.EventTaskMessage, workspaceID, "system", "", taskID, protocol.TaskMessagePayload{
TaskID: taskID,
IssueID: uuidToString(task.IssueID),
Seq: msg.Seq,
Type: msg.Type,
Tool: msg.Tool,
Content: msg.Content,
Input: msg.Input,
Output: msg.Output,
CreatedAt: createdAt,
})
h.publishTask(protocol.EventTaskMessage, workspaceID, "system", "", taskID,
taskMessageToPayload(created, taskID, uuidToString(task.IssueID)))
}
}