diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96880ba8..845831a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,5 +45,12 @@ jobs: - name: Install browser for static application checks run: npx playwright install --with-deps chromium - run: npm run check + - name: Upload visual comparison failures + if: failure() + uses: actions/upload-artifact@v4 + with: + name: factorize-visual-failures + path: packages/app/test-results + if-no-files-found: ignore - name: Exercise compiled jobs/invocation/run slice against PostgreSQL run: npm run test:static-slice --workspace=factorize diff --git a/.gitignore b/.gitignore index ff23a125..2d0499d3 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ coverage/ # Local TLS and Python test caches .dev-certs/ __pycache__/ + +packages/app/test-results/ +packages/app/playwright-report/ +packages/app/test/visual/.legacy/ diff --git a/docs/design-restoration.md b/docs/design-restoration.md new file mode 100644 index 00000000..4327d520 --- /dev/null +++ b/docs/design-restoration.md @@ -0,0 +1,170 @@ +# GEN-2159 design restoration + +The static React app ports the established honey/charcoal identity without changing +API operations, public contracts, routing loaders, cache keys, mutation retry policies, +session handling, or trace virtualization. + +## Reference and reproduction + +Visual source: `82a9cda:packages/app/src/ui.ts` and `tailwind.css`. +The executable reference uses `ff4b51b:packages/api/src/ui.ts` and `tailwind.css`, +the additive API anchor with the legacy design intact. The exact historical tokens +are retained, including primary honey `#fdc901` and warm stone/slate overrides. +Only deterministic fixture data is used: fictional owner/workspace, fixed UUIDs, +UTC time, and the same job, prompt, model, integration, run, and trace contents. + +From the repository root, with Node 24 and Chromium installed: + +```sh +npm ci +npx playwright install --with-deps chromium +npm run build:app +node scripts/design/capture-legacy.mjs +npm run test:visual --workspace=factorize-app +``` + +Reference capture reads historical files with `git archive`, bundles them into a +temporary test-only directory, compiles their own Tailwind stylesheet, renders their +actual HTML and scripts, mocks their API responses, and removes the temporary files. +Historical code never enters the application build. Historical native-auth pages +omitted theme initialization; the capture explicitly applies their existing dark +classes to compare their dark styling. Timers are frozen and cursor-aware fixtures keep each historical trace event unique. Restored runs use Playwright's fixed clock. + +To intentionally change reviewed baselines: + +```sh +npm run test:visual --workspace=factorize-app -- --update-snapshots +``` + +Review expected/actual/diff artifacts in `packages/app/test-results` and the full-page +PNGs before committing. CI runs comparisons, never snapshot updates. The suite uses +Chromium, en-US, UTC, reduced motion, fixed network fixtures, 1280×900 and 390×900. +Pixel comparisons allow at most 0.1% differences for small font rasterization changes. + +## Surface inventory + +| Surface | Restored presentation | +| --- | --- | +| Shared shell | Existing monochrome bee, wordmark, constrained 6xl layout, responsive navigation, active links, search affordance, account disclosure, global theme toggle, skip link, warm footer and safe-area padding | +| Foundations | Exact historical tokens; light/dark fields, labels, cards, typography, focus rings, primary/secondary/destructive/disabled buttons, status badges, native disclosures and modal backdrop | +| Jobs | Header/action, filter panel, job cards, state/model/concurrency hierarchy, pagination, empty/loading/error states | +| Job detail | Compact grouped Run/edit/enable actions, status metadata, prompt disclosure, triggers, bounded run history, separated destructive action | +| Editor | Grouped job details, execution settings, prompt/context and trigger sections; responsive fields, safe template overlay, existing variable insertion/provider/lifecycle/conflict flows | +| Runs | Timing and state hierarchy, lazy prompt/provenance/diagnostics, replay, styled user/assistant/reasoning/tool/command/error events, safe Markdown/code highlighting, ANSI terminal surface, live activity and retained virtualization | +| Settings | Desktop sidebar/mobile wrapping navigation, original provider icon shapes, integration cards/setup disclosures, API-key creation/list/one-time secret, authorized clients and account/password forms | +| Search | Native modal, explanatory empty state, honey keyboard selection, combobox semantics, results/empty/loading/error feedback, Escape and focus restoration | +| Auth/protocol | Branded login/signup/reset/verification/password cards, OAuth consent and device authorization, readable notices and pending controls | +| Remaining states | App entry, router pending/error/not-found and chunk recovery; marketing remains on factorize.sh | + +## Intentional adaptations + +- New bounded jobs/run filters and pagination remain visible in panels; they have no + equivalent in the earlier full-list UI. Job cards expose model and run-state badges + so current capabilities fit the established surfaces and typography. +- The editor keeps the current explicit inline trigger/provider/lifecycle controls + rather than restoring the old imperative table/editor dialog. Sections use the + original field, card, border and spacing language; reconciliation retains its draft. +- Run opens one compact native modal with all current name/prompt/JSON options. + Submission still uses the same payload, idempotency key and retry behavior. +- Trace disclosures retain the current safe React Markdown and lazy diagnostics, + with event-type surfaces and syntax coloring. Raw legacy HTML rendering is excluded. + Continuous traces preserve measurement, polling/reset logic, pinned focus/selection, + expansion identity and bounded DOM behavior. +- Integration setup remains in provider cards with native disclosures so current + edit/test/remove behavior stays explicit. The original provider SVG shapes and + responsive settings sidebar are retained. +- Primary actions use honey with charcoal text consistently. Historical black/white + auth and create/save buttons are intentionally normalized to the brand primary. +- ANSI output has a stable charcoal terminal surface in both themes: the existing + green ANSI palette measured 2.05:1 against the light stone surface. Its original + colors are preserved on the dark terminal surface. +- The theme toggle is available on all screens. A classic blocking, content-hashed + same-origin script runs before CSS and module scripts, honors saved choices or the + OS, and works under `script-src 'self'` without inline-script exceptions. Brand and + theme assets build under the existing Worker `/assets/` allowlist. +- Native auth dark styling is now initialized consistently; the reference's missing + native-auth initialization is corrected. In-app not-found presentation is styled; + the Worker's explicit static/protocol route allowlist remains unchanged. + +## Screenshot comparisons + +Each link is a committed full-page PNG. All four combinations were reviewed for +composition, field spacing, theme contrast, wrapped navigation and internal overflow. + +### Light, 1280px + +| Screen | Historical reference | Restored React | +| --- | --- | --- | +| Jobs | [Reference](../packages/app/test/visual/references/jobs-light-1280.png) | [Restored](../packages/app/test/visual/baselines/jobs-light-1280.png) | +| Job detail | [Reference](../packages/app/test/visual/references/job-light-1280.png) | [Restored](../packages/app/test/visual/baselines/job-light-1280.png) | +| Editor | [Reference](../packages/app/test/visual/references/editor-light-1280.png) | [Restored](../packages/app/test/visual/baselines/editor-light-1280.png) | +| Run trace | [Reference](../packages/app/test/visual/references/trace-light-1280.png) | [Restored](../packages/app/test/visual/baselines/trace-light-1280.png) | +| Settings | [Reference](../packages/app/test/visual/references/settings-light-1280.png) | [Restored](../packages/app/test/visual/baselines/settings-light-1280.png) | +| Login | [Reference](../packages/app/test/visual/references/login-light-1280.png) | [Restored](../packages/app/test/visual/baselines/login-light-1280.png) | + +### Light, 390px + +| Screen | Historical reference | Restored React | +| --- | --- | --- | +| Jobs | [Reference](../packages/app/test/visual/references/jobs-light-390.png) | [Restored](../packages/app/test/visual/baselines/jobs-light-390.png) | +| Job detail | [Reference](../packages/app/test/visual/references/job-light-390.png) | [Restored](../packages/app/test/visual/baselines/job-light-390.png) | +| Editor | [Reference](../packages/app/test/visual/references/editor-light-390.png) | [Restored](../packages/app/test/visual/baselines/editor-light-390.png) | +| Run trace | [Reference](../packages/app/test/visual/references/trace-light-390.png) | [Restored](../packages/app/test/visual/baselines/trace-light-390.png) | +| Settings | [Reference](../packages/app/test/visual/references/settings-light-390.png) | [Restored](../packages/app/test/visual/baselines/settings-light-390.png) | +| Login | [Reference](../packages/app/test/visual/references/login-light-390.png) | [Restored](../packages/app/test/visual/baselines/login-light-390.png) | + +### Dark, 1280px + +| Screen | Historical reference | Restored React | +| --- | --- | --- | +| Jobs | [Reference](../packages/app/test/visual/references/jobs-dark-1280.png) | [Restored](../packages/app/test/visual/baselines/jobs-dark-1280.png) | +| Job detail | [Reference](../packages/app/test/visual/references/job-dark-1280.png) | [Restored](../packages/app/test/visual/baselines/job-dark-1280.png) | +| Editor | [Reference](../packages/app/test/visual/references/editor-dark-1280.png) | [Restored](../packages/app/test/visual/baselines/editor-dark-1280.png) | +| Run trace | [Reference](../packages/app/test/visual/references/trace-dark-1280.png) | [Restored](../packages/app/test/visual/baselines/trace-dark-1280.png) | +| Settings | [Reference](../packages/app/test/visual/references/settings-dark-1280.png) | [Restored](../packages/app/test/visual/baselines/settings-dark-1280.png) | +| Login | [Reference](../packages/app/test/visual/references/login-dark-1280.png) | [Restored](../packages/app/test/visual/baselines/login-dark-1280.png) | + +### Dark, 390px + +| Screen | Historical reference | Restored React | +| --- | --- | --- | +| Jobs | [Reference](../packages/app/test/visual/references/jobs-dark-390.png) | [Restored](../packages/app/test/visual/baselines/jobs-dark-390.png) | +| Job detail | [Reference](../packages/app/test/visual/references/job-dark-390.png) | [Restored](../packages/app/test/visual/baselines/job-dark-390.png) | +| Editor | [Reference](../packages/app/test/visual/references/editor-dark-390.png) | [Restored](../packages/app/test/visual/baselines/editor-dark-390.png) | +| Run trace | [Reference](../packages/app/test/visual/references/trace-dark-390.png) | [Restored](../packages/app/test/visual/baselines/trace-dark-390.png) | +| Settings | [Reference](../packages/app/test/visual/references/settings-dark-390.png) | [Restored](../packages/app/test/visual/baselines/settings-dark-390.png) | +| Login | [Reference](../packages/app/test/visual/references/login-dark-390.png) | [Restored](../packages/app/test/visual/baselines/login-dark-390.png) | + +Additional baselines cover long content, run-dialog validation, running/failed traces, +empty jobs, settings keys/clients/password, consent, device, app entry, not-found, +chunk recovery, loading/error and search states. + +## Validation + +The visual suite also runs axe WCAG A/AA checks on the six representative screens +in both themes and viewport sizes, plus the search modal. Functional coverage checks +profile disclosure, Escape/focus restoration, search keyboard navigation, invocation +validation/idempotency, stale-write reconciliation, pending/disabled controls, and +bounded 20,000-event trace expansion/focus/selection/reset behavior. + +The real Worker/PostgreSQL browser slice checks direct nested navigation, compiled +warm CSS, decoded bee assets, initial theme, real invocation, trace reset, reconciliation, +and real API-key creation/revocation. No production credentials or live user data are +used, and no production deployment is performed. + +Final command results are recorded in the PR. Browser fixtures and axe are automated +evidence, not a claim of a complete manual assistive-technology audit. + +Validated on the final tree with disposable local PostgreSQL: + +- `npm run check`: passed, including application build/type checking, 26 functional + tests, 36 visual/browser tests (56 reviewed PNG baselines), axe audits, generated + client/package/API boundaries, 324 backend tests, Worker dry-run, hosting/OAuth/ + rollback runtime checks, marketing and relay checks. Eight existing backend tests + remain explicitly skipped by the repository's suite configuration. +- `npm run generate` plus a diff of OpenAPI/generated client: unchanged. +- `npm run test:static-slice --workspace=factorize`: two real Worker/PostgreSQL + browser scenarios passed. +- Historical capture: all 24 reference PNGs regenerated successfully; each trace + fixture renders exactly one copy of each of the four deterministic events. +- `git diff --check`: passed. diff --git a/package-lock.json b/package-lock.json index 1d5e36a7..6ba1e9d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9049,6 +9049,8 @@ "react-markdown": "^10.1.0" }, "devDependencies": { + "@axe-core/playwright": "^4.13.0", + "@playwright/test": "^1.64.0", "@tailwindcss/vite": "4.3.3", "@types/react": "^19.2.0", "@types/react-dom": "^19.2.0", @@ -9433,6 +9435,45 @@ "typescript": "^5.9.3", "wrangler": "^4.44.0" } + }, + "node_modules/@axe-core/playwright": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.13.0.tgz", + "integrity": "sha512-6YLx+kxXu5GJceG4ozFg+33a2EMTdjYwWGloJ3sb9Kta5pp+ZNS53uxGVog5JetIY8s++P5UrtX+cri+u0VAVg==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "axe-core": "~4.13.0" + }, + "peerDependencies": { + "playwright-core": ">= 1.0.0" + } + }, + "node_modules/@playwright/test": { + "version": "1.64.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.0.tgz", + "integrity": "sha512-oTN9FNYuN6bqQMwiho6jJKLCG2/QOYCixGXuCjRmzOq23eODeukuY2XiAVoVpAECbuezMt1MHQjAiQxK8F+Y+g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.64.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/axe-core": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.13.0.tgz", + "integrity": "sha512-UzGt8zg7Ny8djbYMhxl2zuEevVa7r2gJjYY5Lwr1xM7+XU2nd6CkIWFTVcCIbAP63vSz71NaVyyuSk9lHKcy0A==", + "dev": true, + "license": "MPL-2.0", + "engines": { + "node": ">=4" + } } } } diff --git a/packages/api/test/helpers/loading-fixture.ts b/packages/api/test/helpers/loading-fixture.ts index bf98bdd0..780ba664 100644 --- a/packages/api/test/helpers/loading-fixture.ts +++ b/packages/api/test/helpers/loading-fixture.ts @@ -23,7 +23,7 @@ export async function loadingFixture(url: string) { env = { ASSETS: { fetch: async (request: Request) => { const path = new URL(request.url).pathname; if (path !== "/index.html" && !/^\/assets\/[A-Za-z0-9_.-]+$/.test(path)) return new Response("Not found", { status: 404 }); - try { return new Response(request.method === "HEAD" ? null : await readFile(new URL("../../../app/dist" + path, import.meta.url)), { headers: { "Content-Type": path.endsWith(".js") ? "application/javascript" : path.endsWith(".css") ? "text/css" : "text/html" } }); } + try { return new Response(request.method === "HEAD" ? null : await readFile(new URL("../../../app/dist" + path, import.meta.url)), { headers: { "Content-Type": path.endsWith(".js") ? "application/javascript" : path.endsWith(".css") ? "text/css" : path.endsWith(".png") ? "image/png" : path.endsWith(".ico") ? "image/x-icon" : "text/html" } }); } catch { return new Response("Not found", { status: 404 }); } } } as unknown as Fetcher, DATABASE: db, APP_ORIGIN: "https://factorize.test", SESSION_SIGNING_SECRET: "local-test-signing", OAUTH_PROVIDER: { listUserGrants: async () => ({ items: [] }) } as any, CREDENTIAL_ENCRYPTION_KEY: btoa("a".repeat(32)) } as Env; await new IdentityRepository(db, tenantId).upsertOwner(userId, "owner@example.test"); diff --git a/packages/api/test/static-slice.e2e.test.ts b/packages/api/test/static-slice.e2e.test.ts index 3735b3a4..449cfb27 100644 --- a/packages/api/test/static-slice.e2e.test.ts +++ b/packages/api/test/static-slice.e2e.test.ts @@ -31,7 +31,12 @@ describe.skipIf(!url)("compiled React + actual Worker API + PostgreSQL", () => { }); const page = await context.newPage(); page.setDefaultTimeout(10000); page.on("pageerror", error => failures.push(error.message)); await page.goto("https://factorize.test/jobs"); + await page.locator("header img").waitFor(); + expect(await page.locator("header img").evaluate(async (image: any) => { await image.decode(); return image.complete && image.naturalWidth > 0; })).toBe(true); + expect(await page.locator("html").getAttribute("data-theme")).toBe("light"); + expect(await page.locator("body").evaluate((element: any) => (globalThis as any).getComputedStyle(element).backgroundColor)).toBe("rgb(252, 251, 246)"); await page.getByRole("link", { name: "Job-1", exact: true }).click(); + await page.getByRole("button", { name: "Run job", exact: true }).click(); await page.getByLabel("Prompt", { exact: true }).fill("Real invocation"); await page.getByLabel("JSON data (optional)").fill('{"number":7}'); await page.getByRole("button", { name: "Invoke", exact: true }).click(); diff --git a/packages/app/index.html b/packages/app/index.html index 17081567..432aa6a0 100644 --- a/packages/app/index.html +++ b/packages/app/index.html @@ -3,6 +3,7 @@ + Factorize diff --git a/packages/app/package.json b/packages/app/package.json index 2c3a8345..57724cf7 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -6,8 +6,9 @@ "scripts": { "dev": "vite --host 0.0.0.0", "build": "tsc --noEmit && vite build", - "check": "npm run build && npm test", - "test": "node --test test/*.test.mjs" + "check": "npm run build && npm test && npm run test:visual", + "test": "node --test test/*.test.mjs", + "test:visual": "playwright test" }, "dependencies": { "@tanstack/react-query": "5.104.1", @@ -19,6 +20,8 @@ "react-markdown": "^10.1.0" }, "devDependencies": { + "@axe-core/playwright": "^4.13.0", + "@playwright/test": "^1.64.0", "@tailwindcss/vite": "4.3.3", "@types/react": "^19.2.0", "@types/react-dom": "^19.2.0", diff --git a/packages/app/playwright.config.mjs b/packages/app/playwright.config.mjs new file mode 100644 index 00000000..b6a33175 --- /dev/null +++ b/packages/app/playwright.config.mjs @@ -0,0 +1,9 @@ +import { defineConfig } from "@playwright/test"; +export default defineConfig({ + testDir: "./test/visual", testMatch: "*.spec.mjs", + snapshotPathTemplate: "{testDir}/baselines/{arg}{ext}", + workers: 1, fullyParallel: false, + use: { browserName: "chromium", locale: "en-US", timezoneId: "UTC", reducedMotion: "reduce" }, + expect: { toHaveScreenshot: { animations: "disabled", maxDiffPixelRatio: 0.001 } }, + reporter: [["list"]], +}); diff --git a/packages/app/src/assets/bee-mark-monochrome.png b/packages/app/src/assets/bee-mark-monochrome.png new file mode 100644 index 00000000..901bcf4e Binary files /dev/null and b/packages/app/src/assets/bee-mark-monochrome.png differ diff --git a/packages/app/src/assets/favicon.ico b/packages/app/src/assets/favicon.ico new file mode 100644 index 00000000..78257fd0 Binary files /dev/null and b/packages/app/src/assets/favicon.ico differ diff --git a/packages/app/src/features/auth/account-bar.tsx b/packages/app/src/features/auth/account-bar.tsx index 8a50c610..092ae479 100644 --- a/packages/app/src/features/auth/account-bar.tsx +++ b/packages/app/src/features/auth/account-bar.tsx @@ -1,3 +1,6 @@ +import beeMark from "../../assets/bee-mark-monochrome.png"; +import { useEffect, useRef, useState } from "react"; +import { Button } from "../../shared/ui"; import { SearchLauncher } from "../search/launcher"; import { ThemeToggle } from "../../shared/theme"; import { Link } from "@tanstack/react-router"; @@ -15,14 +18,33 @@ export function AccountBar() { await refreshIdentity(); }, }); - if (!session.data?.authenticated) return null; - return ( - - ); + const [open, setOpen] = useState(false); + const menu = useRef(null), trigger = useRef(null); + useEffect(() => { + if (!open) return; + const click = (event: PointerEvent) => { if (!menu.current?.contains(event.target as Node)) setOpen(false); }; + const key = (event: KeyboardEvent) => { if (event.key === "Escape") { setOpen(false); trigger.current?.focus(); } }; + document.addEventListener("pointerdown", click); document.addEventListener("keydown", key); + return () => { document.removeEventListener("pointerdown", click); document.removeEventListener("keydown", key); }; + }, [open]); + const authenticated = session.data?.authenticated; + return
+ Skip to content + + {logout.isError &&

{logout.error.message}

} +
; } diff --git a/packages/app/src/features/auth/auth-screen.tsx b/packages/app/src/features/auth/auth-screen.tsx index 0dad3944..499c4ead 100644 --- a/packages/app/src/features/auth/auth-screen.tsx +++ b/packages/app/src/features/auth/auth-screen.tsx @@ -1,3 +1,4 @@ +import { Button, Input, Label, Page } from "../../shared/ui"; import { useState, type FormEvent } from "react"; import { useMutation } from "@tanstack/react-query"; import { Link, useSearch } from "@tanstack/react-router"; @@ -52,14 +53,14 @@ export function AuthScreen({ mode }: { mode: AuthMode }) { const showEmail = mode !== "password" && mode !== "verify" && !resetCompletion; const showPassword = mode === "login" || mode === "signup" || mode === "password" || resetCompletion; return ( -
- Factorize + +

Your software factory

{titles[mode]}

- {showEmail && } - {mode === "password" && } - {showPassword && <>{mode !== "login" &&

Use 12–200 characters.

}} - {mode === "verify" && !search.token ?

This link has no verification token. Request a new email below.

: } + {showEmail && } + {mode === "password" && } + {showPassword && <>{mode !== "login" &&

Use 12–200 characters.

}} + {mode === "verify" && !search.token ?

This link has no verification token. Request a new email below.

: } {mutation.isError &&

{mutation.error.message}

} {notice &&

{notice}

}
@@ -68,6 +69,6 @@ export function AuthScreen({ mode }: { mode: AuthMode }) { {mode === "login" && <>Create an accountForgot password?} Resend verification -
+ ); } diff --git a/packages/app/src/features/auth/consent.tsx b/packages/app/src/features/auth/consent.tsx index 9f80b7b0..74164a99 100644 --- a/packages/app/src/features/auth/consent.tsx +++ b/packages/app/src/features/auth/consent.tsx @@ -1,3 +1,4 @@ +import { Button, Input, Label, Page } from "../../shared/ui"; import { useState } from "react"; import { useQuery, useMutation } from "@tanstack/react-query"; import { api } from "factorize-api-client"; @@ -7,7 +8,7 @@ export function ConsentScreen() { const preview = useQuery({ queryKey: ["consent", authorizationQuery], queryFn: async ({ signal }) => { const { data, error } = await api.POST("/api/v1/oauth/consent/preview", { signal, body: { authorizationQuery } }); if (!data || error) throw new Error(messageOf(error)); return data; }, staleTime: 0, retry: false }); const decision = useMutation({ retry: false, mutationFn: async (value: "allow" | "deny") => { if (!preview.data) throw new Error("Load the authorization request first."); const { data, error } = await api.POST("/api/v1/oauth/consent/decision", { body: { request: preview.data.request, signature: preview.data.signature, decision: value, scopes: (selected ?? preview.data.scopes) as ("flows:read" | "flows:write" | "runs:read" | "runs:write")[] } }); if (!data || error) throw new Error(messageOf(error)); location.assign(data.redirectTo); } }); const scopes = selected ?? preview.data?.scopes ?? []; - return

Authorize {preview.data?.clientName ?? "a client"}

{preview.isPending &&

Validating authorization request…

}{preview.error &&

{preview.error.message}

} - {preview.data && <>

This client requests access to your workspace. Request expires {preview.data.expiresAt}.

Permissions{preview.data.scopes.map(scope => )}
}{decision.error &&

{decision.error.message}

} -
; + return

Authorize {preview.data?.clientName ?? "a client"}

{preview.isPending &&

Validating authorization request…

}{preview.error &&

{preview.error.message}

} + {preview.data && <>

This client requests access to your workspace. Request expires {preview.data.expiresAt}.

Permissions{preview.data.scopes.map(scope => )}
}{decision.error &&

{decision.error.message}

} +
; } diff --git a/packages/app/src/features/auth/device.tsx b/packages/app/src/features/auth/device.tsx index b8657433..10a25e99 100644 --- a/packages/app/src/features/auth/device.tsx +++ b/packages/app/src/features/auth/device.tsx @@ -1,3 +1,4 @@ +import { Button, Input, Label, Page } from "../../shared/ui"; import { useState } from "react"; import { useNavigate, useSearch } from "@tanstack/react-router"; import { useQuery, useMutation } from "@tanstack/react-query"; @@ -7,9 +8,9 @@ export function DeviceScreen() { const search = useSearch({ strict: false }) as { user_code: string }, navigate = useNavigate(), [code, setCode] = useState(search.user_code); const preview = useQuery({ queryKey: ["device", search.user_code], enabled: !!search.user_code, queryFn: async ({ signal }) => { const { data, error } = await api.POST("/api/v1/oauth/device/preview", { signal, body: { userCode: search.user_code } }); if (!data || error) throw new Error(messageOf(error)); return data; }, staleTime: 0, retry: false }); const decision = useMutation({ retry: false, mutationFn: async (value: "allow" | "deny") => { const { data, error } = await api.POST("/api/v1/oauth/device/decision", { body: { userCode: search.user_code, decision: value } }); if (!data || error) throw new Error(messageOf(error)); return data; } }); - return

Connect a device

{decision.data ?

{decision.data.status === "approved" ? "Device connected" : "Authorization denied"}. You can close this window.

: <> -
{ e.preventDefault(); decision.reset(); void navigate({ to: "/device", search: { user_code: code } }); }}>
- {preview.isFetching &&

Validating device code…

}{preview.data && <>

Authorize {preview.data.clientName}

Permissions: {preview.data.scopes.join(", ")} · Expires {preview.data.expiresAt}

} + return

Connect a device

{decision.data ?

{decision.data.status === "approved" ? "Device connected" : "Authorization denied"}. You can close this window.

: <> +
{ e.preventDefault(); decision.reset(); void navigate({ to: "/device", search: { user_code: code } }); }}>
+ {preview.isFetching &&

Validating device code…

}{preview.data && <>

Authorize {preview.data.clientName}

Permissions: {preview.data.scopes.join(", ")} · Expires {preview.data.expiresAt}

} {[preview.error, decision.error].filter(Boolean).map((error, i) =>

{error?.message}

)}} -
; + ; } diff --git a/packages/app/src/features/jobs/conditions-editor.tsx b/packages/app/src/features/jobs/conditions-editor.tsx index 3f346c78..bfcd9530 100644 --- a/packages/app/src/features/jobs/conditions-editor.tsx +++ b/packages/app/src/features/jobs/conditions-editor.tsx @@ -1,3 +1,4 @@ +import { Label, Textarea, Disclosure, Summary, Button } from "../../shared/ui"; import { useEffect, useRef, useState } from "react"; import { useMutation } from "@tanstack/react-query"; import { api } from "factorize-api-client"; @@ -18,15 +19,15 @@ export function ConditionsEditor({ conditions, onChange }: { conditions: Conditi const { data, error } = await api.POST("/api/v1/job-conditions/test", { body: { conditions: text.trim() ? JSON.parse(text) : undefined, webhook: example as Record } }); if (!data || error) throw new Error(validationMessage(error)); return data; } }); - return