fix(organize): 展示智能体处理状态并刷新恢复结果
This commit is contained in:
1 parent
86351f20f3
commit
b306d27d08
9 files changed
+172
-12
No files matched your search
@@ -4,6 +4,7 @@ import { createElement, type ReactNode } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { recordNeedsRefresh } from "~/api/records.ts";
|
||||
import { attentionLine, primaryAction, RecordAttentionActions } from "./record-attention.tsx";
|
||||
|
||||
// 整理记录「需要处理」的行内处理(2026-10-06 去掉待处理中心):原因一句话 + 推荐动作,一键执行。
|
||||
@@ -71,6 +72,28 @@ describe("整理记录行内处理", () => {
|
||||
expect(out).not.toContain("指定作品");
|
||||
});
|
||||
|
||||
it("未创建会话时仍显示智能体处理中,失败记录持续刷新直到交还人工", () => {
|
||||
const r = rec({ topic: "identity", decision: decision({ status: "investigating" }), agentIdentify: true });
|
||||
expect(html(r)).toContain("智能体处理中");
|
||||
expect(html(r)).not.toContain("指定作品");
|
||||
expect(recordNeedsRefresh(r)).toBe(true);
|
||||
const awaiting = rec({
|
||||
topic: "identity",
|
||||
decision: decision({
|
||||
status: "awaiting_user",
|
||||
agentRunId: D,
|
||||
evidence: { autoRecover: { suggestion: "请确认这两个同名作品" } },
|
||||
}),
|
||||
agentIdentify: true,
|
||||
});
|
||||
expect(attentionLine(awaiting)).toBe("需要你确认:请确认这两个同名作品");
|
||||
expect(html(awaiting)).toContain("查看排查过程");
|
||||
expect(html(awaiting)).toContain("指定作品");
|
||||
expect(recordNeedsRefresh(awaiting)).toBe(false);
|
||||
expect(recordNeedsRefresh(rec(null, { status: "partial" }))).toBe(false);
|
||||
expect(recordNeedsRefresh(rec(null, { status: "running" }))).toBe(true);
|
||||
});
|
||||
|
||||
it("目标已存在:按事项选项给替换 / 保留两者 / 跳过", () => {
|
||||
const r = rec({
|
||||
topic: "conflict",
|
||||
|
||||
@@ -27,7 +27,13 @@ type Rec = Pick<PublicOrganizationRecord, "id" | "action" | "status" | "attentio
|
||||
export function attentionLine(r: Rec): string | null {
|
||||
const a = r.attention;
|
||||
if (!a) return null;
|
||||
if (a.decision?.status === "investigating") return "智能体正在识别作品,识别出来后自动重新整理";
|
||||
if (a.decision?.status === "investigating")
|
||||
return a.topic === "identity" ? "智能体正在识别作品,识别出来后自动重新整理" : "智能体正在排查,暂时不用处理";
|
||||
if (a.decision?.status === "awaiting_user") {
|
||||
const recovery = a.decision.evidence.autoRecover as { suggestion?: unknown } | undefined;
|
||||
const suggestion = typeof recovery?.suggestion === "string" ? recovery.suggestion : a.decision.summary;
|
||||
return suggestion ? `需要你确认:${humanizeReason(suggestion)}` : "智能体暂时无法确定,需要你确认";
|
||||
}
|
||||
if (a.topic === "identity") return "没识别出作品。指定作品,或让智能体识别";
|
||||
return a.decision?.summary ? humanizeReason(a.decision.summary) : null;
|
||||
}
|
||||
@@ -66,13 +72,26 @@ export function RecordAttentionActions({
|
||||
<Button asChild variant="ghost" size="sm">
|
||||
<Link to={consolePath("agent", d.agentRunId)}>
|
||||
<LoaderCircle className="animate-spin" />
|
||||
智能体识别中
|
||||
{a.topic === "identity" ? "智能体识别中" : "智能体处理中"}
|
||||
<ChevronRight />
|
||||
</Link>
|
||||
</Button>
|
||||
) : investigating ? (
|
||||
<span role="status" className="inline-flex items-center gap-1.5 text-caption text-muted-foreground">
|
||||
<LoaderCircle className="h-3.5 w-3.5 animate-spin" />
|
||||
智能体处理中
|
||||
</span>
|
||||
) : null}
|
||||
{!investigating && d?.status === "awaiting_user" && d.agentRunId ? (
|
||||
<Button asChild variant="ghost" size="sm">
|
||||
<Link to={consolePath("agent", d.agentRunId)}>
|
||||
查看排查过程
|
||||
<ChevronRight />
|
||||
</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
{primary === "assign" && d && !investigating ? <AssignWorkButton d={d} /> : null}
|
||||
{primary === "options" && d
|
||||
{primary === "options" && d && !investigating
|
||||
? plainOptions(d).map((o, i) => (
|
||||
<OptionButton key={o.key} d={d} option={o} variant={i === 0 ? "default" : "outline"} />
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user