From ed34c42178240caace08a18850deffe1b4ae7d44 Mon Sep 17 00:00:00 2001 From: LHaghfoss Date: Mon, 23 Nov 2026 13:42:11 +0100 Subject: [PATCH] fix(desktop): open job run history from cards --- apps/desktop/src/ui/JobCard.tsx | 26 ++++++--- apps/desktop/src/ui/JobDetails.tsx | 87 ++++++++++++++++++++++++++++++ apps/desktop/src/ui/Loops.tsx | 36 +++++++++++-- apps/desktop/src/ui/MainHeader.tsx | 12 +++-- 4 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 apps/desktop/src/ui/JobDetails.tsx diff --git a/apps/desktop/src/ui/JobCard.tsx b/apps/desktop/src/ui/JobCard.tsx index ebae1fa03..812629307 100644 --- a/apps/desktop/src/ui/JobCard.tsx +++ b/apps/desktop/src/ui/JobCard.tsx @@ -136,6 +136,7 @@ export function JobCard({ agent, machineLabel, onOpen, + onEdit, onDuplicate, onDelete, act, @@ -146,6 +147,7 @@ export function JobCard({ /** Shown in the footer when the network has more than one machine, or for hub-dispatched jobs. */ machineLabel?: string; onOpen: () => void; + onEdit: () => void; onDuplicate: () => void; onDelete: () => void; act: (what: string, run: () => Promise) => void; @@ -169,7 +171,7 @@ export function JobCard({
  • {loop.name} @@ -223,7 +225,7 @@ export function JobCard({ )} {loop.paused ? "Resume" : "Pause"} - + Edit @@ -244,7 +246,7 @@ export function JobCard({ {agent && ( - + {agent} )} @@ -281,9 +283,6 @@ export function JobCard({ )}
    - - - {projectName(loop.workspace)} {(machineLabel || loop.machine) && ` on ${machineLabel || loop.machine}`} ·{" "} @@ -315,6 +314,19 @@ export function JobCard({ {nextRunText(loop, now)} )}
    +
    + + {loop.runs.length > 0 && ( + + {loop.runs.length} {loop.runs.length === 1 ? "run" : "runs"} + + )} + + + + Run history + +
  • ); } diff --git a/apps/desktop/src/ui/JobDetails.tsx b/apps/desktop/src/ui/JobDetails.tsx new file mode 100644 index 000000000..136197ba0 --- /dev/null +++ b/apps/desktop/src/ui/JobDetails.tsx @@ -0,0 +1,87 @@ +import { Dialog } from "radix-ui"; +import { useRef } from "react"; +import { projectName } from "../acp/types"; +import { runThreadKey } from "../state/fleetLoops"; +import { type Loop, nextRunText, scheduleInWords } from "../state/loops"; +import { selfName, useLocalIdentity, useMachines } from "../state/machines"; +import { FULL_RUN_FORMAT, isFailedRun, RunList } from "./JobRuns"; +import { Pill } from "./primitives"; + +export function JobDetails({ + loop, + now, + machine, + onClose, + onEdit, +}: { + loop: Loop; + now: number; + machine: string; + onClose: () => void; + onEdit: () => void; +}) { + const returnFocus = useRef(null); + const machines = useMachines((s) => s.machines); + const local = useLocalIdentity(); + const localName = local.displayName ?? selfName(); + const next = !loop.paused && loop.schedule.kind !== "manual" ? loop.nextDueAt : undefined; + const stats = [ + { label: "Recorded runs", value: loop.runs.length }, + { label: "Succeeded", value: loop.runs.filter((run) => run.state === "succeeded").length }, + { label: "Failed", value: loop.runs.filter(isFailedRun).length }, + ]; + + return ( + !open && onClose()}> + + +
    + { + returnFocus.current = + document.activeElement instanceof HTMLElement ? document.activeElement : null; + }} + onCloseAutoFocus={(event) => { + event.preventDefault(); + if (document.activeElement === document.body) returnFocus.current?.focus(); + }} + className="elevated pointer-events-auto flex max-h-full w-full max-w-xl flex-col overflow-hidden" + > +
    + {loop.name} + + {projectName(loop.workspace)} · {machine} · {scheduleInWords(loop.schedule)} + +

    + {next === undefined ? nextRunText(loop, now) : `Next run ${FULL_RUN_FORMAT.format(next)}`} +

    +
    +
    +
    + {stats.map(({ label, value }) => ( +
    +
    {label}
    +
    {value}
    +
    + ))} +
    +

    Run history

    + runThreadKey(loop, run, machines, localName)} + onOpenThread={onClose} + /> +
    +
    + Edit job + + Done + +
    +
    +
    +
    +
    + ); +} diff --git a/apps/desktop/src/ui/Loops.tsx b/apps/desktop/src/ui/Loops.tsx index 22d8875e0..670b2c66b 100644 --- a/apps/desktop/src/ui/Loops.tsx +++ b/apps/desktop/src/ui/Loops.tsx @@ -4,7 +4,7 @@ * from the sidebar's Jobs row. Jobs live across the entire paired machine network: every connected * computer's scheduler is read and managed directly over ACP, and a hub's members remain reachable * too. Each job is a card with its agent, last result, schedule and next run; the card opens one - * dialog that edits the job beside its runs. Jobs paused by failures lead. Review is a timeline by + * dialog with its run history and a link to edit the job. Jobs paused by failures lead. Review is a timeline by * day of failed runs and open threads, a repeated failure folded into one row. */ @@ -39,6 +39,7 @@ import { LOCAL_HOST } from "../state/threadKeys"; import { statusOf } from "../state/threadStatus"; import { CheckCheck, Plus, Repeat } from "./icons"; import { JobCard, listening } from "./JobCard"; +import { JobDetails } from "./JobDetails"; import { JobReview } from "./JobReview"; import { showJob } from "./JobRunBar"; import { LoopDialog } from "./LoopDialog"; @@ -97,6 +98,7 @@ export function Loops() { const [error, setError] = useState(null); const [scopeHost, setScopeHost] = useState(ALL_MACHINES); const [tab, setTab] = useState("jobs"); + const [detailsKey, setDetailsKey] = useState(null); const [editing, setEditing] = useState(null); const [duplicating, setDuplicating] = useState(false); const [dialogOpen, setDialogOpen] = useState(false); @@ -202,13 +204,13 @@ export function Loops() { setTab("jobs"); if (effectiveScope !== ALL_MACHINES && effectiveScope !== match.host) setScopeHost(ALL_MACHINES); useLoopThreads.setState({ reveal: null }); - openJob(match); + setDetailsKey(loopKey(match)); requestAnimationFrame(() => listRef.current ?.querySelector(`[data-loop="${CSS.escape(loopKey(match))}"]`) ?.scrollIntoView({ block: "nearest" }), ); - }, [reveal, byHost, allLoops, effectiveScope, openJob]); + }, [reveal, byHost, allLoops, effectiveScope]); const attention: Loop[] = []; const upcoming: Loop[] = []; @@ -354,11 +356,22 @@ export function Loops() { const showToolbar = Boolean(byHost && (hasPeers || (anyDaemonRunning && loops.length > 0))); const canCreate = Boolean(byHost && (anyDaemonRunning || hasPeers)); + const details = allLoops.find((loop) => loopKey(loop) === detailsKey); + return (
    - +
    +
    +

    Jobs

    + {loops.length > 0 && ( +

    + {loops.length} {loops.length === 1 ? "job" : "jobs"} · {upcoming.length} active ·{" "} + {attention.length} need attention +

    + )} +
    {showToolbar && (
    {(loops.length > 0 || tab === "review") && ( @@ -489,7 +502,8 @@ export function Loops() { ? loopMachineLabel(loop, machines, localName) : undefined } - onOpen={() => openJob(loop)} + onOpen={() => setDetailsKey(loopKey(loop))} + onEdit={() => openJob(loop)} onDuplicate={() => openJob(loop, true)} onDelete={() => confirmDelete(loop)} act={act} @@ -504,6 +518,18 @@ export function Loops() { )}
    + {details && ( + setDetailsKey(null)} + onEdit={() => { + setDetailsKey(null); + openJob(details); + }} + /> + )} s.sidebarHidden); const lightsInset = useLightsInset(); const controlsInset = windowControlsInset(appPlatform()); @@ -90,9 +90,13 @@ export function ViewHeader({ title, children }: { title: ReactNode; children?: R }} > {sidebarHidden && } -

    - {title} -

    + {title == null ? ( +
    + ) : ( +

    + {title} +

    + )} {children} );