feat(desktop): 运行·观测 重做为运行历史 + 复盘(Tier2,用上 exec Redis 回放)
RunsView 原本只能看「最近一次」实时运行;现做成完整的运行历史复盘: 后端 GET /api/v1/runs?limit=(store.RecentRuns):任务 LEFT JOIN 评测,返回 task_id/status/time + eval level/overall,供历史列表。 前端 RunsView:左侧运行历史列表(状态点 + 相对时间 + 评测分级徽标),点选任一历史运行 → 经 streamExec/streamTokens 从 Redis 回放该次执行轨迹 + 模型输出(对已完成任务流即回放), 并取 /tasks/:id/eval 显示评测(分级/忠实度/纠偏/评语/flags)。「当前运行」固定置顶沿用实时订阅。 api 补 listRuns + taskEval。 这正是之前 exec 轨迹 Redis 回放的消费场景。live(vite + 预览):提一新任务 → 历史列表出现 → 点选 → 完整回放轨迹(2 节点/2518ms/含推理过程)+ 答案全文 + 评测 ok·1.00,无控制台报错。 tsc+vite 构建通过,gateway 全绿。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -483,3 +483,39 @@ export async function statsOverview(): Promise<Overview> {
|
||||
if (!res.ok) throw new Error(`stats failed: ${res.status}`);
|
||||
return res.json() as Promise<Overview>;
|
||||
}
|
||||
|
||||
// ── 运行历史 / 复盘 ──
|
||||
export interface RunSummary {
|
||||
task_id: string;
|
||||
status: string;
|
||||
detail: string;
|
||||
at: string;
|
||||
eval_level: string;
|
||||
eval_overall: number;
|
||||
}
|
||||
|
||||
export async function listRuns(limit = 30): Promise<RunSummary[]> {
|
||||
const res = guard401(await fetch(`${GATEWAY}/api/v1/runs?limit=${limit}`, { headers: bearer() }));
|
||||
if (!res.ok) throw new Error(`list runs failed: ${res.status}`);
|
||||
const d = (await res.json()) as { runs?: RunSummary[] };
|
||||
return d.runs ?? [];
|
||||
}
|
||||
|
||||
export interface EvalResult {
|
||||
overall: number;
|
||||
rule: number;
|
||||
llm: number;
|
||||
faithful: number;
|
||||
level: string;
|
||||
flags: string[];
|
||||
reason: string;
|
||||
sources: number;
|
||||
corrected: boolean;
|
||||
}
|
||||
|
||||
// taskEval: 取一次任务的评测结果(无则返回 null)。
|
||||
export async function taskEval(taskId: string): Promise<EvalResult | null> {
|
||||
const res = await fetch(`${GATEWAY}/api/v1/tasks/${taskId}/eval`, { headers: bearer() });
|
||||
if (!res.ok) return null;
|
||||
return res.json() as Promise<EvalResult>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user