Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions packages/app/src/features/runs/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ export function RunDetail() {
const navigate = useNavigate(), cache = useQueryClient();
const status = useQuery(runStatusQuery(runId!));
const [revision, setRevision] = useState("");
const [tab, setTab] = useState<"trace" | "context" | "settings">("trace");
const [tab, setTab] = useState<"trace" | "info" | "settings">("trace");
const [continuous, setContinuous] = useState(false);
const [now, setNow] = useState(() => Date.now());
const active = !status.data || !["succeeded", "failed", "stopped"].includes(status.data.state) || status.data.finalizing;
useEffect(() => {
if (!status.data?.started_at || !active) return;
const timer = window.setInterval(() => setNow(Date.now()), 1_000);
return () => window.clearInterval(timer);
}, [status.data?.started_at, active]);
const finalizedSnapshot = useRef("");
useEffect(() => {
if (!status.data) return;
Expand Down Expand Up @@ -54,24 +60,30 @@ export function RunDetail() {
{status.isPending && <p role="status">Loading run…</p>}{status.error && <p role="alert">{status.error.message}</p>}
<nav aria-label="Breadcrumb" className="flex min-w-0 flex-wrap items-center gap-2"><Link to="/jobs" search={{ q: "" }}>Jobs</Link>{status.data && <><span aria-hidden="true">→</span><Link className="break-words min-w-0" to="/jobs/$jobId" params={{ jobId: status.data.job_id }}>{status.data.job_name}</Link></>}</nav>
{status.data && <>
<h1 className="mt-5 text-3xl font-semibold">{status.data.run_name || "Run"}</h1><p role="status" className="mb-4"><Badge active={active}>{status.data.state}</Badge>{status.data.finalizing ? " · Finalizing trace and artifacts" : ""}</p>
<p className="text-sm text-slate-600 dark:text-slate-400">Created {new Date(status.data.created_at).toLocaleString()} · Started {status.data.started_at ? new Date(status.data.started_at).toLocaleString() : "Not yet"}</p>
{status.data.started_at && <p className="mt-2 text-sm text-slate-600 dark:text-slate-400">Queue time: {Math.max(0, Math.round((Date.parse(status.data.started_at) - Date.parse(status.data.created_at)) / 1000))}s · Runtime: {Math.max(0, Math.round(((active ? Date.now() : Date.parse(status.data.updated_at)) - Date.parse(status.data.started_at)) / 1000))}s</p>}
{active && <p role="status">{trace.data?.items.at(-1)?.type === "reasoning" ? "Thinking…" : trace.data?.items.at(-1)?.title ? `Activity: ${trace.data.items.at(-1)!.title}` : "Waiting for execution activity…"}</p>}
{status.data.destination_url && /^https?:\/\//.test(status.data.destination_url) && <a href={status.data.destination_url} target="_blank" rel="noopener noreferrer">Execution destination</a>}
{["starting", "running", "blocked", "stopping"].includes(status.data.state) && <Button disabled={stop.isPending || status.data.state === "stopping"} onClick={() => stop.mutate()}>Stop run</Button>}
<div className="mt-5 flex min-w-0 flex-wrap items-start gap-3">
<h1 className="min-w-0 flex-1 break-words text-3xl font-semibold">{status.data.run_name || "Run"}</h1>
{["starting", "running", "blocked", "stopping"].includes(status.data.state) && <Button className="shrink-0" disabled={stop.isPending || status.data.state === "stopping"} onClick={() => stop.mutate()}>Stop run</Button>}
</div>
<p role="status" className="mb-4"><Badge active={active}>{status.data.state}</Badge>{status.data.finalizing ? " · Finalizing trace and artifacts" : ""}</p>
</>}
{stop.error && <p role="alert">{stop.error.message}</p>}
<div role="tablist" aria-label="Run details" className="mt-6 flex gap-1 overflow-x-auto border-b border-stone-200 dark:border-slate-700">
{(["trace", "context", "settings"] as const).map((name, index, tabs) => <button key={name} type="button" role="tab" id={`run-tab-${name}`} aria-controls={`run-panel-${name}`} aria-selected={tab === name} tabIndex={tab === name ? 0 : -1}
{(["trace", "info", "settings"] as const).map((name, index, tabs) => <button key={name} type="button" role="tab" id={`run-tab-${name}`} aria-controls={`run-panel-${name}`} aria-selected={tab === name} tabIndex={tab === name ? 0 : -1}
className={`min-h-11 shrink-0 border-b-2 px-4 py-3 text-sm capitalize ${tab === name ? "border-factorize-500 font-semibold" : "border-transparent text-slate-600 hover:border-stone-300 dark:text-slate-400"}`}
onClick={() => setTab(name)} onKeyDown={event => {
const next = event.key === "ArrowRight" ? (index + 1) % tabs.length : event.key === "ArrowLeft" ? (index + tabs.length - 1) % tabs.length : event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : null;
if (next === null) return;
event.preventDefault(); setTab(tabs[next]); document.getElementById(`run-tab-${tabs[next]}`)?.focus();
}}>{name[0].toUpperCase() + name.slice(1)}</button>)}
</div>
<section role="tabpanel" id="run-panel-context" aria-labelledby="run-tab-context" hidden={tab !== "context"} tabIndex={0}>
<section role="tabpanel" id="run-panel-info" aria-labelledby="run-tab-info" hidden={tab !== "info"} tabIndex={0}>
{status.data && <dl className="my-4 grid min-w-0 gap-4 sm:grid-cols-2">
<div><dt className="text-sm font-semibold text-slate-700 dark:text-slate-300">Created</dt><dd className="break-words text-sm text-slate-600 dark:text-slate-400">{new Date(status.data.created_at).toLocaleString()}</dd></div>
<div><dt className="text-sm font-semibold text-slate-700 dark:text-slate-300">Started</dt><dd className="break-words text-sm text-slate-600 dark:text-slate-400">{status.data.started_at ? new Date(status.data.started_at).toLocaleString() : "Not started yet"}</dd></div>
<div><dt className="text-sm font-semibold text-slate-700 dark:text-slate-300">Queue time</dt><dd className="text-sm text-slate-600 dark:text-slate-400">{status.data.started_at ? `${Math.max(0, Math.round((Date.parse(status.data.started_at) - Date.parse(status.data.created_at)) / 1000))}s` : "Not available until the run starts"}</dd></div>
<div><dt className="text-sm font-semibold text-slate-700 dark:text-slate-300">Runtime</dt><dd className="text-sm text-slate-600 dark:text-slate-400">{status.data.started_at ? `${Math.max(0, Math.round(((active ? now : Date.parse(status.data.updated_at)) - Date.parse(status.data.started_at)) / 1000))}s` : "Not available until the run starts"}</dd></div>
<div className="sm:col-span-2"><dt className="text-sm font-semibold text-slate-700 dark:text-slate-300">Execution destination</dt><dd className="break-words text-sm text-slate-600 dark:text-slate-400">{status.data.destination_url && /^https?:\/\//.test(status.data.destination_url) ? <><a className="break-all underline" href={status.data.destination_url} target="_blank" rel="noopener noreferrer">{status.data.destination_url}</a><span className="mt-1 block text-xs">The location where this run executes.</span></> : "Not available for this run"}</dd></div>
</dl>}
<ExpandedRunDetail runId={runId!} />
</section>
<section role="tabpanel" id="run-panel-settings" aria-labelledby="run-tab-settings" hidden={tab !== "settings"} tabIndex={0}>
Expand Down
3 changes: 2 additions & 1 deletion packages/app/test/runs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ test("prompt/provenance and diagnostics are lazy, terminal replay retries reuse
const breadcrumbs = page.getByRole("navigation", { name: "Breadcrumb" });
assert.equal(await breadcrumbs.getByRole("link", { name: "Jobs", exact: true }).getAttribute("href"), "/jobs?q=");
assert.equal(await breadcrumbs.getByRole("link", { name: "Job", exact: true }).getAttribute("href"), "/jobs/" + jobId);
await page.getByRole("tab", { name: "Context", exact: true }).click();
await page.getByRole("tab", { name: "Info", exact: true }).click();
await page.getByText("Created", { exact: true }).waitFor(); await page.getByText("Started", { exact: true }).waitFor(); await page.getByText("Queue time", { exact: true }).waitFor(); await page.getByText("Runtime", { exact: true }).waitFor(); await page.getByText("Execution destination", { exact: true }).waitFor();
await page.getByText("Prompt, context and provenance", { exact: true }).click(); await page.getByText("Private prompt", { exact: true }).waitFor(); await page.getByText("trigger-fixture", { exact: true }).waitFor(); await page.getByRole("heading", { name: "Trigger context and occurrence" }).waitFor(); await page.getByText("Diagnostics and artifacts", { exact: true }).click(); await page.getByText(/retained\/log.txt/).waitFor(); assert.equal(detailReads, 1); assert.equal(diagnosticReads, 1);
await page.getByRole("tab", { name: "Settings", exact: true }).click();
await page.getByText("Replay trace", { exact: true }).click(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByRole("alert").filter({ hasText: "Retry replay" }).waitFor(); await page.getByRole("tab", { name: "Trace", exact: true }).click(); await page.getByRole("tab", { name: "Settings", exact: true }).click(); await page.getByRole("alert").filter({ hasText: "Retry replay" }).waitFor(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByRole("status").filter({ hasText: "projected" }).waitFor(); await page.getByRole("tab", { name: "Trace", exact: true }).click(); await page.getByText("Replayed trace · assistant_message", { exact: true }).waitFor();
Expand Down
Binary file modified packages/app/test/visual/baselines/run-context-dark-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/run-context-light-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/run-settings-dark-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/run-settings-light-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/trace-dark-1280.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/trace-dark-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/trace-failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/trace-light-1280.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/trace-light-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/app/test/visual/baselines/trace-running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/app/test/visual/design.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ for (const theme of ["light", "dark"]) test(`run tabs, context and breadcrumbs o
const trace = page.getByRole("tab", { name: "Trace", exact: true });
await expect(trace).toHaveAttribute("aria-selected", "true");
await trace.focus(); await page.keyboard.press("ArrowRight");
await expect(page.getByRole("tab", { name: "Context", exact: true })).toBeFocused();
await expect(page.getByRole("tab", { name: "Info", exact: true })).toBeFocused();
await page.getByText("Prompt, context and provenance", { exact: true }).click();
await expect(page.getByRole("heading", { name: "Prompt", exact: true })).toBeVisible();
await page.getByText("Diagnostics and artifacts", { exact: true }).click();
Expand Down
Loading