import { useState } from "react"; import { useConsole } from "../../context"; import { Bar, DataList } from "../../components/ui"; import { fmt, shortId } from "../../api/client"; import type { Automation, AutomationDetail } from "../../api/types"; const PROMPT_PREVIEW = 160; function humanInterval(s?: number): string { if (!s) return ""; if (s % 86400 === 0) return "(每天)"; if (s % 3600 === 0) return "(每小时)"; if (s % 60 === 0) return "(每 " + s / 60 + " 分钟)"; return ""; } // Automation detail (read-only display): backed by GET // /projects/{pid}/automations/{aid} — full definition + runs[] + // runs_note + heartbeat_binding. Editing is NOT duplicated here: // the single edit form is main's inline edit in the list below // (updateAutomation with the (a, name, prompt, interval, repo) // signature). Detail display + runs + task buttons are our side's // addition; cross-view jumps use location.hash because the IDE // shell switches views on hashchange (no sec-conv / sec-automations // element to scroll to). function AutomationDetailBox({ detail }: { detail: AutomationDetail }) { const ctx = useConsole(); const openTask = (id?: string) => { if (!id) return; ctx.showDetail(id); try { window.location.hash = "#view-tasks"; } catch { /* noop */ } }; return (