fix: preserve interaction replies across chat recovery
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
type TodoUpdatePayload,
|
||||
} from "./chatStream.js";
|
||||
|
||||
export type RunStatus = "running" | "completed" | "error" | "aborted";
|
||||
export type RunStatus = "running" | "waiting_input" | "completed" | "error" | "aborted";
|
||||
|
||||
export type StreamSubscriber = {
|
||||
write: (event: string, data: Record<string, unknown>) => void;
|
||||
@@ -82,8 +82,13 @@ export const upsertBackendProgress = (
|
||||
const next = Array.isArray(progress) ? [...progress] : [];
|
||||
const id = typeof payload.id === "string" ? payload.id : `progress-${Date.now()}`;
|
||||
const index = next.findIndex((item) => isObjectRecord(item) && item.id === id);
|
||||
const existing = index >= 0 && isObjectRecord(next[index]) ? next[index] : undefined;
|
||||
const tool = isObjectRecord(payload.tool) && typeof payload.tool.name === "string"
|
||||
? { name: payload.tool.name, callId: typeof payload.tool.call_id === "string" ? payload.tool.call_id : undefined, input: isObjectRecord(payload.tool.input) ? payload.tool.input : undefined }
|
||||
: existing?.tool;
|
||||
const nextItem = {
|
||||
id,
|
||||
tool,
|
||||
phase: typeof payload.phase === "string" ? payload.phase : "progress",
|
||||
status:
|
||||
payload.status === "completed" || payload.status === "error"
|
||||
|
||||
Reference in New Issue
Block a user