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
4 changes: 2 additions & 2 deletions packages/app/src/features/runs/history.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Badge, Button, buttonClasses, SortableHeader, Table, tableCellClasses, tableHeadClasses, tableRowClasses } from "../../shared/ui";
import { Button, RunStatusDot, buttonClasses, SortableHeader, Table, tableCellClasses, tableHeadClasses, tableRowClasses } from "../../shared/ui";
import { Link, useNavigate, useSearch } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
import { historyQuery } from "./queries";
Expand All @@ -22,7 +22,7 @@ export function RunHistory({ jobId }: { jobId: string }) {
<thead className={tableHeadClasses}><tr>{columns.map(([column, label]) => <SortableHeader key={column} label={label} active={search.sort === column} direction={search.direction} ariaLabel={`${label}, ${sortLabel(column)}`} onSort={() => sortColumn(column)} />)}</tr></thead>
<tbody>{runs.data.items.map(run => <tr className={tableRowClasses} key={run.id}>
<td className={`min-w-40 max-w-sm break-words ${tableCellClasses}`}><Link to="/job-runs/$runId" params={{ runId: run.id }} search={{ after: 0 }} className="font-semibold hover:text-factorize-700 focus-visible:rounded-sm dark:hover:text-factorize-500">{run.run_name || run.issue_title || "Run"}</Link></td>
<td className={`whitespace-nowrap ${tableCellClasses}`}><Badge active={run.state === "running"}>{run.state}</Badge></td>
<td className={`whitespace-nowrap ${tableCellClasses}`}><RunStatusDot state={run.state} /></td>
<td className={`whitespace-nowrap ${tableCellClasses}`}><time dateTime={run.created_at}>{new Date(run.created_at).toLocaleString()}</time></td><td className={tableCellClasses}>{run.agent_kind}</td>
</tr>)}{runs.data.items.length === 0 && <tr><td colSpan={4} className="px-3 py-6 text-center">No runs found.</td></tr>}</tbody>
</Table></>}
Expand Down
6 changes: 2 additions & 4 deletions packages/app/src/features/runs/list.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Badge, Button, buttonClasses, SortableHeader, Table, tableCellClasses, tableHeadClasses, tableRowClasses } from "../../shared/ui";
import { Button, RunStatusDot, buttonClasses, SortableHeader, Table, tableCellClasses, tableHeadClasses, tableRowClasses } from "../../shared/ui";
import { Link, useNavigate, useSearch } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
import { runPageQuery } from "./queries";

export type RunListSearch = { cursor?: string; previous?: string; sort?: "job" | "run" | "status" | "created" | "agent"; direction?: "asc" | "desc" };
const activeStates = new Set(["queued", "starting", "running", "blocked", "stopping"]);

export function RunList({ jobId, limit = 30 }: { jobId?: string; limit?: number }) {
const search = useSearch({ strict: false }) as RunListSearch, navigate = useNavigate({ from: "/job-runs" }), runs = useQuery(runPageQuery({ jobId, cursor: search.cursor, limit, sort: search.sort, direction: search.direction }));
const sortColumn = (sort: RunListSearch["sort"]) => { if (!sort) return; const direction = search.sort === sort && search.direction === "asc" ? "desc" : "asc"; void navigate({ search: { ...search, sort, direction, cursor: undefined, previous: undefined } }); };
Expand All @@ -22,7 +20,7 @@ export function RunList({ jobId, limit = 30 }: { jobId?: string; limit?: number
</nav>;
return <section aria-label="Runs" className="my-6 min-w-0">
{runs.isPending && <p role="status">Loading runs…</p>}{runs.error && <p role="alert">{runs.error.message} <Button onClick={() => void runs.refetch()}>Retry</Button></p>}
{runs.data && <>{runs.data.items.length === 0 && jobId ? <Table shellProps={{ role: "region", "aria-label": "Runs table", tabIndex: 0 }}><tbody><tr><td colSpan={4} className={tableCellClasses + " py-6 text-center"}>No runs found.</td></tr></tbody></Table> : runs.data.items.length === 0 ? <p className="py-8 text-center text-sm text-slate-600 dark:text-slate-400">No runs yet</p> : <Table shellProps={{ role: "region", "aria-label": "Runs table", tabIndex: 0 }}><caption className="sr-only">Runs{search.sort ? "" : ", newest first"}</caption><thead className={tableHeadClasses}><tr>{sortableHeader("status", "Status")}{sortableHeader("job", "Job name")}{sortableHeader("run", "Run")}{sortableHeader("created", "Created")}</tr></thead><tbody>{runs.data.items.map(run => <tr className={tableRowClasses} key={run.id}><td className={`whitespace-nowrap ${tableCellClasses}`}><Badge active={activeStates.has(run.state)}>{run.state}</Badge></td><td className={`min-w-40 max-w-sm break-words ${tableCellClasses}`}><Link to="/jobs/$jobId" params={{ jobId: run.job_id }} className="font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.job_name}</Link></td><td className={`min-w-40 max-w-sm break-words ${tableCellClasses}`}><Link to="/job-runs/$runId" params={{ runId: run.id }} search={{ after: 0 }} className="font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.run_name || "Run"}</Link></td><td className={`whitespace-nowrap ${tableCellClasses}`}><time dateTime={run.created_at}>{new Date(run.created_at).toLocaleString()}</time></td></tr>)}</tbody></Table>}</>}
{runs.data && <>{runs.data.items.length === 0 && jobId ? <Table shellProps={{ role: "region", "aria-label": "Runs table", tabIndex: 0 }}><tbody><tr><td colSpan={4} className={tableCellClasses + " py-6 text-center"}>No runs found.</td></tr></tbody></Table> : runs.data.items.length === 0 ? <p className="py-8 text-center text-sm text-slate-600 dark:text-slate-400">No runs yet</p> : <Table shellProps={{ role: "region", "aria-label": "Runs table", tabIndex: 0 }}><caption className="sr-only">Runs{search.sort ? "" : ", newest first"}</caption><thead className={tableHeadClasses}><tr>{sortableHeader("status", "Status")}{sortableHeader("job", "Job name")}{sortableHeader("run", "Run")}{sortableHeader("created", "Created")}</tr></thead><tbody>{runs.data.items.map(run => <tr className={tableRowClasses} key={run.id}><td className={`whitespace-nowrap ${tableCellClasses}`}><RunStatusDot state={run.state} /></td><td className={`min-w-40 max-w-sm break-words ${tableCellClasses}`}><Link to="/jobs/$jobId" params={{ jobId: run.job_id }} className="font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.job_name}</Link></td><td className={`min-w-40 max-w-sm break-words ${tableCellClasses}`}><Link to="/job-runs/$runId" params={{ runId: run.id }} search={{ after: 0 }} className="font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.run_name || "Run"}</Link></td><td className={`whitespace-nowrap ${tableCellClasses}`}><time dateTime={run.created_at}>{new Date(run.created_at).toLocaleString()}</time></td></tr>)}</tbody></Table>}</>}
{pagination}
</section>;
}
9 changes: 9 additions & 0 deletions packages/app/src/shared/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export function SortableHeader({ label, active = false, direction = "asc", onSor
const next = active && direction === "asc" ? "descending" : "ascending";
return <th scope="col" aria-sort={order} className={`${tableCellClasses} ${className}`}><button type="button" className="font-semibold underline decoration-transparent underline-offset-4 hover:decoration-current focus-visible:rounded-sm focus-visible:decoration-current focus-visible:outline-none" onClick={onSort} aria-label={`${ariaLabel}, ${active ? `sorted ${order}` : "not sorted"}. Activate to sort ${next}`}>{label}{active && <span aria-hidden="true"> {direction === "desc" ? "↓" : "↑"}</span>}</button></th>;
}
const runStatusStyles: Record<string, { label: string; color: string; pulse?: boolean }> = {
queued: { label: "Queued", color: "bg-amber-500" }, starting: { label: "Starting", color: "bg-blue-500" }, running: { label: "Running", color: "bg-blue-500", pulse: true },
blocked: { label: "Blocked", color: "bg-amber-500" }, stopping: { label: "Stopping", color: "bg-amber-500" }, succeeded: { label: "Succeeded", color: "bg-emerald-500" }, done: { label: "Done", color: "bg-emerald-500" },
failed: { label: "Failed", color: "bg-red-500" }, stopped: { label: "Stopped", color: "bg-slate-500" }, ignored: { label: "Ignored", color: "bg-slate-400" },
};
export function RunStatusDot({ state }: { state: string }) {
const status = runStatusStyles[state] ?? { label: state || "Unknown", color: "bg-slate-400" };
return <span role="img" aria-label={`Status: ${status.label}`} title={status.label} className={`inline-block size-2.5 rounded-full ${status.color} ${status.pulse ? "motion-safe:animate-pulse" : ""}`} />;
}
export function Button({ variant = "secondary", className = "", ...props }: ComponentProps<"button"> & { variant?: keyof typeof buttonClasses }) {
return <button {...props} className={`inline-flex min-h-10 shrink-0 items-center justify-center gap-2 rounded-lg border px-3 py-2 text-sm font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${buttonClasses[variant]} ${className}`} />;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/app/test/runs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ test("all-runs table sorts its data columns with accessible headers", async () =
assert.equal(await table.getByRole("columnheader", { name: /Created/ }).getAttribute("aria-sort"), "descending");
await context.close();
});
test("shared run status dots show running transitions in both tables", async () => {
const { context, page } = await setup(); let state = "running";
await page.route(`**/api/v1/jobs/${jobId}`, route => route.fulfill({ json: { id: jobId, name: "Job", enabled: true, model: "", agentKind: "codex", concurrencyLimit: 1, runningCount: state === "running" ? 1 : 0, promptTemplate: "Prompt", triggers: [] } }));
await page.route("**/api/v1/runs?**", route => route.fulfill({ json: { items: [{ id: runId, run_name: "Transition run", state, created_at: time, agent_kind: "codex" }], nextCursor: null } }));
await page.goto(origin + "/job-runs"); await page.getByRole("img", { name: "Status: Running" }).waitFor();
assert.match(await page.getByRole("img", { name: "Status: Running" }).getAttribute("class"), /animate-pulse/);
state = "succeeded"; await page.reload(); await page.getByRole("img", { name: "Status: Succeeded" }).waitFor();
assert.doesNotMatch(await page.getByRole("img", { name: "Status: Succeeded" }).getAttribute("class"), /animate-pulse/);
state = "failed"; await page.goto(origin + `/jobs/${jobId}`); await page.getByRole("img", { name: "Status: Failed" }).waitFor();
assert.doesNotMatch(await page.getByRole("img", { name: "Status: Failed" }).getAttribute("class"), /animate-pulse/); await context.close();
});
test("job run history restores its cursor on direct refresh and ignores legacy filters", async () => {
const { context, page } = await setup(); const requests = [];
await page.route(`**/api/v1/jobs/${jobId}`, route => route.fulfill({ json: { id: jobId, name: "Job", enabled: true, model: "", agentKind: "codex", concurrencyLimit: 1, runningCount: 0, promptTemplate: "Prompt", triggers: [] } }));
Expand Down
Binary file modified packages/app/test/visual/baselines/job-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/job-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/job-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/job-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/long-job-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading