Skip to content

Commit ce3570d

Browse files
Merge pull request #210 from GenerationSoftware/fix/gen-2164-run-tabs
GEN-2164: Organize run details into Trace, Context, and Settings
2 parents 7861ff9 + 6f3db3b commit ce3570d

13 files changed

Lines changed: 58 additions & 3 deletions

‎packages/app/src/features/runs/detail.tsx‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function RunDetail() {
1515
const navigate = useNavigate(), cache = useQueryClient();
1616
const status = useQuery(runStatusQuery(runId!));
1717
const [revision, setRevision] = useState("");
18+
const [tab, setTab] = useState<"trace" | "context" | "settings">("trace");
1819
const [continuous, setContinuous] = useState(false);
1920
const active = !status.data || !["succeeded", "failed", "stopped"].includes(status.data.state) || status.data.finalizing;
2021
const finalizedSnapshot = useRef("");
@@ -51,16 +52,32 @@ export function RunDetail() {
5152
}, onSuccess: () => cache.invalidateQueries({ queryKey: ["runs", runId] }) });
5253
return <Page className="max-w-6xl">
5354
{status.isPending && <p role="status">Loading run…</p>}{status.error && <p role="alert">{status.error.message}</p>}
54-
{status.data && <><Link to="/jobs/$jobId" params={{ jobId: status.data.job_id }}>{status.data.job_name}</Link>
55+
<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>
56+
{status.data && <>
5557
<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>
5658
<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>
5759
{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>}
5860
{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>}
5961
{status.data.destination_url && /^https?:\/\//.test(status.data.destination_url) && <a href={status.data.destination_url} target="_blank" rel="noopener noreferrer">Execution destination</a>}
6062
{["starting", "running", "blocked", "stopping"].includes(status.data.state) && <Button disabled={stop.isPending || status.data.state === "stopping"} onClick={() => stop.mutate()}>Stop run</Button>}
6163
</>}
62-
<ExpandedRunDetail runId={runId!} />{status.data && !active && <ReplayTrace runId={runId!} />}
6364
{stop.error && <p role="alert">{stop.error.message}</p>}
65+
<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">
66+
{(["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}
67+
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"}`}
68+
onClick={() => setTab(name)} onKeyDown={event => {
69+
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;
70+
if (next === null) return;
71+
event.preventDefault(); setTab(tabs[next]); document.getElementById(`run-tab-${tabs[next]}`)?.focus();
72+
}}>{name[0].toUpperCase() + name.slice(1)}</button>)}
73+
</div>
74+
<section role="tabpanel" id="run-panel-context" aria-labelledby="run-tab-context" hidden={tab !== "context"} tabIndex={0}>
75+
<ExpandedRunDetail runId={runId!} />
76+
</section>
77+
<section role="tabpanel" id="run-panel-settings" aria-labelledby="run-tab-settings" hidden={tab !== "settings"} tabIndex={0}>
78+
{status.data && !active ? <ReplayTrace runId={runId!} /> : <p className="my-4">Replay is available after the run finishes and trace finalization completes.</p>}
79+
</section>
80+
<section role="tabpanel" id="run-panel-trace" aria-labelledby="run-tab-trace" hidden={tab !== "trace"} tabIndex={0}>
6481
<h2 className="my-4 text-xl font-semibold">Trace</h2>
6582
<Label><Input type="checkbox" checked={continuous} onChange={e => setContinuous(e.target.checked)} /> Continuous virtualized trace</Label>
6683
{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"] }); }} />}
@@ -76,5 +93,6 @@ export function RunDetail() {
7693
{trace.data.nextCursor !== null && <Link to="/job-runs/$runId" params={{ runId: runId! }} search={{ after: trace.data.nextCursor }}>Next trace page</Link>}
7794
</nav>
7895
</>}
96+
</section>
7997
</Page>;
8098
}

‎packages/app/test/runs.browser.test.mjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ test("prompt/provenance and diagnostics are lazy, terminal replay retries reuse
2424
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" } }); });
2525
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);
2626
assert.equal(await page.locator('a[href^="javascript:"]').count(), 0); assert.equal(await page.locator("main script").count(), 0);
27+
assert.equal(await page.getByRole("tab", { name: "Trace", exact: true }).getAttribute("aria-selected"), "true");
28+
const breadcrumbs = page.getByRole("navigation", { name: "Breadcrumb" });
29+
assert.equal(await breadcrumbs.getByRole("link", { name: "Jobs", exact: true }).getAttribute("href"), "/jobs?q=");
30+
assert.equal(await breadcrumbs.getByRole("link", { name: "Job", exact: true }).getAttribute("href"), "/jobs/" + jobId);
31+
await page.getByRole("tab", { name: "Context", exact: true }).click();
2732
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);
28-
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();
33+
await page.getByRole("tab", { name: "Settings", exact: true }).click();
34+
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();
2935
assert.equal(replays[0].requestId, replays[1].requestId); assert.equal(await page.getByText("Old trace · assistant_message", { exact: true }).count(), 0); await context.close();
3036
});
3137
test("stopping a run submits once, observes stopping state and keeps terminal finalization visible", async () => {
90.5 KB
Loading
87.6 KB
Loading
54.5 KB
Loading
52.8 KB
Loading
-8.2 KB
Loading
-7.43 KB
Loading
-8.47 KB
Loading
-8.23 KB
Loading

0 commit comments

Comments
 (0)