[FEATURE] - PR2 : Web api - #1197
Open
pulk17 wants to merge 2 commits into
Open
Conversation
pulk17
requested review from
canihavesomecoffee and
thealphadollar
as code owners
September 14, 2026 07:42
Vite + React + TypeScript setup for the web console under web/, with the shared styles, UI primitives and types the pages build on.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



[FEATURE]
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
The typed client for the existing mod_api endpoints. Depends on #1196.
What's here
lib/api.ts is four small fetch helpers (apiGet, apiSend, apiDelete, fetchAll for paginated collections) and then one TanStack Query hook per resource on top - runs, samples, regression tests, artifacts, users, tokens, queue, health, categories, maintenance, tags.
lib/auth.ts is session handling, and it's the part most worth reviewing.
The scope decision
Signing in mints a token via POST /auth/tokens. Rather than always asking for everything, it mints a base set - runs:read, runs:write, results:read, system:read - and only requests the elevated scopes (baselines:write, tokens:manage, system:write) once /auth/me confirms a role that can use them.
That's belt and braces, not a security boundary: the API already rejects those scopes at mint time for anyone else, and the endpoints behind them are admin-only regardless. The point is that a normal user's stored token is boring if it leaks.
The role in the session gates what the UI shows. Every mutation is checked again server-side.
Error handling
apiError() deliberately does not pass server messages through for 401/403/5xx - those get generic copy so backend internals never reach the screen. 4xx validation messages do pass through, because those are written for users. The raw message always goes to the console.
A 401 on any query drops the stored session and returns to sign-in, rather than erroring every query in flight.
Review notes
This is the only file in the console that makes HTTP requests, apart from auth.ts. If it isn't in these two files, it isn't talking to the backend - which makes the API surface easy to audit in one place.
It adds no endpoints and changes no backend behaviour.