feat(web): scheduled jobs board (/console/schedules)
- cards grouped by collect / download / organize / maintain / agent checks: switch, in-place interval or cron edit, last result and duration, next-run countdown, failure reason, run now, skip next, reset to default, history drawer - top stats (enabled / failed / running / total) and a scheduler-offline notice; refreshed by the schedule.changed SSE event with a 30s fallback - agent check cards show goal template, trigger, budget and allowlist size; create / edit dialog (read-only capabilities, budget, trigger, interval, report to inbox) - nav entry in the system group, route and smoke route Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a68fcea13b
commit
d800987403
11 files changed
+1024
-3
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import type { ScheduledJob } from "@umt/contracts";
|
||||
import { History } from "lucide-react";
|
||||
import { Link } from "react-router";
|
||||
import { useScheduleRuns } from "~/api/schedules.ts";
|
||||
import { DetailSheet } from "~/components/console/detail-sheet.tsx";
|
||||
import { EmptyState, ErrorState, LoadingState } from "~/components/console/empty-state.tsx";
|
||||
import { consolePath } from "~/components/console/nav.ts";
|
||||
import { StatusBadge } from "~/components/console/status-badge.tsx";
|
||||
import { agentRunLabel } from "~/lib/labels.ts";
|
||||
import { describeSchedule, formatClock, formatMs, RUN_STATUS, TRIGGER_LABEL } from "./labels.ts";
|
||||
|
||||
/** 历史抽屉:最近 50 次运行(新→旧) */
|
||||
export function RunsSheet({ job, onClose }: { job: ScheduledJob | null; onClose: () => void }) {
|
||||
const runs = useScheduleRuns(job?.id ?? null);
|
||||
const items = runs.data?.items ?? [];
|
||||
return (
|
||||
<DetailSheet
|
||||
open={!!job}
|
||||
onOpenChange={(o) => !o && onClose()}
|
||||
title={job ? `${job.name} · 历史` : "历史"}
|
||||
description={
|
||||
job ? `${describeSchedule(job.schedule)} · 累计 ${job.runCount} 次,失败 ${job.failCount} 次` : undefined
|
||||
}
|
||||
>
|
||||
{runs.isPending ? (
|
||||
<LoadingState rows={5} />
|
||||
) : runs.isError ? (
|
||||
<ErrorState plain error={runs.error} onRetry={() => runs.refetch()} />
|
||||
) : items.length === 0 ? (
|
||||
<EmptyState plain icon={History} title="还没有运行记录" />
|
||||
) : (
|
||||
<ol className="grid gap-2">
|
||||
{items.map((r) => {
|
||||
const s = RUN_STATUS[r.status];
|
||||
return (
|
||||
<li key={r.id} className="grid gap-1 rounded-tight border border-border/70 px-3 py-2">
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-meta text-muted-foreground">
|
||||
<StatusBadge tone={s.tone}>{s.label}</StatusBadge>
|
||||
<span>{TRIGGER_LABEL[r.trigger]}</span>
|
||||
<span className="tabular-nums" title={r.startedAt}>
|
||||
{formatClock(r.startedAt)}
|
||||
</span>
|
||||
<span className="ml-auto tabular-nums">{formatMs(r.durationMs)}</span>
|
||||
</div>
|
||||
{r.error ? (
|
||||
<p className="text-caption break-words text-destructive">{r.error}</p>
|
||||
) : r.summary ? (
|
||||
<p className="text-caption break-words text-foreground">{r.summary}</p>
|
||||
) : null}
|
||||
{r.agentRunId ? (
|
||||
<Link
|
||||
to={consolePath("agent", r.agentRunId)}
|
||||
className="w-fit text-meta text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
查看 Agent 会话{r.agentStatus ? `(${agentRunLabel(r.agentStatus).label})` : ""}
|
||||
</Link>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
)}
|
||||
</DetailSheet>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user