feat(web): 会话实际结果行只列系统核实的事实,不一致时标记(FIX-9)
去掉「说明」「汇总」与「未经核查」;没有动作时一行小字,有动作时列提交的下载与完成的整理并可点到记录, 汇报里的数字与系统记录不一致时行尾加「与汇报不一致」。统计行已有费用时不重复。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c67fd96639
commit
41a39f3cc8
3 files changed
+193
-62
No files matched your search
@@ -4,9 +4,18 @@ import { createElement, type ReactNode } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { AgentRunView } from "~/api/agent.ts";
|
||||
import type { AgentRunView, GoalReport } from "~/api/agent.ts";
|
||||
import { qk } from "~/lib/query-keys.ts";
|
||||
import { AgentConversation, contextLabel, DeniedLines, ResultLine, StepSummary } from "./agent-conversation.tsx";
|
||||
import {
|
||||
AgentConversation,
|
||||
claimedCounts,
|
||||
contextLabel,
|
||||
DeniedLines,
|
||||
ResultLine,
|
||||
reportMismatch,
|
||||
resultFacts,
|
||||
StepSummary,
|
||||
} from "./agent-conversation.tsx";
|
||||
import { OptionsCard, optionPoint, orderOptions } from "./agent-interaction.tsx";
|
||||
import { goalFromInput, RunStatsLine } from "./agent-run-panel.tsx";
|
||||
import { arrangeHistory } from "./agent-session-list.tsx";
|
||||
@@ -442,3 +451,91 @@ describe("会话统计与本轮状态(AG-4)", () => {
|
||||
expect(t).toContain("工具调用 1 次 · token 45.2K · 剩 154.8K(77%) · 费用 $0.03");
|
||||
});
|
||||
});
|
||||
|
||||
describe("实际结果行(FIX-9):只列系统核实的事实", () => {
|
||||
const ID = (n: number) => `00000000-0000-4000-8000-00000000010${n}`;
|
||||
const report = (o: Partial<GoalReport>): GoalReport => ({
|
||||
state: "no_actions",
|
||||
summary: "本次没有提交下载或整理,结论见模型汇报。",
|
||||
submitted: 0,
|
||||
imported: 0,
|
||||
inProgress: 0,
|
||||
failed: 0,
|
||||
plans: [],
|
||||
downloads: [],
|
||||
organization: [],
|
||||
modelText: null,
|
||||
generatedAt: AT,
|
||||
...o,
|
||||
});
|
||||
const done = report({
|
||||
state: "completed",
|
||||
summary: "已提交下载 2 个",
|
||||
submitted: 2,
|
||||
imported: 1,
|
||||
inProgress: 1,
|
||||
downloads: [
|
||||
{ downloadTaskId: ID(1), planId: null, status: "completed", name: "A" },
|
||||
{ downloadTaskId: ID(2), planId: null, status: "downloading", name: "B" },
|
||||
],
|
||||
organization: [
|
||||
{ recordId: ID(3), status: "succeeded", downloadTaskId: ID(1), mediaEntityId: null, targetPath: "/m/A" },
|
||||
],
|
||||
});
|
||||
const withText = (t: string) =>
|
||||
liveOf([
|
||||
ev(0, { type: "run_started", goal: "g", resumed: false }),
|
||||
ev(1, { type: "text_delta", delta: t }),
|
||||
ev(2, { type: "run_completed", finalText: "", usage: { costUsd: 0.01 } }),
|
||||
]);
|
||||
|
||||
it("没有动作:一行小字 + 时长 + 费用,不再有「说明」「汇总」「未经核查」", () => {
|
||||
const html = render(
|
||||
createElement(ResultLine, {
|
||||
run: { ...RUN, usage: { costUsd: 0.01 } },
|
||||
report: report({}),
|
||||
live: withText("都正常。"),
|
||||
}),
|
||||
);
|
||||
const t = text(html);
|
||||
expect(t).toContain("没有提交下载或整理 · 41 秒 · 约 $0.01");
|
||||
expect(t).not.toContain("说明");
|
||||
expect(t).not.toContain("汇总");
|
||||
expect(t).not.toContain("未经核查");
|
||||
expect(t).not.toContain("实际结果:");
|
||||
expect(t).not.toContain("结论见模型汇报");
|
||||
});
|
||||
it("统计行已显示费用时不重复", () => {
|
||||
const t = text(
|
||||
render(
|
||||
createElement(ResultLine, {
|
||||
run: { ...RUN, usage: { costUsd: 0.01 } },
|
||||
report: report({}),
|
||||
live: withText("x"),
|
||||
showCost: false,
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(t).toContain("没有提交下载或整理 · 41 秒");
|
||||
expect(t).not.toContain("$0.01");
|
||||
});
|
||||
it("有动作:列事实,单条记录链到记录本身,多条链到列表", () => {
|
||||
const html = render(
|
||||
createElement(ResultLine, { run: RUN, report: done, live: withText("提交了 2 个下载,整理了 1 个。") }),
|
||||
);
|
||||
expect(text(html).replace(/\s*、\s*/g, "、")).toContain("提交了 2 个下载、完成 1 次整理、1 个还在进行 · 41 秒");
|
||||
expect(html).toContain(`href="/console/organize/${ID(3)}"`);
|
||||
expect(html).toContain('href="/console/downloads"');
|
||||
expect(html).not.toContain("与汇报不一致");
|
||||
});
|
||||
it("数字与汇报不一致:行尾加标记,悬停和技术信息里说明", () => {
|
||||
const html = render(createElement(ResultLine, { run: RUN, report: done, live: withText("已提交了 3 个下载。") }));
|
||||
expect(html).toContain('data-slot="report-mismatch"');
|
||||
expect(html).toContain("汇报说提交了 3 个下载,系统记录是 2 个");
|
||||
});
|
||||
it("汇报没写数字时不判不一致", () => {
|
||||
expect(reportMismatch(done, "下载都安排好了。")).toEqual([]);
|
||||
expect(claimedCounts("整理了 4 部电影")).toEqual({ organized: 4 });
|
||||
expect(resultFacts(null)).toEqual([{ text: "汇总中…" }]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user