fix: 统一AI生成失败提示

This commit is contained in:
hh
2026-07-15 13:12:35 +08:00
parent 38d8c8ad54
commit e81d7170ed
19 changed files with 1220 additions and 88 deletions
+15 -2
View File
@@ -4,6 +4,7 @@ import { Play } from "lucide-react";
import { api, ApiError } from "../api";
import type { Asset, BillingSummary, ExportPoll, ModelConfig, Product, Project, StoryboardShot, Team, TimelineSavePayload, User } from "../types";
import { publicModelDisplayName } from "../model-display";
import { isPublicGenerationError, presentGenerationError } from "../generation-error";
import type { Notice, Page } from "./route-config";
import { money, stageOrder, statusPill } from "./stage-config";
import { CornerMarks, Decorations, Sidebar, ToastLike } from "../components/app-shell";
@@ -39,6 +40,11 @@ function statusLabel(status: string): string {
if (status === "needs_review") return "待确认";
return "待生成";
}
function generationTaskErrorText(error: unknown, fallback: string): string {
if (!isPublicGenerationError(error)) return fallback;
const presentation = presentGenerationError(error);
return `${presentation.title}${presentation.description}`;
}
// 毫秒 → mm:ss(时间轴 / 字幕展示)
function fmtMs(ms: number): string {
const total = Math.max(0, Math.round(ms / 1000));
@@ -830,7 +836,7 @@ export function PipelinePage(props: {
setExtractState("idle"); setExtractMsg(""); // 闸门据 entities_extracted 已落库 → 渲染层自动隐藏
} else if (s.status === "failed") {
setExtractState("idle"); setExtractMsg("");
setExtractErr(s.error || "提取失败,请重试");
setExtractErr(generationTaskErrorText(s.error, s.error_message || "提取失败请重试"));
} else {
setExtractState("idle"); setExtractMsg(""); // 既不在途也无成败(理论不至于):收尾,别把 loading 永久挂住
}
@@ -1439,7 +1445,14 @@ export function PipelinePage(props: {
ok = true;
} else if (evt.type === "error") {
setChatMsgs((list) => list.map((m) => (m.id === progressId ? { ...m, done: true } : m)));
pushMsg("ai", `生成失败:${typeof evt.detail === "string" ? evt.detail : "请稍后重试"}`);
const publicError = isPublicGenerationError(evt.error) ? evt.error : null;
if (publicError) {
const presentation = presentGenerationError(publicError);
pushMsg("ai", `${presentation.title}${presentation.description}`);
} else {
// 兼容尚未接入统一错误对象的安全本地校验帧。
pushMsg("ai", typeof evt.detail === "string" ? evt.detail : "脚本遇到问题,请稍后重试。");
}
}
},
ac.signal