From c5b66dc5a006420035f386f5f29dc55659455b42 Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 12 Oct 2026 04:37:48 +0200 Subject: [PATCH] swarm-ui: match the try-out page to the backend's limits The repo check takes the endpoint's own character set and refuses . and .. parts. The running and expired messages say a run can last up to half an hour and that a controller restart drops the result. --- docs/swarm/ui.md | 4 ++-- .../src/pages/review-tryout/ReviewTryOutPage.tsx | 12 +++++++----- .../swarm-ui/src/pages/review-tryout/TryOutTypes.ts | 9 +++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/swarm/ui.md b/docs/swarm/ui.md index 5b7f14ca..34e69c3d 100644 --- a/docs/swarm/ui.md +++ b/docs/swarm/ui.md @@ -55,8 +55,8 @@ Give it a repo as `owner/name` and a PR number, then write a classification: a name, a description, a polarity (positive or negative) and a threshold from 0 to 100. **add a classification** adds more, and **run** starts the run. -A run takes a minute or more. The page says it's running and shows how long it -has been, then shows the review's table: for each classification the verdict, +A run takes a minute or more, and up to half an hour for ten classifications. +The page says it's running and shows how long it has been, then shows the review's table: for each classification the verdict, the model's certainty, the threshold, whether the verdict counted and the reason. A classification that couldn't run shows its error where the reason would be. Under the table are the overall verdict, approve or request changes, diff --git a/frontend/packages/swarm-ui/src/pages/review-tryout/ReviewTryOutPage.tsx b/frontend/packages/swarm-ui/src/pages/review-tryout/ReviewTryOutPage.tsx index 4b353b07..8c134dfa 100644 --- a/frontend/packages/swarm-ui/src/pages/review-tryout/ReviewTryOutPage.tsx +++ b/frontend/packages/swarm-ui/src/pages/review-tryout/ReviewTryOutPage.tsx @@ -31,9 +31,9 @@ import "./ReviewTryOutPage.css"; const TRY_OUT = "/api/review-classifier/try-out"; const POLL_MS = 2000; -// More classifications than this are not offered a row. Keep it in step with -// the try-out endpoint's own cap, which answers a longer list with a 400 that -// the page shows as it is; the backend has no way to report it yet. +// More classifications than this are not offered a row. It is the try-out +// endpoint's own cap, which answers a longer list with a 400 that the page +// shows as it is. const MAX_CLASSIFICATIONS = 10; let nextKey = 0; @@ -88,7 +88,8 @@ export function ReviewTryOutPage() { if (cancelled) return; if (res.status === 404) { stop({ - detail: "the result expired before it was read: run it again", + detail: + "the result is gone, because it expired or the controller restarted: run it again", }); return; } @@ -214,7 +215,8 @@ export function ReviewTryOutPage() { {running ? (

- Running — a run takes a minute or more ({elapsed}s so far). + Running — a run takes a minute or more, and up to half an hour for + a long list ({elapsed}s so far).

) : null} {error ? ( diff --git a/frontend/packages/swarm-ui/src/pages/review-tryout/TryOutTypes.ts b/frontend/packages/swarm-ui/src/pages/review-tryout/TryOutTypes.ts index 3c3a313b..1114448f 100644 --- a/frontend/packages/swarm-ui/src/pages/review-tryout/TryOutTypes.ts +++ b/frontend/packages/swarm-ui/src/pages/review-tryout/TryOutTypes.ts @@ -50,10 +50,15 @@ export interface TryOutResult { error?: string; } -const REPO = /^[^/\s]+\/[^/\s]+$/; +// Characters the endpoint accepts in each half of a repo: letters, digits, `.`, +// `_` and `-`, other than `.` and `..` themselves. +const SEGMENT = /^(?!\.{1,2}$)[A-Za-z0-9._-]+$/; export function repoProblem(repo: string): string | null { - return REPO.test(repo.trim()) ? null : "a repo is owner/name"; + const parts = repo.trim().split("/"); + return parts.length === 2 && parts.every((p) => SEGMENT.test(p)) + ? null + : "a repo is owner/name, with letters, digits, . _ and - in each part"; } export function prNumber(pr: string): number | null {