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
2 changes: 1 addition & 1 deletion packages/app/src/features/jobs/conditions-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export function ConditionsEditor({ conditions, onChange, onValidityChange }: { c
<Disclosure><Summary>Test webhook conditions</Summary><p>Supply the prepared context the job would receive. This preview does not authenticate, route events, verify live GitHub state, or invoke jobs.</p>
<Label>Example webhook JSON <Textarea rows={8} value={webhook} onChange={e => { setWebhook(e.target.value); test.reset(); }} /></Label>
<Button type="button" disabled={test.isPending || Boolean(invalid)} onClick={() => test.mutate()}>Test conditions</Button>
{test.error && <p role="alert">{test.error.message}</p>}{test.data && <pre role="status" className="whitespace-pre-wrap break-words">{JSON.stringify(test.data, null, 2)}</pre>}
{test.error && <p role="alert">{test.error.message}</p>}{test.data && <p role={test.data.decision === "error" ? "alert" : "status"} aria-live="polite" className={test.data.decision === "match" ? "text-green-700 dark:text-green-400" : undefined}>{test.data.decision === "match" ? "✓ Conditions match the example webhook." : test.data.decision === "no-match" ? "Conditions do not match the example webhook." : "Condition test failed."}</p>}
</Disclosure></div>;
}
2 changes: 1 addition & 1 deletion packages/app/src/features/runs/replay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { messageOf } from "../auth/session";
export function ReplayTrace({ runId }: { runId: string }) {
const cache = useQueryClient(), [source, setSource] = useState<"primary" | "native_session">("primary"), [requestId, setRequestId] = useState(() => crypto.randomUUID());
const replay = useMutation({ retry: false, mutationFn: async () => { const { data, error } = await api.POST("/api/v1/runs/{runId}/trace/replay", { params: { path: { runId } }, body: { source, requestId } }); if (!data || error) throw new Error(messageOf(error)); return data; }, onSuccess: async () => { await cache.invalidateQueries({ queryKey: ["runs", runId] }); setRequestId(crypto.randomUUID()); } });
return <Disclosure className="my-4"><Summary>Replay trace</Summary><p>Rebuild the displayed trace from retained artifacts. Existing pages reset after a successful replay.</p><Label>Replay source <Select disabled={replay.isPending} value={source} onChange={e => { setSource(e.target.value as typeof source); setRequestId(crypto.randomUUID()); replay.reset(); }}><option value="primary">Primary</option><option value="native_session">Native session</option></Select></Label><Button disabled={replay.isPending} onClick={() => { if (window.confirm("Replay this run's retained trace?")) replay.mutate(); }}>Replay retained trace</Button>{replay.error && <p role="alert">{replay.error.message}</p>}{replay.data && <pre role="status" className="whitespace-pre-wrap break-words">{JSON.stringify(replay.data, null, 2)}</pre>}</Disclosure>;
return <Disclosure className="my-4"><Summary>Replay trace</Summary><p>Rebuild the displayed trace from retained artifacts. Existing pages reset after a successful replay.</p><Label>Replay source <Select disabled={replay.isPending} value={source} onChange={e => { setSource(e.target.value as typeof source); setRequestId(crypto.randomUUID()); replay.reset(); }}><option value="primary">Primary</option><option value="native_session">Native session</option></Select></Label><Button disabled={replay.isPending} onClick={() => { if (window.confirm("Replay this run's retained trace?")) replay.mutate(); }}>Replay retained trace</Button>{replay.error && <p role="alert">{replay.error.message}</p>}{replay.data && <p role="status" aria-live="polite" className="text-green-700 dark:text-green-400">✓ Trace replay completed.</p>}</Disclosure>;
}
3 changes: 2 additions & 1 deletion packages/app/src/features/settings/integration-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export function IntegrationForm({ kind, connectionId, initialName = "", initialA
<Label>{kind === "exe" ? "exe.dev account token" : kind === "amp" ? "Amp access token" : "Tail signing secret (leave blank to generate or retain)"} <Input type="password" autoComplete="new-password" required={!connectionId && kind !== "cloudflareTail"} value={credential} onChange={e => { setCredential(e.target.value); test.reset(); }} /></Label>
{kind === "exe" && <><Label>Agent <Select value={agentKind} onChange={e => setAgentKind(e.target.value as typeof agentKind)}><option value="codex">Codex</option><option value="claude">Claude</option><option value="pi">Pi</option></Select></Label><Label>VM tags <Select multiple value={tags} disabled={!connectionId && !test.data?.ok} onChange={e => setTags(Array.from(e.target.selectedOptions, option => option.value))}>{Array.from(new Set([...initialTags, ...(test.data?.tags ?? [])])).map(tag => <option key={tag}>{tag}</option>)}</Select></Label><p>Saving validates the agent and models on a temporary VM.</p></>}
{kind !== "cloudflareTail" && <Button type="button" disabled={test.isPending || save.isPending} onClick={() => test.mutate()}>Test credentials</Button>}
{test.data && <p role="status">{test.data.ok ? "Credentials verified" : "Credential test failed"}</p>}
{test.data?.ok && <p role="status" aria-live="polite" className="text-green-700 dark:text-green-400">✓ Credentials verified.</p>}
{test.data && !test.data.ok && <p role="alert" aria-live="polite" className="text-red-700 dark:text-red-400">Credential verification failed.</p>}
{!connectionId && <Button variant="primary" disabled={save.isPending || test.isPending}>{save.isPending ? "Saving…" : "Save integration"}</Button>}
{connectionId && <AutosaveStatus state={autosave.state} error={autosave.error} label="Integration" />}{!connectionId && savedFeedback && <p role="status" aria-live="polite">Integration saved</p>}{[test.error, save.error].filter(Boolean).map((error, index) => <p key={index} role="alert">{error?.message}</p>)}
{generatedSecret && <Card role="status"><p>Copy this signing secret now; it is displayed only once.</p><pre className="whitespace-pre-wrap break-all">{generatedSecret}</pre><Button type="button" onClick={() => setGeneratedSecret("")}>Dismiss secret</Button></Card>}
Expand Down
9 changes: 4 additions & 5 deletions packages/app/src/features/settings/integrations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,20 @@ function ProviderCard({ kind, name, description, children }: { kind: string; nam
}

export function Integrations() {
const cache = useQueryClient(), status = useQuery(integrationsQuery), github = useQuery(installationsQuery), [openSetup, setOpenSetup] = useState<string | null>(null);
const cache = useQueryClient(), status = useQuery(integrationsQuery), github = useQuery(installationsQuery), [openSetup, setOpenSetup] = useState<string | null>(null), [feedback, setFeedback] = useState<{ key: string; test: boolean; message: string; error: boolean } | null>(null);
const action = useMutation({ retry: false, mutationFn: async ({ kind, id, test }: { kind: "exe" | "amp" | "cloudflareTail" | "github"; id: string; test?: boolean }) => {
let result;
if (kind === "exe") result = test ? await api.POST("/api/v1/integrations/exe/test", { body: { connectionId: id } }) : await api.DELETE("/api/v1/integrations/exe/{connectionId}", { params: { path: { connectionId: id } } });
else if (kind === "amp") result = test ? await api.POST("/api/v1/integrations/amp/test", { body: { connectionId: id } }) : await api.DELETE("/api/v1/integrations/amp/{connectionId}", { params: { path: { connectionId: id } } });
else if (kind === "cloudflareTail") result = test ? await api.POST("/api/v1/integrations/cloudflare-tail/{integrationId}/test", { params: { path: { integrationId: id } } }) : await api.DELETE("/api/v1/integrations/cloudflare-tail/{integrationId}", { params: { path: { integrationId: id } } });
else result = await api.DELETE("/api/v1/providers/github/installations/{installationId}", { params: { path: { installationId: id } } });
if (result.error) throw new Error(messageOf(result.error)); return { test, result: result.data };
}, onSuccess: async () => { await cache.invalidateQueries({ queryKey: ["settings"] }); await cache.invalidateQueries({ queryKey: ["providers"] }); await cache.invalidateQueries({ queryKey: ["editor"] }); } });
const buttons = (kind: "exe" | "amp" | "cloudflareTail" | "github", id: string) => <div className="flex flex-wrap gap-2">{kind !== "github" && <Button disabled={action.isPending} onClick={() => action.mutate({ kind, id, test: true })}>Test connection</Button>}<Button variant="destructive" disabled={action.isPending} onClick={() => { if (window.confirm("Disconnect this integration? Jobs that still reference it must be updated first.")) action.mutate({ kind, id }); }}>Disconnect</Button></div>;
}, onSuccess: async (_result, variables) => { setFeedback({ key: `${variables.kind}:${variables.id}`, test: Boolean(variables.test), message: variables.test ? "Connection verified." : "Integration disconnected.", error: false }); await cache.invalidateQueries({ queryKey: ["settings"] }); await cache.invalidateQueries({ queryKey: ["providers"] }); await cache.invalidateQueries({ queryKey: ["editor"] }); }, onError: (error, variables) => setFeedback({ key: `${variables.kind}:${variables.id}`, test: Boolean(variables.test), message: error.message, error: true }) });
const buttons = (kind: "exe" | "amp" | "cloudflareTail" | "github", id: string) => { const key = `${kind}:${id}`, current = feedback?.key === key ? feedback : null; return <div className="flex flex-wrap items-center gap-2">{kind !== "github" && <Button disabled={action.isPending} onClick={() => { setFeedback(null); action.mutate({ kind, id, test: true }); }}>Test connection</Button>}<Button variant="destructive" disabled={action.isPending} onClick={() => { if (window.confirm("Disconnect this integration? Jobs that still reference it must be updated first.")) { setFeedback(null); action.mutate({ kind, id }); } }}>Disconnect</Button>{current && <p role={current.error ? "alert" : "status"} aria-live="polite" className={current.error ? "text-red-700 dark:text-red-400" : "text-green-700 dark:text-green-400"}>{current.error ? current.message : `✓ ${current.message}`}</p>}</div>; };
const manage = (key: string, form: ReactNode) => openSetup === key && <div className="mt-3 border-t border-stone-200 pt-3 dark:border-slate-700">{form}</div>;
const hasConnections = Boolean(status.data?.linear || status.data?.clickup || status.data?.exeConnections.length || status.data?.ampConnections.length || status.data?.cloudflareTail.installations.length || github.data?.length);
return <SettingsLayout title="Integrations">
{status.isPending && <p role="status">Loading integrations…</p>}{[status.error, github.error, action.error].filter(Boolean).map((error, i) => <p role="alert" key={i}>{error?.message}</p>)}
{action.data?.test && <pre role="status" className="whitespace-pre-wrap break-words">{JSON.stringify(action.data.result, null, 2)}</pre>}
{status.isPending && <p role="status">Loading integrations…</p>}{[status.error, github.error].filter(Boolean).map((error, i) => <p role="alert" key={i}>{error?.message}</p>)}
<section aria-labelledby="your-integrations-heading"><div className="mb-4"><h2 id="your-integrations-heading" className="text-2xl font-bold">Your integrations</h2><p className="mt-1 text-sm text-slate-600 dark:text-slate-400">Manage the connections already available to your workspace.</p></div>
{!hasConnections && !status.isPending && <Card className="border-dashed"><p className="font-semibold">No integrations added yet</p><p className="mt-1 text-sm text-slate-600 dark:text-slate-400">Choose a provider from the available integrations below to get started.</p></Card>}
{hasConnections && <div className="overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900">
Expand Down
6 changes: 3 additions & 3 deletions packages/app/test/editor.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test("provider editor fetches only the selected provider and submits project/mat
await page.route("**/api/v1/job-conditions/test", route => route.fulfill({ json: { decision: "match", details: [] } }));
await page.goto(origin + `/jobs/${id}/edit`); assert.equal(reads.length, 0); await page.getByLabel("New trigger kind").selectOption("webhook"); await page.getByRole("button", { name: "Add trigger" }).click();
await page.getByLabel("Linear project").selectOption("project"); await page.getByRole("button", { name: "Add matching rule" }).click(); await page.getByLabel("Match value").selectOption("done"); await page.getByLabel("Conditions JSON (optional)").fill('{"all":[{"fact":"webhook","path":"$.issue.id","operator":"equal","value":"i1"}]}');
await page.getByText("Test webhook conditions", { exact: true }).click(); await page.getByRole("button", { name: "Test conditions", exact: true }).click(); await page.getByRole("status").filter({ hasText: '"decision": "match"' }).waitFor();
await page.getByText("Test webhook conditions", { exact: true }).click(); await page.getByRole("button", { name: "Test conditions", exact: true }).click({ force: true }); await page.getByRole("status").filter({ hasText: "Conditions match the example webhook." }).waitFor(); assert.equal(await page.getByText('"decision": "match"', { exact: false }).count(), 0);
await page.getByRole("status").filter({ hasText: "Job settings saved." }).waitFor();
assert.ok(reads.every(path => path.startsWith("/api/v1/providers/linear/"))); assert.deepEqual(writes[0].triggers[1].config, { provider: "linear", projectId: "project", matchRules: [{ type: "status", targetId: "done" }], conditions: { all: [{ fact: "webhook", path: "$.issue.id", operator: "equal", value: "i1" }] } }); assert.equal(writes[0].triggers[0].id, triggerId); await context.close();
});
Expand Down Expand Up @@ -129,8 +129,8 @@ for (const config of [
await page.getByLabel("Conditions JSON (optional)").fill(JSON.stringify(changed));
await page.getByText("Test webhook conditions", { exact: true }).click();
await page.getByLabel("Example webhook JSON").fill(JSON.stringify({ provider: config.provider }));
await page.getByRole("button", { name: "Test conditions", exact: true }).click();
await page.getByRole("status").filter({ hasText: '"decision": "match"' }).waitFor();
await page.getByRole("button", { name: "Test conditions", exact: true }).click({ force: true });
await page.getByRole("status").filter({ hasText: "Conditions match the example webhook." }).waitFor();
assert.deepEqual(preview, { conditions: changed, webhook: { provider: config.provider } });
await page.getByRole("status").filter({ hasText: "Job settings saved." }).waitFor();
assert.deepEqual(written.triggers[1], { id: hook.id, slug: hook.slug, kind: hook.kind, enabled: hook.enabled, config: { ...config, conditions: changed } });
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 @@ -96,7 +96,7 @@ test("prompt/provenance and diagnostics are lazy, terminal replay retries reuse
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();
await page.getByText("Prompt, context and provenance", { exact: true }).click(); await page.getByText("Private prompt", { exact: true }).waitFor(); await page.getByText("trigger-fixture", { exact: true }).waitFor(); await page.getByRole("heading", { name: "Trigger context and occurrence" }).waitFor(); await page.getByText("Diagnostics and artifacts", { exact: true }).click(); await page.getByText(/retained\/log.txt/).waitFor(); assert.equal(detailReads, 1); assert.equal(diagnosticReads, 1);
await page.getByRole("tab", { name: "Settings", exact: true }).click();
await page.getByText("Replay trace", { exact: true }).click(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByRole("alert").filter({ hasText: "Retry replay" }).waitFor(); await page.getByRole("tab", { name: "Trace", exact: true }).click(); await page.getByRole("tab", { name: "Settings", exact: true }).click(); await page.getByRole("alert").filter({ hasText: "Retry replay" }).waitFor(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByRole("status").filter({ hasText: "projected" }).waitFor(); await page.getByRole("tab", { name: "Trace", exact: true }).click(); await page.getByText("Replayed trace · assistant_message", { exact: true }).waitFor();
await page.getByText("Replay trace", { exact: true }).click(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByRole("alert").filter({ hasText: "Retry replay" }).waitFor(); await page.getByRole("tab", { name: "Trace", exact: true }).click(); await page.getByRole("tab", { name: "Settings", exact: true }).click(); await page.getByRole("alert").filter({ hasText: "Retry replay" }).waitFor(); page.once("dialog", dialog => dialog.accept()); await page.getByRole("button", { name: "Replay retained trace" }).click(); await page.getByRole("status").filter({ hasText: "Trace replay completed." }).waitFor(); assert.equal(await page.getByText("projected", { exact: true }).count(), 0); await page.getByRole("tab", { name: "Trace", exact: true }).click(); await page.getByText("Replayed trace · assistant_message", { exact: true }).waitFor();
assert.equal(replays[0].requestId, replays[1].requestId); assert.equal(await page.getByText("Old trace · assistant_message", { exact: true }).count(), 0); await context.close();
});
test("stopping a run submits once, observes stopping state and keeps terminal finalization visible", async () => {
Expand Down
Loading
Loading