Watch
0
0
Fork
You've already forked hyperhive
0

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.
This commit is contained in:
iris 2026-10-12 04:37:48 +02:00 • committed by mara
commit c5b66dc5a0
3 changed files with 16 additions and 9 deletions

View file

@ -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 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. 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 A run takes a minute or more, and up to half an hour for ten classifications.
has been, then shows the review's table: for each classification the verdict, 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 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 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, would be. Under the table are the overall verdict, approve or request changes,

View file

@ -31,9 +31,9 @@ import "./ReviewTryOutPage.css";
const TRY_OUT = "/api/review-classifier/try-out"; const TRY_OUT = "/api/review-classifier/try-out";
const POLL_MS = 2000; const POLL_MS = 2000;
// More classifications than this are not offered a row. Keep it in step with // More classifications than this are not offered a row. It is the try-out
// the try-out endpoint's own cap, which answers a longer list with a 400 that // endpoint's own cap, which answers a longer list with a 400 that the page
// the page shows as it is; the backend has no way to report it yet. // shows as it is.
const MAX_CLASSIFICATIONS = 10; const MAX_CLASSIFICATIONS = 10;
let nextKey = 0; let nextKey = 0;
@ -88,7 +88,8 @@ export function ReviewTryOutPage() {
if (cancelled) return; if (cancelled) return;
if (res.status === 404) { if (res.status === 404) {
stop({ 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; return;
} }
@ -214,7 +215,8 @@ export function ReviewTryOutPage() {
<Panel title="result" icon="📋"> <Panel title="result" icon="📋">
{running ? ( {running ? (
<p class="ui-tryout-running" role="status"> <p class="ui-tryout-running" role="status">
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).
</p> </p>
) : null} ) : null}
{error ? ( {error ? (

View file

@ -50,10 +50,15 @@ export interface TryOutResult {
error?: string; 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 { 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 { export function prNumber(pr: string): number | null {