feat(schedules): per-check cost and model summary on GET /schedules (INT-3)
agent_check items carry agentRuns (last 100 sessions: last/avg cost, 7-day count and cost, models, recent 3); plan page and home plan band use it instead of fetching agent runs. Migration 0052 indexes agent_run(created_by, created_at). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
82df5662f0
commit
e681fcedf6
9 files changed
+200
-78
No files matched your search
@@ -22,7 +22,6 @@ import type { ReactNode } from "react";
|
||||
import { useRef } from "react";
|
||||
import { Link } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { useScheduleAgentRuns } from "~/api/agent.ts";
|
||||
import { useDashboard, useSitesWithAccounts } from "~/api/dashboard.ts";
|
||||
import { useDecisions } from "~/api/decisions.ts";
|
||||
import { useEngineRunsPage, useEngineStats } from "~/api/engine.ts";
|
||||
@@ -36,7 +35,7 @@ import { StatTile } from "~/components/console/stat-tile.tsx";
|
||||
import { StatusBadge, type StatusTone } from "~/components/console/status-badge.tsx";
|
||||
import { useVolumeLabel } from "~/components/downloads/cache-volumes.tsx";
|
||||
import { formatUsd, planPath } from "~/components/schedules/labels.ts";
|
||||
import { planStats, useLiveSchedules, useNow } from "~/components/schedules/schedule-board.tsx";
|
||||
import { planStats, useLiveSchedules } from "~/components/schedules/schedule-board.tsx";
|
||||
import { engineRunStatus, runTitle, workflowLabel } from "~/components/tasks/labels.ts";
|
||||
import { useLiveTasks } from "~/components/tasks/task-stream.tsx";
|
||||
import { Button } from "~/components/ui/button.tsx";
|
||||
@@ -353,13 +352,7 @@ function Num({ children, tone }: { children: ReactNode; tone?: "destructive" })
|
||||
|
||||
function PlanStrip() {
|
||||
const board = useLiveSchedules();
|
||||
const runs = useScheduleAgentRuns();
|
||||
const now = useNow(60_000);
|
||||
const s = planStats(
|
||||
board.data?.items ?? [],
|
||||
(runs.data ?? []).map((r) => ({ at: r.createdAt, cost: r.usage.costUsd })),
|
||||
now,
|
||||
);
|
||||
const s = planStats(board.data?.items ?? []);
|
||||
return (
|
||||
<Section
|
||||
title="计划"
|
||||
@@ -388,7 +381,7 @@ function PlanStrip() {
|
||||
启用 <Num>{s.checks.enabled}</Num> / {s.checks.total}
|
||||
</span>
|
||||
<span title="近 7 天巡检会话费用合计">
|
||||
近 7 天 <Num>{runs.isPending ? "…" : runs.isError ? "—" : formatUsd(s.checks.weekCost)}</Num>
|
||||
近 7 天 <Num>{formatUsd(s.checks.weekCost)}</Num>
|
||||
</span>
|
||||
</PlanCount>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user