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
22 changes: 20 additions & 2 deletions packages/app/src/features/runs/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 [continuous, setContinuous] = useState(false);
const active = !status.data || !["succeeded", "failed", "stopped"].includes(status.data.state) || status.data.finalizing;
const finalizedSnapshot = useRef("");
Expand Down Expand Up @@ -51,16 +52,32 @@ export function RunDetail() {
}, onSuccess: () => cache.invalidateQueries({ queryKey: ["runs", runId] }) });
return <Page className="max-w-6xl">
{status.isPending && <p role="status">Loading run…</p>}{status.error && <p role="alert">{status.error.message}</p>}
{status.data && <><Link to="/jobs/$jobId" params={{ jobId: status.data.job_id }}>{status.data.job_name}</Link>
<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>}
</>}
<ExpandedRunDetail runId={runId!} />{status.data && !active && <ReplayTrace runId={runId!} />}
{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}
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}>
<ExpandedRunDetail runId={runId!} />
</section>
<section role="tabpanel" id="run-panel-settings" aria-labelledby="run-tab-settings" hidden={tab !== "settings"} tabIndex={0}>
{status.data && !active ? <ReplayTrace runId={runId!} /> : <p className="my-4">Replay is available after the run finishes and trace finalization completes.</p>}
</section>
<section role="tabpanel" id="run-panel-trace" aria-labelledby="run-tab-trace" hidden={tab !== "trace"} tabIndex={0}>
<h2 className="my-4 text-xl font-semibold">Trace</h2>
<Label><Input type="checkbox" checked={continuous} onChange={e => setContinuous(e.target.checked)} /> Continuous virtualized trace</Label>
{continuous && <ContinuousTrace key={revision} runId={runId!} revision={revision} active={active} onReset={next => { if (next === revision) return; void cache.cancelQueries({ queryKey: ["runs", runId, "continuous-trace"] }); cache.removeQueries({ queryKey: ["runs", runId, "continuous-trace"] }); setRevision(next); cache.setQueryData(runStatusQuery(runId!).queryKey, previous => previous ? { ...previous, trace_revision: next } : previous); cache.removeQueries({ queryKey: ["runs", runId, "continuous-tail"] }); }} />}
Expand All @@ -76,5 +93,6 @@ export function RunDetail() {
{trace.data.nextCursor !== null && <Link to="/job-runs/$runId" params={{ runId: runId! }} search={{ after: trace.data.nextCursor }}>Next trace page</Link>}
</nav>
</>}
</section>
</Page>;
}
8 changes: 7 additions & 1 deletion packages/app/test/runs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ test("prompt/provenance and diagnostics are lazy, terminal replay retries reuse
await page.route(`**/api/v1/runs/${runId}/trace/replay`, route => { replays.push(route.request().postDataJSON()); if (replays.length === 1) return route.fulfill({ status: 503, json: { error: { code: "unavailable", message: "Retry replay" } } }); revision = "new"; return route.fulfill({ json: { status: "projected" } }); });
await page.goto(origin + "/job-runs/" + runId); await page.getByText("Old trace · assistant_message", { exact: true }).click(); assert.equal(detailReads, 0); assert.equal(diagnosticReads, 0);
assert.equal(await page.locator('a[href^="javascript:"]').count(), 0); assert.equal(await page.locator("main script").count(), 0);
assert.equal(await page.getByRole("tab", { name: "Trace", exact: true }).getAttribute("aria-selected"), "true");
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.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.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(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByText("Replayed trace · assistant_message", { exact: true }).waitFor();
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();
assert.equal(replays[0].requestId, replays[1].requestId); assert.equal(await page.getByText("Old trace · assistant_message", { exact: true }).count(), 0); await context.close();
});
test("stopping a run submits once, observes stopping state and keeps terminal finalization visible", async () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
31 changes: 31 additions & 0 deletions packages/app/test/visual/design.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,37 @@ for (const theme of ["light", "dark"]) test(`search loading, error and no result
expect((await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze()).violations).toEqual([]);
});

for (const theme of ["light", "dark"]) test(`run tabs, context and breadcrumbs on mobile ${theme}`, async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.emulateMedia({ colorScheme: theme });
await mockApi(page, { long: true });
await page.goto(origin + screens[3][1]);
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 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();
await expect(page.getByText(/"artifacts":/)).toBeVisible();
await expect(page).toHaveScreenshot(`run-context-${theme}-390.png`, { fullPage: true });
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
expect((await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze()).violations).toEqual([]);
await page.getByRole("tab", { name: "Settings", exact: true }).click();
await page.getByText("Replay trace", { exact: true }).click();
await expect(page.getByRole("button", { name: "Replay retained trace" })).toBeVisible();
await expect(page).toHaveScreenshot(`run-settings-${theme}-390.png`, { fullPage: true });
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
expect((await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze()).violations).toEqual([]);
const breadcrumbs = page.getByRole("navigation", { name: "Breadcrumb" });
await breadcrumbs.getByRole("link", { name: "Review release builds", exact: true }).click();
await expect(page).toHaveURL(new RegExp("/jobs/" + jobId));
await expect(page.getByRole("heading", { name: /^Long release review/ })).toBeVisible();
await page.goto(origin + screens[3][1]);
await page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "Jobs", exact: true }).click();
await expect(page.getByRole("heading", { name: "Jobs", exact: true })).toBeVisible();
});

for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }, { width: 390, height: 400 }]) test(`search geometry stays stable through asynchronous query changes ${viewport.width}x${viewport.height}`, async ({ page }) => {
await page.setViewportSize(viewport); await mockApi(page);
let pending;
Expand Down
Loading