Skip to content

feat(ui): maintainer self-serve AI review + BYOK key config (closes #663) - #665

Merged
JSONbored merged 1 commit into
mainfrom
feat/byok-dashboard-ui
Jun 14, 2026
Merged

feat(ui): maintainer self-serve AI review + BYOK key config (closes #663)#665
JSONbored merged 1 commit into
mainfrom
feat/byok-dashboard-ui

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

What

Adds a maintainer-facing AI review & BYOK settings panel to the dashboard (Option A), so maintainers can configure dual-AI review and supply their own Anthropic/OpenAI key entirely from the UI — no direct API calls, no repo secrets.

This is the UI half of the BYOK feature; the backend (config-as-code provider/model + the maintainer self-serve routes) lands in #664.

How

New AiReviewSettings component (rendered under SurfacePreview in the maintainer panel):

  • Repo selector (datalist from the maintainer's reviewable repos).
  • Modeoff / advisory / block (block only blocks on a dual-model consensus defect, confirmed-contributor-only).
  • BYOK toggle + provider (Anthropic/OpenAI) + optional model override.
  • Save configurationPUT /v1/repos/:owner/:repo/ai-review.
  • Provider API key — write-only field → POST /ai-key; status (configured ····last4) via GET /ai-key; DELETE /ai-key to remove.

Security

  • The key is write-only: it is never rendered back into the form. Only the configured flag + last4 + model are ever read (the GET endpoint never returns the secret).
  • All calls are session-scoped via apiFetch with credentials:"include" — the backend enforces maintainer/owner authz per repo.
  • The copy makes the trust model explicit: free Workers AI by default; BYOK runs the advisory write-up on the maintainer's own provider account; consensus blocking always uses the free models.

Verification

  • ui:typecheck
  • ui:lint
  • ui:build

closes #663
part of #525

Depends on #664 (backend routes).

Add an AI review & BYOK settings panel to the maintainer dashboard so
maintainers can configure dual-AI review and supply their own
Anthropic/OpenAI key without touching the API directly.

- New AiReviewSettings component: repo selector, mode (off/advisory/block),
  BYOK toggle, provider + optional model, and a write-only provider-key
  field (POST/GET-status/DELETE). The key is never rendered back — only the
  configured/last4 status is read.
- Wires PUT /v1/repos/:owner/:repo/ai-review and the /ai-key routes via
  apiFetch with credentials:"include" (session-scoped maintainer authz).
- Renders under SurfacePreview in the maintainer panel.

closes #663, part of #525
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@ghost

ghost commented Jun 14, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #665 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 689dc6e Commit Preview URL

Branch Preview URL
Jun 14 2026, 01:01 AM

@JSONbored
JSONbored merged commit 1908233 into main Jun 14, 2026
11 checks passed
@JSONbored
JSONbored deleted the feat/byok-dashboard-ui branch June 14, 2026 01:01
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 14, 2026
@ghost

ghost commented Jun 14, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 2 changed file(s) — two independent AI reviewers.

Suggested action: 🛠️ Request changes. (reviewers split: merge / request changes) Address the suggestions below before merging.

Reviewer A · gpt-oss-120b — recommends ✅ merge
This PR adds a new AiReviewSettings panel allowing maintainers to configure AI review mode and BYOK provider keys, and integrates it into the MaintainerPanel. The implementation follows project conventions, respects the public/private boundary, and includes basic UI and error handling.

Suggestions

  • Add unit/integration tests for the new AiReviewSettings component to verify loading, saving, and key management flows.
  • Consider disabling the Provider/Model fields when the BYOK checkbox is unchecked to avoid confusing users.
  • Document the new /ai-review and /ai-key API endpoints (if not already) to ensure they enforce proper authentication and encryption.

Worth double-checking

  • If the backend /ai-key endpoint does not correctly encrypt and never logs the key, the provider key could be exposed.
  • The new UI may affect layout on smaller screens; verify responsive behavior.

Reviewer B · mistral-small-3.1-24b-instruct — recommends 🛠️ request changes
This PR adds a new 'AI review & BYOK' settings panel for maintainers to configure AI review modes and provider keys. The implementation is clean and follows the project's conventions. The UI is accessible and responsive.

Suggestions

  • Consider adding a test to ensure the AI review settings are correctly saved and retrieved.
  • Add a loading state or spinner when fetching the initial settings to improve UX.
  • Ensure the repoFullName input has proper validation to prevent invalid repository names.

Worth double-checking

  • Verify that the API endpoints for saving and retrieving AI review settings are secure and properly authenticated.
  • Check that the provider keys are stored securely and not exposed in any logs or public outputs.
  • Ensure that the AI review modes and provider keys are correctly applied to the PR review process.

Warning

Could not capture a preview of the changed route(s) — review the rendered page manually before merging.

Before = production · After = this PR's preview deploy.

Route Viewport Before After
/ desktop before desktop after desktop
mobile before mobile after mobile

@ghost ghost added the gittensory-review label Jun 14, 2026
JSONbored added a commit that referenced this pull request Jun 14, 2026
…-only panel guard, key validation) (#670)

Follow-up hardening from a security/completeness audit of the BYOK feature
(PRs #664/#665). The panel was already maintainer-only via the backend gate;
these changes close the confirmed gaps.

Backend:
- Bound the BYOK provider fetch with AbortSignal.timeout (20s), mirroring the
  github/gittensor timeoutFetch convention, so a hung Anthropic/OpenAI
  connection can't stall the queue worker. Surface the failure reason
  (timeout/http_error/exception) in the ai_usage_events audit metadata for
  observability — never any key material.
- Classify POST/DELETE /ai-key and PUT /ai-review as "expensive" in
  routeClassForPath (POST /ai-key runs PBKDF2 100k iters + an encrypted upsert).
- Enforce the provider/key prefix check the schema comment already described:
  Anthropic keys must start with sk-ant-, OpenAI with sk- (and not sk-ant-),
  so a mismatched key is rejected with a 400 instead of failing silently later.

Frontend:
- Add an explicit maintainer/owner/operator role gate to MaintainerPanel via
  useSession, so the dashboard query and the BYOK form never mount for a
  non-maintainer (the backend 403 remains the source of truth) and a clean
  "Maintainer access required" message replaces the raw 403.
- Mirror the provider/key prefix validation client-side for instant feedback.

Tests: provider-fetch timeout signal + recorded failure reason, rate-limit
classification, and provider/key mismatch rejection (400). Branch coverage 97%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

BYOK AI review: dashboard settings UI for AI review + provider key (Option A)

1 participant