Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -278,6 +278,7 @@ export type ProjectOverviewMetrics = {
|
||||
readyStoryboardCount: number;
|
||||
readyPrevizCount: number;
|
||||
readyVideoCount: number;
|
||||
renderSucceededCount: number;
|
||||
staleArtifactCount: number;
|
||||
};
|
||||
|
||||
@@ -479,7 +480,7 @@ export function unlinkCanvasProject(projectId: string, canvasId: string) {
|
||||
return request<{ canvasId: string }>(api.delete(`/projects/${encodeURIComponent(projectId)}/canvases/${encodeURIComponent(canvasId)}`));
|
||||
}
|
||||
|
||||
export function linkProjectAsset(projectId: string, input: { assetId: string; category: AssetCategory; folderId?: string; title?: string }, signal?: AbortSignal) {
|
||||
export function linkProjectAsset(projectId: string, input: { assetId: string; category: AssetCategory; folderId?: string; title?: string; source?: "uploaded" | "canvas" }, signal?: AbortSignal) {
|
||||
return request<{ asset: ProjectAsset }>(api.post(`/projects/${encodeURIComponent(projectId)}/assets`, input, { signal }));
|
||||
}
|
||||
|
||||
|
||||
@@ -532,6 +532,7 @@ export async function waitForGenerationTask(id: string, options?: WaitForGenerat
|
||||
const intervalMs = options?.intervalMs || 2000;
|
||||
let lastTask = options?.initialTask;
|
||||
let lastQueryError: unknown;
|
||||
let consecutiveFailures = 0;
|
||||
try {
|
||||
while (Date.now() - startedAt < (options?.timeoutMs || taskWaitTimeoutMs(lastTask))) {
|
||||
if (options?.signal?.aborted) throw new DOMException("Aborted", "AbortError");
|
||||
@@ -540,9 +541,16 @@ export async function waitForGenerationTask(id: string, options?: WaitForGenerat
|
||||
task = await queryGenerationTask(id, { signal: options?.signal });
|
||||
lastTask = task;
|
||||
lastQueryError = undefined;
|
||||
consecutiveFailures = 0;
|
||||
options?.onTaskUpdate?.(task);
|
||||
} catch (error) {
|
||||
lastQueryError = error;
|
||||
consecutiveFailures += 1;
|
||||
// 连续失败说明查询通道已不可用,继续轮询只会空转到整体超时;
|
||||
// 保留少量容忍度(约 10 秒)以跳过瞬时抖动后直接报错,便于用户尽早处理。
|
||||
if (consecutiveFailures >= 5) {
|
||||
throw error instanceof Error ? error : new Error(String(error));
|
||||
}
|
||||
await delay(intervalMs, options?.signal);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ async function saveRemoteUserDataBatch(uploaded: Map<string, string>) {
|
||||
message: "正在保存画布结构",
|
||||
});
|
||||
}
|
||||
await upsertRemoteCanvasProject(remotePayload);
|
||||
await upsertRemoteCanvasProject(sanitizeCanvasProjectForRemoteSync(remotePayload));
|
||||
acknowledgedProjects.set(source.id, source);
|
||||
if (total > 0) useSyncProgressStore.getState().setProjectProgress(source.id, null);
|
||||
} catch (error) {
|
||||
@@ -513,3 +513,42 @@ function numberValue(value: unknown) {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) && number > 0 ? number : undefined;
|
||||
}
|
||||
|
||||
function sanitizeCanvasProjectForRemoteSync<T>(project: T): T {
|
||||
if (!project || typeof project !== "object") return project;
|
||||
const clone = { ...(project as Record<string, unknown>) };
|
||||
if (Array.isArray(clone.chatSessions)) {
|
||||
clone.chatSessions = clone.chatSessions.map((session) => {
|
||||
if (!session || typeof session !== "object") return session;
|
||||
const s = { ...(session as Record<string, unknown>) };
|
||||
if (Array.isArray(s.messages)) {
|
||||
s.messages = s.messages.map((message) => {
|
||||
if (!message || typeof message !== "object" || !message.detail) return message;
|
||||
const m = { ...(message as Record<string, unknown>) };
|
||||
if (m.detail && typeof m.detail === "object") {
|
||||
const d = { ...(m.detail as Record<string, unknown>) };
|
||||
if (Array.isArray(d.results)) {
|
||||
d.results = d.results.map((r) => {
|
||||
if (!r || typeof r !== "object") return r;
|
||||
const res = { ...(r as Record<string, unknown>) };
|
||||
if (res.result && typeof res.result === "object") {
|
||||
const inner = { ...(res.result as Record<string, unknown>) };
|
||||
if (inner.data && typeof inner.data === "object") {
|
||||
const { snapshot: _s, before: _b, after: _a, ...restData } = inner.data as Record<string, unknown>;
|
||||
inner.data = restData;
|
||||
}
|
||||
res.result = inner;
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
m.detail = d;
|
||||
}
|
||||
return m;
|
||||
});
|
||||
}
|
||||
return s;
|
||||
});
|
||||
}
|
||||
return clone as T;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user