gitflarePublicPartly agent-ready50
cf-workflows-pipeline
Durable content pipeline on Cloudflare Workflows: ingest, extract, summarise with Workers AI via AI Gateway, human approval, publish.
- LicenseApache-2.0
- LanguageTypeScript
- Last landed
629b2faOct 20, 2026
Fix pipeline runs failing at ingest (steps.attempt NOT NULL)
629b2faimport { el, icon } from "./dom.js";import { api } from "./api.js";import { buildTimeline, isFinished } from "./lib.js";import { chip, errorCard } from "./view-runs.js";function approval(id, run, refresh) { const note = el("textarea", { id: "note", "aria-label": "Note (optional)", placeholder: "Note (optional)", style: "min-height:72px" }); const msg = el("p", { class: "muted", role: "status" }); const box = el("div", { class: "row" }); let pending = null; const send = async (kind) => { box.querySelectorAll("button").forEach((b) => (b.disabled = true)); msg.textContent = "Sending…"; try { await api(`/api/runs/${id}/${kind}`, { method: "POST", body: { note: note.value } }); msg.textContent = kind === "approve" ? "Approved. Publishing…" : "Rejected."; refresh(); } catch (e) { msg.textContent = e.message; pending = null; draw(); } }; const draw = () => box.replaceChildren(pending ? [el("span", {}, `Confirm ${pending}?`), el("button", { class: `btn ${pending === "reject" ? "dng" : "pri"}`, onclick: () => send(pending) }, `Yes, ${pending}`), el("button", { class: "btn", onclick: () => { pending = null; draw(); } }, "Cancel")] : [el("button", { class: "btn pri", onclick: () => { pending = "approve"; draw(); } }, icon("done"), "Approve"), el("button", { class: "btn dng", onclick: () => { pending = "reject"; draw(); } }, icon("failed"), "Reject")]); draw(); return el("section", { class: "card", "aria-labelledby": "ap-h" }, el("h2", { id: "ap-h" }, "Approval needed"), el("p", { class: "summary" }, run.summary || "Review the summary above."), el("label", { for: "note" }, "Note"), note, box, msg);}export function detailView(id) { const root = el("div", {}); let timer, stopped = false, shown = false; root.append(el("h1", {}, "Run"), el("div", { class: "skel", style: "height:200px" })); const tick = async () => { if (stopped) return; try { const d = await api(`/api/runs/${encodeURIComponent(id)}`); const run = d.run || d; const steps = d.steps || run.steps || []; const tl = buildTimeline(steps); const waiting = tl.some((s) => s.state === "waiting"); const published = ["published", "done"].includes(String(run.status)) && run.published !== false; root.replaceChildren(el("h1", {}, "Run ", el("code", {}, String(id).slice(0, 8))), el("p", {}, chip(run.status), " ", run.url ? el("span", { class: "muted" }, run.url) : ""), el("ol", { class: "tl", "aria-label": "Pipeline steps" }, tl.map((s) => el("li", { class: `s-${s.state}` }, el("span", { class: "dot" }, icon(s.state)), el("h2", {}, s.name[0].toUpperCase() + s.name.slice(1), chip(s.state, s.attempt)), el("div", { class: "meta" }, s.attempt ? `Attempts: ${s.attempt} · ` : "", `Duration: ${s.duration}`), s.error && el("p", { class: "errtxt" }, s.error), s.preview && el("pre", {}, s.preview)))), waiting && !isFinished(run.status) && approval(id, run, tick), published && el("a", { class: "btn pri", href: `/p/${id}` }, "View published page")); document.getElementById("status").textContent = `Run ${run.status}`; shown = true; if (isFinished(run.status)) return; } catch (e) { if (!shown) { root.replaceChildren(el("h1", {}, "Run"), errorCard(e.message, () => { tick(); })); return; } } clearTimeout(timer); timer = setTimeout(tick, 1000); }; tick(); root.stop = () => { stopped = true; clearTimeout(timer); }; return root;}