fix(onboarding): 模板分发报告识别 appended/updated 五态,不再误显 ✗

noteapp 实测追加管理块成功但 UI 渲染成红叉——前端映射只认旧三态,
新增 action 落入 failed 默认分支。改映射表覆盖五态,
updated/appended 展示后端 detail(含版本信息)。

Rules-Applied: R12
This commit is contained in:
lanrtop 2026-07-03 13:37:22 +09:00
parent 965d095820
commit c4a6600134

View File

@ -53,6 +53,19 @@ const STATUS_CONFIG: Record<string, { color: string; bg: string; label: string }
abandoned: { color: "#52525B", bg: "#FAFAFA", label: "已退役" }, abandoned: { color: "#52525B", bg: "#FAFAFA", label: "已退役" },
}; };
// 接入包模板分发五态(对应 onboarding.rs TemplateResult.action
// label 为 null 时展示后端 detailupdated/appended/failed 的 detail 含版本信息)
const TEMPLATE_ACTION_STYLE: Record<
string,
{ icon: string; color: string; label: string | null }
> = {
written: { icon: "✓", color: "text-green-600", label: "已写入" },
updated: { icon: "↑", color: "text-blue-600", label: null },
appended: { icon: "+", color: "text-blue-600", label: null },
skipped: { icon: "○", color: "text-gray-400", label: "已存在" },
failed: { icon: "✗", color: "text-red-600", label: null },
};
const TASK_PREFIX: Record<string, string> = { const TASK_PREFIX: Record<string, string> = {
done: "✅", done: "✅",
in_progress: "🔵", in_progress: "🔵",
@ -1289,25 +1302,17 @@ function GovernancePanel({
{packTemplates && ( {packTemplates && (
<div className="space-y-0.5 pt-0.5"> <div className="space-y-0.5 pt-0.5">
<p className="text-[10px] text-gray-500 font-semibold"></p> <p className="text-[10px] text-gray-500 font-semibold"></p>
{packTemplates.map((t) => ( {packTemplates.map((t) => {
const style =
TEMPLATE_ACTION_STYLE[t.action] ?? TEMPLATE_ACTION_STYLE.failed;
return (
<p key={t.name} className="text-[10px] font-mono flex items-center gap-1"> <p key={t.name} className="text-[10px] font-mono flex items-center gap-1">
<span <span className={style.color}>{style.icon}</span>
className={
t.action === "written"
? "text-green-600"
: t.action === "skipped"
? "text-gray-400"
: "text-red-600"
}
>
{t.action === "written" ? "✓" : t.action === "skipped" ? "○" : "✗"}
</span>
<span className="text-gray-600 truncate flex-1">{t.name}</span> <span className="text-gray-600 truncate flex-1">{t.name}</span>
<span className="text-gray-400"> <span className="text-gray-400">{style.label ?? t.detail}</span>
{t.action === "written" ? "已写入" : t.action === "skipped" ? "已存在" : t.detail}
</span>
</p> </p>
))} );
})}
</div> </div>
)} )}
{buffStatus?.status === "active" ? ( {buffStatus?.status === "active" ? (