Preserve elapsed time in replay activity parts
This commit is contained in:
@@ -442,7 +442,7 @@ export function toReplayRepository(
|
||||
id,
|
||||
role: message.role,
|
||||
createdAt: new Date(),
|
||||
content: toThreadMessageContent(parts),
|
||||
content: toThreadMessageContent(parts, elapsedMs),
|
||||
...(message.role === "assistant"
|
||||
? {
|
||||
status: { type: "complete", reason: "stop" },
|
||||
@@ -797,9 +797,11 @@ function attachStageNote(input: unknown, stageNote?: string) {
|
||||
return { value: input, __claw_stage_note: note };
|
||||
}
|
||||
|
||||
function toThreadMessageContent(parts: UIMessage["parts"]) {
|
||||
function toThreadMessageContent(parts: UIMessage["parts"], elapsedMs?: number) {
|
||||
return parts.map((part) => {
|
||||
if (part.type === "text" || part.type === "reasoning") return part;
|
||||
const elapsedPayload = elapsedMs === undefined ? {} : { elapsedMs };
|
||||
if (part.type === "text") return part;
|
||||
if (part.type === "reasoning") return { ...part, ...elapsedPayload };
|
||||
if (part.type === "dynamic-tool") {
|
||||
return {
|
||||
type: "tool-call",
|
||||
@@ -807,6 +809,7 @@ function toThreadMessageContent(parts: UIMessage["parts"]) {
|
||||
toolCallId: part.toolCallId,
|
||||
args: part.input ?? {},
|
||||
argsText: JSON.stringify(part.input ?? {}),
|
||||
...elapsedPayload,
|
||||
...(part.state === "output-available" ? { result: part.output } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user