fix(qa): 前端错误文案——按 API 信封 surface 真实错因,去掉通用 toast

新增 friendlyFromApiError(apiError):兼容业务信封 {error:{code,message}}(ARCH §7.1)
与 FastAPI 422 {detail:[...]},422 映射为友好 VALIDATION 文案(不泄露技术细节)。
接入三处此前吞掉错因、永显通用文案的调用点:
- useOutline(QA #2):原 env.error.code 漏读 422 detail,永显「大纲生成失败」。
- ChainPage / ChainAdjudication(QA #11):原 friendlyError(undefined) 永显通用 toast,
  现 surface 真实 code(如 LLM_UNAVAILABLE→去设置 provider / CONFLICT→提示裁决)。
+ messages.test.ts 加 3 例(业务码带动作 / 422→VALIDATION / 未知形兜底)。
门禁绿:vitest / tsc / eslint 干净。
This commit is contained in:
Yaojia Wang
2026-06-24 18:01:15 +02:00
parent f4f01aeca9
commit 9a623688e8
6 changed files with 49 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import { ConflictCard } from "@/components/review/ConflictCard";
import { useToast } from "@/components/Toast";
import { api } from "@/lib/api/client";
import { buildResumeRequest } from "@/lib/chain/chain";
import { friendlyError } from "@/lib/errors/messages";
import { friendlyFromApiError } from "@/lib/errors/messages";
import type { ReviewConflict } from "@/lib/review/sse";
import {
allResolved,
@@ -99,7 +99,7 @@ export function ChainAdjudication({
},
);
if (error) {
toast(friendlyError(undefined).text, "error");
toast(friendlyFromApiError(error).text, "error");
setResuming(false);
return;
}

View File

@@ -6,7 +6,7 @@ import { AppShell } from "@/components/AppShell";
import { useToast } from "@/components/Toast";
import { api } from "@/lib/api/client";
import { chainPhase, chainResultView, type ChainKind } from "@/lib/chain/chain";
import { friendlyError } from "@/lib/errors/messages";
import { friendlyFromApiError } from "@/lib/errors/messages";
import { useJobPoll } from "@/lib/jobs/useJobPoll";
import type { ProjectResponse } from "@/lib/api/types";
import { ChainAdjudication } from "./ChainAdjudication";
@@ -58,7 +58,7 @@ export function ChainPage({ project }: ChainPageProps) {
},
);
if (error || !data) {
toast(friendlyError(undefined).text, "error");
toast(friendlyFromApiError(error).text, "error");
return;
}
setJobId(data.job_id);