import { For, type JSX, Show } from "solid-js"; import { CONFIG } from "../config"; import { fmtAge, fmtDuration, shortDelivery, splitIssueKey } from "../format"; import { runCancel, statusResource } from "../state"; import type { RunningEvent } from "../types"; import { GlassCard } from "./GlassCard"; import { IssueLink } from "./IssueLink"; import { Pill } from "./Pill"; interface Row { key: string; delivery_id: string; issue_key: string | null; event_type: string; attempts: number; model: string | null; last_tool: string | null; last_tool_ts: string | null; started_at: string | null; inflight_only: boolean; } function rowsFor(running: RunningEvent[], inflight: string[]): Row[] { const out: Row[] = []; const seen = new Set(); for (const e of running) { const key = e.issue_key ?? e.delivery_id; seen.add(key); out.push({ key, delivery_id: e.delivery_id, issue_key: e.issue_key, event_type: e.event_type, attempts: e.attempts, model: e.model, last_tool: e.last_tool, last_tool_ts: e.last_tool_ts, started_at: e.started_at ?? e.received_at, inflight_only: false, }); } for (const key of inflight) { if (seen.has(key)) continue; out.push({ key, delivery_id: "", issue_key: key, event_type: "", attempts: 0, model: null, last_tool: null, last_tool_ts: null, started_at: null, inflight_only: true, }); } return out; } async function cancelDelivery(deliveryId: string): Promise { if ( !window.confirm( "Kill this running task? The omp subprocess dies and the row lands in 'failed'.", ) ) { return; } await runCancel(deliveryId); } function elapsed(startedAt: string | null): string { if (!startedAt) return "—"; const t = Date.parse(startedAt); if (Number.isNaN(t)) return "—"; return fmtDuration((Date.now() - t) / 1000); } export function Working(): JSX.Element { const rows = (): Row[] => { const s = statusResource(); return s ? rowsFor(s.running_events, s.inflight) : []; }; return ( {rows().length}}> idle — waiting for events}>
{(r) => }
issue event state elapsed model last action attempt
); } function WorkingRow(props: { row: Row }): JSX.Element { const ref = (): { repo: string; number: string } => splitIssueKey(props.row.issue_key); return ( {shortDelivery(props.row.delivery_id)}}> {props.row.event_type || "—"} {props.row.inflight_only ? "inflight" : "running"} {elapsed(props.row.started_at)} {props.row.model ? ( {props.row.model} ) : ( — )} {props.row.last_tool ? ( {props.row.last_tool} {fmtAge(props.row.last_tool_ts)} ) : ( {props.row.inflight_only ? "held by pool" : "—"} )} {props.row.inflight_only ? "—" : `#${props.row.attempts}`} —} > ); }