diff --git a/packages/app/src/features/runs/history.tsx b/packages/app/src/features/runs/history.tsx index b3046c6c..121210b5 100644 --- a/packages/app/src/features/runs/history.tsx +++ b/packages/app/src/features/runs/history.tsx @@ -10,7 +10,7 @@ export function RunHistory({ jobId }: { jobId: string }) { const runs = useQuery(historyQuery(jobId, search.cursor, search.sort, search.direction)); const previous = search.previous === undefined ? [] : search.previous.split(","); const pageClasses = `inline-flex min-h-10 items-center rounded-lg border px-3 py-2 text-sm font-semibold ${buttonClasses.secondary}`; - const columns: Array<[HistorySort, string]> = [["status", "Status"], ["run", "Run"], ["created", "Created"]]; + const columns: Array<[HistorySort, string]> = [["run", "Run"], ["status", "Status"], ["created", "Created"], ["agent", "Agent"]]; const sortColumn = (column: HistorySort) => { const direction = search.sort === column && search.direction === "asc" ? "desc" : "asc"; void navigate({ to: "/jobs/$jobId", params: { jobId }, search: { sort: column, direction, cursor: undefined, previous: undefined } }); @@ -18,13 +18,13 @@ export function RunHistory({ jobId }: { jobId: string }) { const sortLabel = (column: HistorySort) => search.sort === column ? (search.direction === "desc" ? "sorted descending" : "sorted ascending") : "not sorted"; return
{runs.isPending &&

Loading run history…

}{runs.error &&

{runs.error.message}

} - {runs.data && <> + {runs.data && <>
Job runs{search.sort ? "" : ", newest first"}
{columns.map(([column, label]) => sortColumn(column)} />)}{runs.data.items.map(run => + - - - )}{runs.data.items.length === 0 && } + + )}{runs.data.items.length === 0 && }
Job runs{search.sort ? "" : ", newest first"}
{run.run_name || run.issue_title || "Run"} {run.run_name || run.issue_title || "Run"}
No runs found.
{run.agent_kind}
No runs found.
} ; return
{runs.isPending &&

Loading runs…

}{runs.error &&

{runs.error.message}

} - {runs.data && <>{runs.data.items.length === 0 && jobId ?
No runs found.
: runs.data.items.length === 0 ?

No runs yet

: {sortableHeader("status", "Status")}{sortableHeader("job", "Job name")}{sortableHeader("run", "Run")}{sortableHeader("created", "Created")}{runs.data.items.map(run => )}
Runs{search.sort ? "" : ", newest first"}
{run.job_name}{run.run_name || "Run"}
}} + {runs.data && <>{runs.data.items.length === 0 && jobId ?
No runs found.
: runs.data.items.length === 0 ?

No runs yet

: {sortableHeader("status", "Status")}{sortableHeader("job", "Job name")}{sortableHeader("run", "Run")}{sortableHeader("created", "Created")}{runs.data.items.map(run => )}
Runs{search.sort ? "" : ", newest first"}
{run.job_name}{run.run_name || "Run"}
}} {pagination}
; } diff --git a/packages/app/src/shared/ui.tsx b/packages/app/src/shared/ui.tsx index 0c1ebff2..57359316 100644 --- a/packages/app/src/shared/ui.tsx +++ b/packages/app/src/shared/ui.tsx @@ -10,7 +10,7 @@ export const tableHeadClasses = "bg-stone-100 text-xs font-semibold text-slate-6 export const tableRowClasses = "group relative border-t border-stone-200 transition-colors hover:bg-factorize-50 focus-within:bg-factorize-50 focus-within:shadow-[inset_3px_0_0_var(--color-factorize-500)] dark:border-slate-800 dark:hover:bg-factorize-500/10 dark:focus-within:bg-factorize-500/10"; export const tableCellClasses = "px-2 py-2 sm:px-3"; export function Table({ className = "", children, shellProps, ...props }: ComponentProps<"table"> & { shellProps?: ComponentProps<"div"> }) { - return
{children}
; + return
{children}
; } export function SortableHeader({ label, active = false, direction = "asc", onSort, className = "", ariaLabel = label }: { label: string; active?: boolean; direction?: "asc" | "desc"; onSort: () => void; className?: string; ariaLabel?: string }) { const order = active ? (direction === "desc" ? "descending" : "ascending") : "none"; diff --git a/packages/app/test/jobs.browser.test.mjs b/packages/app/test/jobs.browser.test.mjs index f793d78b..90f16623 100644 --- a/packages/app/test/jobs.browser.test.mjs +++ b/packages/app/test/jobs.browser.test.mjs @@ -301,15 +301,17 @@ test("run table headers sort every column accessibly and persist in the URL", as await page.goto(origin + `/jobs/${jobId}`); const table = page.getByRole("table"); await table.getByRole("columnheader").nth(0).getByRole("button").waitFor(); - assert.deepEqual(await table.locator("thead th").allTextContents(), ["Status", "Run", "Created"]); - assert.equal(await table.getByRole("columnheader", { name: /Agent/ }).count(), 0); - for (const index of [0, 1, 2]) assert.equal(await table.getByRole("columnheader").nth(index).getByRole("button").count(), 1); + assert.deepEqual(await table.locator("thead th").allTextContents(), ["Run", "Status", "Created", "Agent"]); + assert.equal(await table.getByRole("columnheader", { name: /Agent/ }).count(), 1); + for (const index of [0, 1, 2, 3]) assert.equal(await table.getByRole("columnheader").nth(index).getByRole("button").count(), 1); const runButton = page.getByRole("button", { name: "Run job", exact: true }), optionsButton = page.getByRole("button", { name: "More run options", exact: true }); const runBox = await runButton.boundingBox(), optionsBox = await optionsButton.boundingBox(); assert.equal(runBox.x + runBox.width, optionsBox.x); const runHeader = table.getByRole("button", { name: /Run, not sorted/ }); + const widths = await table.locator("thead th").evaluateAll(cells => cells.map(cell => Math.round(cell.getBoundingClientRect().width))); await runHeader.focus(); await page.keyboard.press("Enter"); await page.waitForURL(`**/jobs/${jobId}?sort=run&direction=asc`); assert.equal(await table.getByRole("columnheader", { name: /Run/ }).getAttribute("aria-sort"), "ascending"); + assert.deepEqual(await table.locator("thead th").evaluateAll(cells => cells.map(cell => Math.round(cell.getBoundingClientRect().width))), widths); await table.getByRole("button", { name: /Run, sorted ascending/ }).click(); await page.waitForURL(`**/jobs/${jobId}?sort=run&direction=desc`); assert.equal(requests.at(-1).searchParams.get("direction"), "desc"); await context.close(); diff --git a/packages/app/test/runs.browser.test.mjs b/packages/app/test/runs.browser.test.mjs index 5d3307ed..ccd9b234 100644 --- a/packages/app/test/runs.browser.test.mjs +++ b/packages/app/test/runs.browser.test.mjs @@ -32,6 +32,25 @@ 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("all-runs columns keep their widths when sorting changes content", async () => { + const { context, page } = await setup(); + const shortRuns = [{ id: runId, run_name: "Run", state: "succeeded", created_at: time, updated_at: time, started_at: null, agent_kind: "codex" }]; + const longRuns = [{ id: runId, run_name: "A very long run name that should stay inside its assigned column", state: "succeeded", created_at: time, updated_at: time, started_at: null, agent_kind: "codex" }]; + await page.route("**/api/v1/runs?**", route => { + const url = new URL(route.request().url()); + return route.fulfill({ json: { items: url.searchParams.get("sort") === "run" ? longRuns : shortRuns, nextCursor: null } }); + }); + for (const viewport of [{ width: 1280, height: 800 }, { width: 390, height: 844 }]) { + await page.setViewportSize(viewport); await page.goto(origin + "/job-runs"); + const table = page.getByRole("table"); + await table.getByRole("columnheader", { name: /Run/ }).waitFor(); + const widths = await table.locator("thead th").evaluateAll(cells => cells.map(cell => Math.round(cell.getBoundingClientRect().width))); + await table.getByRole("button", { name: /Run, not sorted/ }).click(); await page.waitForURL("**/job-runs?sort=run&direction=asc"); + const sortedWidths = await table.locator("thead th").evaluateAll(cells => cells.map(cell => Math.round(cell.getBoundingClientRect().width))); + assert.deepEqual(sortedWidths, widths); assert.equal(await table.locator("a").first().evaluate(link => getComputedStyle(link).textOverflow), "ellipsis"); + } + 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: [] } }));