返回 DeepSeek-Reasonix
SubagentOutcomeCard.tsx
根目录 / desktop / frontend / src / components / SubagentOutcomeCard.tsx
1 import "./SubagentDetails.css";
2 import { ErrorMessage } from "./ErrorMessage";
3
4 import { useT, type Translator } from "../lib/i18n";
5 import { parseSubagentOutcomeText, type SubagentOutcome } from "../lib/subagentOutcome";
6
7 type SubagentOutcomeCardProps = {
8 text?: string;
9 outcome?: SubagentOutcome;
10 };
11
12 function outcomeLabel(t: Translator, status: string): string {
13 switch (status) {
14 case "completed": return t("subagent.phase.completed");
15 case "partial": return t("subagent.phase.partial");
16 case "failed": return t("subagent.phase.failed");
17 case "cancelled": return t("subagent.phase.cancelled");
18 default: return status;
19 }
20 }
21
22 export function SubagentOutcomeCard({
23 text,
24 outcome,
25 }: SubagentOutcomeCardProps) {
26 const t = useT();
27 const [ref, status, errorCode, retryable] = outcome ?? parseSubagentOutcomeText(text) ?? [];
28 if (!ref && !status) return null;
29 return (
30 <div className="tool__subagent-outcome">
31 <div className="tool__subagent-outcome-status">
32 {t("caps.subagent")} {outcomeLabel(t, status ?? "unknown")}
33 {retryable ? ` · ${t("subagent.outcome.retryable")}` : ""}
34 </div>
35 {ref && <code>{ref}</code>}
36 {errorCode && <div className="tool__note"><ErrorMessage error={errorCode} /></div>}
37 </div>
38 );
39 }
40
40 lines Plain Text