import { useConsole } from "../context";
import { Card } from "../components/ui";
import { shortId, fmt } from "../api/client";
import { STATUS_EXPLAIN } from "../api/types";
import { firstChar, durationOf, tokenOf, fmtCostUsd } from "../api/taskMeta";
import DetailActions from "./detail/DetailActions";
import ReviewPanel from "./detail/ReviewPanel";
import { CoordPanel, AgentsPanel, ApprovalPanel, PeerPanel, ThreadPanel } from "./detail/DetailLists";
// Right detail column for the task view, card-style layout.
// Everything structured lives here — never inside a chat bubble.
// Layout only: data, actions and sub-sections are unchanged,
// just grouped into cards instead of one
-separated block:
// 概览(状态 + 耗时/token/成本三张指标卡)
// 基本信息(键值网格)
// prompt(单独一张卡,长 prompt 不再挤在信息行末尾)
// 操作与结果
// 协调子任务 / 子代理链路 / 评审队列 / 运行时审批队列 /
// 给其他任务发消息 / 线程(各一张卡)
export default function TaskDetailPanel() {
const ctx = useConsole();
const t = ctx.currentTask;
if (!t) return 点任务行查看详情
;
const [dur, durTitle] = durationOf(t);
const [tok, tokTitle] = tokenOf(t);
const fc = firstChar(t);
const cost = ctx.costSummary;
const modeText = t.plan ? "计划模式(只读)"
: t.goal_mode ? (t.no_time_limit ? "goal 模式无敌版(不限时)" : "goal 模式(不限轮次,模型宣告完成)")
: t.verify_command ? "goal 模式(旧语义,验收命令)" : null;
return (
{fc}
状态 {t.status}({STATUS_EXPLAIN[t.status] || "未知状态"})
更新 {fmt(t.updated_at)}
成本
{cost === undefined ? "加载中…" : cost === null ? "—" : fmtCostUsd(cost.usd_micros)}
{cost === undefined ?
成本加载中…
: cost === null ?
成本明细加载失败(“查成本”按钮仍可手动拉取原始 JSON)
:
token {(cost.total_tokens ?? 0).toLocaleString()}(实际 {(cost.actual_tokens ?? 0).toLocaleString()} / 估算 {(cost.estimated_tokens ?? 0).toLocaleString()},缓存 {(cost.cached_input_tokens ?? 0).toLocaleString()},无价 {(cost.unpriced_actual_tokens ?? 0).toLocaleString()})| 轮数 {cost.turns ?? 0} | fallback {cost.fallback_count ?? 0}
}
- 任务
- {t.id}
- turn
- {shortId(t.turn_id)}
- root turn
- {shortId(t.root_turn_id)}
- executor
- {t.executor || ""}
- 主机
- {t.worktree_host || ""}
- 模型
- {t.model || "默认"}
- 强度
- {t.effort || "默认"}
{(t.child_model || t.child_effort) ? - 子任务默认
- {(t.child_model || "跟随本任务") + " / " + (t.child_effort || "跟随本任务")}
: null}
- 权限
- {t.approval || "默认"}
- 项目
- {shortId(t.project_id)}
{modeText ? - 模式
- {modeText}
: null}
{t.forked_from ? - 分支自
- {shortId(t.forked_from)}
: null}
{t.coordinator_parts ? - 协调员
- {t.coordinator_parts.length} 个子任务({t.coordinator_parts.map((p) => p.name).join("、")})
: null}
{t.parent_task_id ? - 协调子任务
- 父任务 {shortId(t.parent_task_id)}{t.coordinator_part ? "(" + t.coordinator_part + ")" : ""}
: null}
{(t.attachments && t.attachments.length) ? - 附件
- {t.attachments.join("、")}
: null}
{t.pr_url ? : null}
{t.prompt || "(无 prompt)"}
{ctx.detailBody || "(暂无 result/error 输出)"}
{ctx.costBox ? {ctx.costBox} : null}
);
}