Persist active run state for replay
This commit is contained in:
@@ -69,6 +69,10 @@ export type ClawRunStatus = {
|
||||
| "interrupted";
|
||||
current_stage?: string;
|
||||
started_at?: number;
|
||||
updated_at?: number;
|
||||
finished_at?: number;
|
||||
elapsed_ms?: number;
|
||||
cancellable?: boolean;
|
||||
pending_prompt?: string;
|
||||
events?: ClawRunEvent[];
|
||||
};
|
||||
@@ -590,8 +594,9 @@ function buildActiveRunParts(runStatus: ClawActiveRunStatus) {
|
||||
: runStatus.current_stage || "后端正在执行这个会话。";
|
||||
const reasoningText = eventLines.length ? eventLines.join("\n") : fallback;
|
||||
const runStartedAtMs = resolveRunStartedAtMs(runStatus);
|
||||
const elapsedMs = normalizeElapsedMs(runStatus.elapsed_ms);
|
||||
return [
|
||||
{ type: "reasoning", text: reasoningText, runStartedAtMs },
|
||||
{ type: "reasoning", text: reasoningText, runStartedAtMs, elapsedMs },
|
||||
...buildRunToolParts(runStatus.events ?? []),
|
||||
];
|
||||
}
|
||||
@@ -795,6 +800,12 @@ function resolveRunStartedAtMs(runStatus: ClawRunStatus) {
|
||||
const direct = normalizeRunTimestampMs(runStatus.started_at);
|
||||
if (direct !== undefined) return direct;
|
||||
|
||||
const updatedAt = normalizeRunTimestampMs(runStatus.updated_at);
|
||||
const elapsedMs = normalizeElapsedMs(runStatus.elapsed_ms);
|
||||
if (updatedAt !== undefined && elapsedMs !== undefined) {
|
||||
return Math.max(0, updatedAt - elapsedMs);
|
||||
}
|
||||
|
||||
for (const event of runStatus.events ?? []) {
|
||||
if (event.type !== "run_started") continue;
|
||||
const eventStarted = normalizeRunTimestampMs(event.started_at);
|
||||
|
||||
Reference in New Issue
Block a user