feat: hyperparameter editing UI (auth, edit form, history tab, admin register)#1345
Draft
LandynDev wants to merge 3 commits into
Draft
feat: hyperparameter editing UI (auth, edit form, history tab, admin register)#1345LandynDev wants to merge 3 commits into
LandynDev wants to merge 3 commits into
Conversation
Phase 5.1 + 5.5 of the hyperparam-API UI (greenfield auth):
- src/auth/token.ts: localStorage-backed JWT store (read by the API client
interceptor and AuthContext), failure-tolerant.
- src/auth/AuthContext.tsx: AuthProvider + useAuth. Captures the das post-login
`#token=` redirect fragment, hydrates the user via GET /auth/me, exposes
user/isAuthenticated/isAdmin/loading + login()/logout(). login() redirects to
{API}/auth/github; a 401 clears the session.
- ApiUtils: dedicated `apiClient` axios instance with a Bearer request
interceptor (kept separate from the github/mirror clients so the JWT never
leaks cross-origin); useApiQuery now routes through it; new useApiMutation
helper (auto query invalidation on success).
- ReposApi: write hooks (useUpdateRepositoryConfig, useSetEmissionShare,
useRegisterRepository, useDeleteRepository) + useRepositoryConfigHistory,
plus RepositoryConfigEdit / RepositoryConfigPatch types.
- main.tsx: wrap the app in AuthProvider.
Editable form / admin register form / history tab (5.2-5.4) build on this next.
tsc --noEmit clean.
Phase 5.2: add an auth-gated edit mode to RepositoryHyperparametersTab. - RepositoryHyperparametersEditForm: inputs for the eligibility/scoring/time-decay knob groups + top-level scalars, reusing repoConfig.ts field defs/bounds with client-side validation mirroring das config-validation.ts. Builds a snake_case patch of ONLY changed fields (no-op saves don't burn the 1/day cooldown; defaults don't get frozen into overrides). Nested time_decay is sent whole when any of its knobs change (das merges one level deep). emission_share is admin-only (read-only for maintainers); trusted_label_pipeline + scorable branches editable; optional note recorded in history. Surfaces the API error (403 cooldown / not-a-maintainer). - repoConfig.ts: add TOP_LEVEL_FIELD_DEFS (emission_share, issue_discovery_share, maintainer_cut, default_label_multiplier, fixed_base_score) and a shared validateFieldValue() bounds checker. - Tab shows an Edit button to authenticated users; the server guard enforces real maintainer/admin perms. tsc --noEmit clean.
Completes Phase 5 of the hyperparam-API UI. 5.4 — RepositoryConfigHistoryTab: new "History" tab in RepositoryDetailsPage consuming useRepositoryConfigHistory; renders the audit trail newest-first with actor (maintainer/admin), timestamp, optional note, per-changed-key before->after diff, repo created/deleted lifecycle markers, and a "last edited by … on …" line. Tab key appended so existing tab indices / back-nav stay stable. 5.3 — AdminRegisterRepositoryForm: admin-only direct registration (POST /repos), added to RepositoryRegistrationPage above the public request flow (self-gates on the admin session, so non-admins still see the existing email/App-install flow). fullName owner/repo validation + optional initial config reusing TOP_LEVEL_FIELD_DEFS/validateFieldValue; on success routes to the new repo's hyperparameters tab. tsc --noEmit clean.
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.
Hyperparameter Editing API — UI (Phase 5)
Greenfield GitHub-auth + self-service repository-hyperparameter editing, part of the cross-repo effort to replace the PR→JSON flow with an authed API (das DB as source of truth).
What's in here
src/auth/token.ts(localStorage JWT store),AuthContext/useAuth(captures das's#token=post-login fragment, hydrates viaGET /auth/me, exposesuser/isAuthenticated/isAdmin/loading+login()/logout()), wired inmain.tsx.apiClientaxios instance with a Bearer interceptor (kept separate from the github/mirror clients so the JWT never leaks cross-origin);useApiQueryroutes through it; newuseApiMutationhelper with auto query-invalidation.ReposApi.ts) —useUpdateRepositoryConfig,useSetEmissionShare,useRegisterRepository,useDeleteRepository,useRepositoryConfigHistory.RepositoryHyperparametersTab; reusesrepoConfig.tsfield defs/bounds with client validation mirroring dasconfig-validation.ts; sends a changed-only snake_case patch (no-op saves don't burn the 1/day cooldown; defaults aren't frozen into overrides); nestedtime_decaysent whole (das merges one level deep);emission_shareadmin-only.RepositoryConfigHistoryTab(audit trail, before→after diffs, "last edited by").POST /repos, self-gated to admins, on the registration page alongside the public request flow.repoConfig.ts— addedTOP_LEVEL_FIELD_DEFS+ sharedvalidateFieldValue()(also backs the cross-repo bounds contract test in gt-utils).tsc --noEmitclean.This UI depends on the das API (
entrius/das-gittensor#82) being deployed and Phase 0 OAuth being configured. Do not merge/ship before das is live, or the edit/login UI has no backend. Related: gittensor-db #50, das #82, gittensor #1511 (draft), gt-utils #4.🤖 Generated with Claude Code