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
6 changes: 3 additions & 3 deletions packages/app/src/features/jobs/detail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page } from "../../shared/ui";
import { Breadcrumb, Page, ResourceHeader } from "../../shared/ui";
import { JobHeader } from "./header";
import { RunHistory } from "../runs/history";
import { useParams, Link } from "@tanstack/react-router";
Expand All @@ -10,8 +10,8 @@ export function JobDetail() {
const query = useQuery(jobQuery(jobId!));
const job = query.data;
const project = useQuery({ ...projectQuery(job?.projectId ?? ""), enabled: !!job?.projectId });
return <Page className="max-w-6xl"><nav aria-label="Breadcrumb"><Link to="/projects" className="font-semibold">Projects</Link><span aria-hidden="true">→</span>{project.data && job?.projectId ? <Link to="/projects/$projectId" params={{ projectId: job.projectId }}>{project.data.name}</Link> : null}</nav>
{query.isPending && <p role="status">Loading job…</p>}{query.error && <p role="alert">{query.error.message}</p>}
return <Page className="max-w-6xl"><Breadcrumb>{project.data && job?.projectId ? <Link to="/projects/$projectId" params={{ projectId: job.projectId }}>{project.data.name}</Link> : <Link to="/projects">Projects</Link>}</Breadcrumb>
{query.isPending && <><ResourceHeader type="Job" title="Job" /><p role="status">Loading job…</p></>}{query.error && <p role="alert">{query.error.message}</p>}
{job && <><JobHeader job={job} /><div className="mb-6"><RunHistory jobId={job.id} /></div></>}
</Page>;
}
3 changes: 1 addition & 2 deletions packages/app/src/features/jobs/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ function EditorForm({ initial }: { initial?: Job }) {
if (conflicts.length === 1) setRemote(undefined);
};
const [localConflictDraft, setLocalConflictDraft] = useState(draft);
const showJobBreadcrumb = Boolean(initial && !location.pathname.endsWith("/settings"));
return <Page className="max-w-6xl"><nav aria-label="Breadcrumb" className="flex min-w-0 flex-wrap items-center gap-2">{project.data && initial?.projectId ? <Link to="/projects/$projectId" params={{ projectId: initial.projectId }}>{project.data.name}</Link> : <Link to="/projects">Projects</Link>}{showJobBreadcrumb && initial && <><span aria-hidden="true">→</span><Link className="break-words min-w-0" to="/jobs/$jobId" params={{ jobId: initial.id }} search={{}}> {initial.name}</Link></>}</nav>{initial && <JobHeader job={initial} />}
return <Page className="max-w-6xl"><nav aria-label="Breadcrumb" className="mb-4 flex min-h-6 min-w-0 flex-wrap items-center gap-2 text-sm">{project.data && initial?.projectId ? <Link to="/projects/$projectId" params={{ projectId: initial.projectId }}>{project.data.name}</Link> : <Link to="/projects">Projects</Link>}</nav>{initial && <JobHeader job={initial} />}
{(remote || reconciling || refreshConflict.error) && <Card role="alert" className="my-4 border p-4"><h2>This job changed while you were editing</h2><p>Your unsaved draft is retained. Review the latest configuration before retrying.</p>
{refreshConflict.isPending && <p>Loading latest configuration…</p>}{refreshConflict.error && <><p>{refreshConflict.error.message}</p><Button onClick={() => refreshConflict.mutate()}>Retry loading latest</Button></>}
{remote && !conflicts.length && <><pre className="max-h-64 overflow-auto whitespace-pre-wrap">{JSON.stringify(editableJob(remote), null, 2)}</pre><Button onClick={acceptRemote}>Reload latest and discard my changes</Button><Button onClick={() => { setLocalConflictDraft(draft); merge(); }}>Reconcile my changes</Button></>}
Expand Down
7 changes: 3 additions & 4 deletions packages/app/src/features/jobs/header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { api } from "factorize-api-client";
import { Button } from "../../shared/ui";
import { Button, ResourceHeader } from "../../shared/ui";
import { messageOf } from "../auth/session";
import { InvokeJob } from "./invoke";
import { JobTabs } from "./tabs";
Expand All @@ -27,10 +27,9 @@ export function JobHeader({ job }: JobHeaderProps) {
});

return <>
<div className="mt-5 flex min-w-0 flex-wrap items-start gap-x-4 gap-y-2"><h1 className={`min-w-0 flex-1 break-words text-3xl font-semibold ${job.enabled ? "" : "text-slate-500 dark:text-slate-400"}`}>{job.name}</h1><div className="flex max-w-full shrink-0 flex-wrap items-center gap-2"><InvokeJob jobId={job.id} enabled={job.enabled} />
<ResourceHeader type="Job" title={job.name} description={<>{job.agentKind} · {job.model || "Default model"} · {job.runningCount}/{job.concurrencyLimit} running</>}><div className="flex max-w-full shrink-0 flex-wrap items-center gap-2"><InvokeJob jobId={job.id} enabled={job.enabled} />
<Button className="min-h-9 px-2.5 py-1.5 text-xs" disabled={enabled.isPending} onClick={() => enabled.mutate(!job.enabled)}>{job.enabled ? "Disable job" : "Enable job"}</Button>
</div></div>
<p className="mb-4 mt-2 text-sm text-slate-600 dark:text-slate-400">{job.agentKind} · {job.model || "Default model"} · {job.runningCount}/{job.concurrencyLimit} running</p>
</div></ResourceHeader>
<JobTabs jobId={job.id} />
{enabled.error && <p role="alert">{enabled.error.message}</p>}
</>;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/features/jobs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from "@tanstack/react-router";
export function JobTabs({ jobId }: { jobId: string }) {
const classes = "inline-flex min-h-11 items-center border-b-2 px-4 py-2 text-sm font-semibold hover:bg-stone-100 dark:hover:bg-slate-800";
const activeProps = { className: "border-factorize-500 text-factorize-700 dark:text-factorize-500", "aria-current": "page" as const };
return <nav aria-label="Job views" className="my-5 flex gap-2 border-b border-stone-200 dark:border-slate-700">
return <nav aria-label="Job views" className="mt-5 flex gap-2 border-b border-stone-200 dark:border-slate-700">
<Link to="/jobs/$jobId" params={{ jobId }} search={{}} activeOptions={{ exact: true, includeSearch: false }} className={classes} activeProps={activeProps} inactiveProps={{ className: "border-transparent" }}>Runs</Link>
<Link to="/jobs/$jobId/settings" params={{ jobId }} activeOptions={{ exact: true, includeSearch: false }} className={classes} activeProps={activeProps} inactiveProps={{ className: "border-transparent" }}>Settings</Link>
</nav>;
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/features/projects/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from "react";
import { Link, useParams } from "@tanstack/react-router";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { api } from "factorize-api-client";
import { Breadcrumb, Button, Input, Label, Page, PageHeader, Textarea } from "../../shared/ui";
import { Breadcrumb, Button, Input, Label, Page, ResourceHeader, Textarea } from "../../shared/ui";
import { Dialog } from "../../shared/dialog";
import { messageOf } from "../auth/session";
import { projectQuery, projectsQuery } from "./queries";
Expand Down Expand Up @@ -40,5 +40,5 @@ export function ProjectDetail() {
setValidationError("");
setEditing(true);
};
return <Page className="max-w-6xl"><Breadcrumb><Link to="/projects" className="font-semibold">Projects</Link></Breadcrumb>{project.data&&<><PageHeader title={project.data.name} description={project.data.description}><div className="flex flex-wrap gap-2"><Button onClick={openEditor}>Edit</Button><Link to="/jobs/new" search={{ projectId }}><Button variant="primary">Create job</Button></Link></div></PageHeader><JobsTable projectId={projectId} />{editing&&<Dialog title="Edit project" close={() => { if (!edit.isPending) setEditing(false); }}><form className="space-y-5" onSubmit={event => { event.preventDefault(); edit.mutate(); }}><Label>Name<Input required maxLength={120} value={name} onChange={event => setName(event.target.value)} /></Label><Label>Description<Textarea maxLength={2000} value={description} onChange={event => setDescription(event.target.value)} /></Label>{validationError&&<p role="alert">{validationError}</p>}<div className="flex justify-end gap-2"><Button type="button" onClick={() => setEditing(false)} disabled={edit.isPending}>Cancel</Button><Button type="submit" variant="primary" disabled={edit.isPending}>{edit.isPending ? "Saving…" : "Save changes"}</Button></div></form></Dialog>}</>}</Page>;
return <Page className="max-w-6xl"><Breadcrumb><Link to="/projects" className="font-semibold">Projects</Link></Breadcrumb><ResourceHeader type="Project" title={project.data?.name ?? "Project"} description={project.data?.description}><div className="flex flex-wrap gap-2">{project.data && <><Button onClick={openEditor}>Edit</Button><Link to="/jobs/new" search={{ projectId }}><Button variant="primary">Create job</Button></Link></>}</div></ResourceHeader>{project.isPending && <p role="status">Loading project…</p>}{project.error && <p role="alert">{project.error.message}</p>}{project.data&&<><JobsTable projectId={projectId} />{editing&&<Dialog title="Edit project" close={() => { if (!edit.isPending) setEditing(false); }}><form className="space-y-5" onSubmit={event => { event.preventDefault(); edit.mutate(); }}><Label>Name<Input required maxLength={120} value={name} onChange={event => setName(event.target.value)} /></Label><Label>Description<Textarea maxLength={2000} value={description} onChange={event => setDescription(event.target.value)} /></Label>{validationError&&<p role="alert">{validationError}</p>}<div className="flex justify-end gap-2"><Button type="button" onClick={() => setEditing(false)} disabled={edit.isPending}>Cancel</Button><Button type="submit" variant="primary" disabled={edit.isPending}>{edit.isPending ? "Saving…" : "Save changes"}</Button></div></form></Dialog>}</>}</Page>;
}
13 changes: 5 additions & 8 deletions packages/app/src/features/runs/detail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Badge, Button, Page } from "../../shared/ui";
import { Badge, Button, Breadcrumb, Page, ResourceHeader } from "../../shared/ui";
import { ContinuousTrace } from "./continuous-trace";
import { ExpandedRunDetail } from "./expanded-detail";
import { ReplayTrace } from "./replay";
Expand Down Expand Up @@ -42,16 +42,13 @@ 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>}
<nav aria-label="Breadcrumb" className="flex min-w-0 flex-wrap items-center gap-2">{status.data?.project_id && status.data.project_name ? <Link to="/projects/$projectId" params={{ projectId: status.data.project_id }}>{status.data.project_name}</Link> : <Link to="/projects">Projects</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>
<Breadcrumb>{status.data ? <Link className="break-words min-w-0" to="/jobs/$jobId" params={{ jobId: status.data.job_id }}>{status.data.job_name}</Link> : <Link to="/projects">Projects</Link>}</Breadcrumb>
{status.data && <>
<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>
<ResourceHeader type="Run" title={status.data.run_name || "Run"} description={<p role="status"><Badge active={active}>{status.data.state}</Badge>{status.data.finalizing ? " · Finalizing trace and artifacts" : ""}</p>}>{["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>}</ResourceHeader>
</>}
{!status.data && <ResourceHeader type="Run" title="Run" />}
{stop.error && <p role="alert">{stop.error.message}</p>}
<nav role="tablist" aria-label="Run details" className="mt-6 flex gap-1 overflow-x-auto border-b border-stone-200 dark:border-slate-700">
<nav role="tablist" aria-label="Run details" className="mt-5 flex gap-1 overflow-x-auto border-b border-stone-200 dark:border-slate-700">
{(["trace", "info"] as const).map((name, index, tabs) => <Link key={name} to={tabPath(name)} params={{ runId: runId! }} search={{ after: 0 }} 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"}`}
onKeyDown={event => {
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/shared/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ export function Select({ className = "", ...props }: ComponentProps<"select">) {
export function Label({ className = "", ...props }: ComponentProps<"label">) { return <label {...props} className={`block min-w-0 text-sm font-medium text-slate-700 dark:text-slate-300 ${className}`} />; }
export function Page({ className = "", ...props }: ComponentProps<"main">) { return <main {...props} id="main-content" className={`mx-auto w-full min-w-0 max-w-6xl flex-1 px-4 py-8 sm:px-6 sm:py-12 lg:px-8 ${className}`} />; }
export function Breadcrumb({ children }: { children?: ReactNode }) { return <nav aria-label="Breadcrumb" className="mb-4 flex min-h-6 min-w-0 flex-wrap items-center gap-2 text-sm">{children}</nav>; }
export function ResourceHeader({ type, title, description, children }: { type: "Project" | "Job" | "Run"; title: string; description?: ReactNode; children?: ReactNode }) {
return <div className="mb-6 min-w-0">
<p className="mb-1 min-h-4 text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400">{type}</p>
<div className="flex min-w-0 flex-wrap items-start justify-between gap-4">
<h1 className="min-w-0 flex-1 break-words text-3xl font-bold tracking-tight">{title}</h1>
{children}
</div>
{description && <div className="mt-2 text-sm text-slate-600 dark:text-slate-400">{description}</div>}
</div>;
}
export function Card({ className = "", ...props }: ComponentProps<"section">) { return <section {...props} className={`min-w-0 rounded-2xl border border-stone-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-900 sm:p-6 ${className}`} />; }
export function PageHeader({ title, description, children }: { title: string; description?: string; children?: ReactNode }) {
return <div className="mb-8 flex min-w-0 flex-wrap items-start justify-between gap-4"><div className="min-w-0"><h1 className="text-3xl font-bold tracking-tight">{title}</h1>{description && <p className="mt-2 text-sm text-slate-600 dark:text-slate-400">{description}</p>}</div>{children}</div>;
Expand Down
4 changes: 3 additions & 1 deletion packages/app/test/jobs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ test("projects and job pages keep a stable breadcrumb row", async () => {
await page.goto(origin + `/projects/${projectId}`);
await page.getByRole("heading", { name: "Release project", exact: true }).waitFor();
assert.deepEqual(await page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link").allTextContents(), ["Projects"]);
assert.equal(await page.getByText("Project", { exact: true }).count(), 1);
await page.goto(origin + `/jobs/${jobId}`);
await page.getByRole("heading", { name: "Review builds", exact: true }).waitFor();
assert.deepEqual(await page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link").allTextContents(), ["Projects", "Release project"]);
assert.deepEqual(await page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link").allTextContents(), ["Release project"]);
assert.equal(await page.getByText("Job", { exact: true }).count(), 1);
await context.close();
});
for (const width of [1280, 390, 320]) for (const theme of ["light", "dark"]) test(`compact jobs grouping, pagination, focus and long titles at ${width} ${theme}`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/test/runs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test("prompt/provenance and diagnostics are lazy, terminal replay retries reuse
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: "Projects", exact: true }).getAttribute("href"), "/projects");
assert.equal(await breadcrumbs.getByRole("link", { name: "Job", exact: true }).count(), 1);
assert.equal(await breadcrumbs.getByRole("link", { name: "Job", exact: true }).getAttribute("href"), "/jobs/" + jobId);
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();
Expand Down
Loading