diff --git a/packages/app/src/features/jobs/detail.tsx b/packages/app/src/features/jobs/detail.tsx index 6c1d3dba..cb5a67d6 100644 --- a/packages/app/src/features/jobs/detail.tsx +++ b/packages/app/src/features/jobs/detail.tsx @@ -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 Jobs {query.isPending &&

Loading job…

}{query.error &&

{query.error.message}

} - {job && <>

{job.name}

- -

{job.agentKind} · {job.model || "Default model"} · {job.runningCount}/{job.concurrencyLimit} running

{enabled.error &&

{enabled.error.message}

} + {job && <>
} diff --git a/packages/app/src/features/jobs/editor.tsx b/packages/app/src/features/jobs/editor.tsx index 64ff83d5..639de902 100644 --- a/packages/app/src/features/jobs/editor.tsx +++ b/packages/app/src/features/jobs/editor.tsx @@ -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"; @@ -54,7 +54,7 @@ function EditorForm({ initial }: { initial?: Job }) { if (conflicts.length === 1) setRemote(undefined); }; const [localConflictDraft, setLocalConflictDraft] = useState(draft); - return

{initial ? initial.name : "Create job"}

{initial && } + return {initial && } {(remote || reconciling || refreshConflict.error) &&

This job changed while you were editing

Your unsaved draft is retained. Review the latest configuration before retrying.

{refreshConflict.isPending &&

Loading latest configuration…

}{refreshConflict.error && <>

{refreshConflict.error.message}

} {remote && !conflicts.length && <>
{JSON.stringify(editableJob(remote), null, 2)}
} diff --git a/packages/app/src/features/jobs/header.tsx b/packages/app/src/features/jobs/header.tsx new file mode 100644 index 00000000..31f9c5f5 --- /dev/null +++ b/packages/app/src/features/jobs/header.tsx @@ -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; +}; + +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 <> +

{job.name}

+ +
+

{job.agentKind} · {job.model || "Default model"} · {job.runningCount}/{job.concurrencyLimit} running

+ + {enabled.error &&

{enabled.error.message}

} + ; +} diff --git a/packages/app/test/jobs.browser.test.mjs b/packages/app/test/jobs.browser.test.mjs index fc63d2c1..472a868b 100644 --- a/packages/app/test/jobs.browser.test.mjs +++ b/packages/app/test/jobs.browser.test.mjs @@ -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(); }); diff --git a/packages/app/test/visual/baselines/editor-dark-1280.png b/packages/app/test/visual/baselines/editor-dark-1280.png index 2f4e70c0..2717aa11 100644 Binary files a/packages/app/test/visual/baselines/editor-dark-1280.png and b/packages/app/test/visual/baselines/editor-dark-1280.png differ diff --git a/packages/app/test/visual/baselines/editor-dark-390.png b/packages/app/test/visual/baselines/editor-dark-390.png index 2048a3f0..f9216271 100644 Binary files a/packages/app/test/visual/baselines/editor-dark-390.png and b/packages/app/test/visual/baselines/editor-dark-390.png differ diff --git a/packages/app/test/visual/baselines/editor-light-1280.png b/packages/app/test/visual/baselines/editor-light-1280.png index 3d951789..bab4206b 100644 Binary files a/packages/app/test/visual/baselines/editor-light-1280.png and b/packages/app/test/visual/baselines/editor-light-1280.png differ diff --git a/packages/app/test/visual/baselines/editor-light-390.png b/packages/app/test/visual/baselines/editor-light-390.png index d20dad02..e267ee19 100644 Binary files a/packages/app/test/visual/baselines/editor-light-390.png and b/packages/app/test/visual/baselines/editor-light-390.png differ