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
19 changes: 5 additions & 14 deletions packages/app/src/features/jobs/detail.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { Button, Page } from "../../shared/ui";
import { JobTabs } from "./tabs";
import { Page } from "../../shared/ui";
import { JobHeader } from "./header";
import { RunHistory } from "../runs/history";
import { useParams, Link } from "@tanstack/react-router";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { api } from "factorize-api-client";
import { useQuery } from "@tanstack/react-query";
import { jobQuery } from "./queries";
import { InvokeJob } from "./invoke";
import { messageOf } from "../auth/session";
export function JobDetail() {
const { jobId } = useParams({ strict: false });
const cache = useQueryClient(), query = useQuery(jobQuery(jobId!));
const enabled = useMutation({ retry: false, mutationFn: async (value: boolean) => {
const { error } = value ? await api.POST("/api/v1/jobs/{jobId}/enable", { params: { path: { jobId: jobId! } } }) : await api.POST("/api/v1/jobs/{jobId}/disable", { params: { path: { jobId: jobId! } } });
if (error) throw new Error(messageOf(error));
}, onSuccess: () => cache.invalidateQueries({ queryKey: ["jobs"] }) });
const query = useQuery(jobQuery(jobId!));
const job = query.data;
return <Page className="max-w-6xl"><Link to="/jobs" search={{ q: "" }}>Jobs</Link>
{query.isPending && <p role="status">Loading job…</p>}{query.error && <p role="alert">{query.error.message}</p>}
{job && <><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} />
<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><JobTabs jobId={job.id} /><div className="mb-6">{enabled.error && <p role="alert">{enabled.error.message}</p>}
{job && <><JobHeader job={job} /><div className="mb-6">
<RunHistory jobId={job.id} />
</div>
</>}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/features/jobs/editor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Disclosure, Summary, Button, Input, Select, Label, Page, Card } from "../../shared/ui";
import { JobTabs } from "./tabs";
import { JobHeader } from "./header";
import { DeleteJob } from "./delete";
import { validationMessage } from "./validation-message";
import { useEffect, useState, useRef } from "react";
Expand Down Expand Up @@ -54,7 +54,7 @@ function EditorForm({ initial }: { initial?: Job }) {
if (conflicts.length === 1) setRemote(undefined);
};
const [localConflictDraft, setLocalConflictDraft] = useState(draft);
return <Page className="max-w-6xl"><nav aria-label="Breadcrumb" className="flex min-w-0 flex-wrap items-center gap-2"><Link to="/jobs" search={{ q: "" }}>Jobs</Link>{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><h1 className="mt-5 break-words text-3xl font-semibold">{initial ? initial.name : "Create job"}</h1>{initial && <JobTabs jobId={initial.id} />}
return <Page className="max-w-6xl"><nav aria-label="Breadcrumb" className="flex min-w-0 flex-wrap items-center gap-2"><Link to="/jobs" search={{ q: "" }}>Jobs</Link>{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} />}
{(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
37 changes: 37 additions & 0 deletions packages/app/src/features/jobs/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { api } from "factorize-api-client";
import { Button } from "../../shared/ui";
import { messageOf } from "../auth/session";
import { InvokeJob } from "./invoke";
import { JobTabs } from "./tabs";
import type { Job } from "./editor-state";

type JobHeaderProps = {
job: Pick<Job, "id" | "name" | "enabled" | "agentKind" | "model" | "runningCount" | "concurrencyLimit">;
};

export function JobHeader({ job }: JobHeaderProps) {
const cache = useQueryClient();
const enabled = useMutation({
retry: false,
mutationFn: async (value: boolean) => {
const { error } = value
? await api.POST("/api/v1/jobs/{jobId}/enable", { params: { path: { jobId: job.id } } })
: await api.POST("/api/v1/jobs/{jobId}/disable", { params: { path: { jobId: job.id } } });
if (error) throw new Error(messageOf(error));
},
onSuccess: async () => {
await cache.invalidateQueries({ queryKey: ["jobs"] });
await cache.invalidateQueries({ queryKey: ["jobs", "detail", job.id] });
},
});

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} />
<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>
<JobTabs jobId={job.id} />
{enabled.error && <p role="alert">{enabled.error.message}</p>}
</>;
}
5 changes: 5 additions & 0 deletions packages/app/test/jobs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ test("job Runs tab paginates distinct records, supports refresh/back and keeps c
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
const region = page.getByRole("region", { name: "Runs table" }); await region.focus(); assert.equal(await region.evaluate(el => el === document.activeElement), true);
assert.ok(cursors.includes("page-2") && cursors.includes("page-3"));
await page.goto(origin + `/jobs/${jobId}/settings`);
await page.getByRole("heading", { name: "Review builds", exact: true }).waitFor();
assert.equal(await page.getByText("codex · Default model · 0/2 running", { exact: true }).count(), 1);
assert.equal(await page.getByRole("button", { name: "Run job", exact: true }).count(), 1);
assert.equal(await page.getByRole("button", { name: "Disable job", exact: true }).count(), 1);
await context.close();
});

Expand Down
Binary file modified packages/app/test/visual/baselines/editor-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/editor-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/editor-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/editor-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.
Loading