Skip to content

feat(dashboard): scoped-key permissions UI, OAuth consent screen, MCP connect#225

Merged
duyet merged 1 commit into
mainfrom
claude/dashboard-scoped-keys-oauth-ui
Jun 18, 2026
Merged

feat(dashboard): scoped-key permissions UI, OAuth consent screen, MCP connect#225
duyet merged 1 commit into
mainfrom
claude/dashboard-scoped-keys-oauth-ui

Conversation

@duyet

@duyet duyet commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Wave 1 — Dashboard UI for the MCP/OAuth/scoped-keys feature

Builds on the merged backend (scoped keys #221, OAuth #223, MCP #224, docs #222).

U4 — Key-permissions UI

  • The "New Key" form now has a Full access (default, one-click) vs Custom permission selector with a grouped scope checklist mirroring the API API_SCOPES taxonomy.
  • The keys table shows a Permissions column — per-key scope badges, or a "Full access" pill for unscoped keys.
  • The create action sends scopes (omitted for full access).

U3 — OAuth consent screen (/oauth/consent)

  • Clerk-gated React island. Reads the OAuth /authorize query params, shows the requesting client (redirect host), the requested scopes as badges, and a project selector (the token is project-scoped).
  • Approve/Deny POST to /api/oauth/authorize/decision (Clerk cookie) and follow the returned { redirect }.

U5 — Connect via MCP

  • New section on the Integrate page: the hosted MCP URL (https://agentstate.app/api/mcp) with copyable mcp.json snippets for token auth and OAuth.

Shared

  • src/lib/scopes.ts — dashboard scope catalog + scopeLabel() (handles * / resource:*), reused by the key form and consent screen.

Verification

  • bun run build ✅ (all 14 pages incl. new /oauth/consent); Biome clean on changed files.

Co-Authored-By: Duyet Le [email protected]
Co-Authored-By: duyetbot [email protected]

… connect

- API key creation: "Full access" (default) vs "Custom" permission selector with
  a grouped scope checklist; keys table shows per-key permission badges
- New OAuth consent screen at /oauth/consent (Clerk-gated): shows the requesting
  client, requested scopes, and a project selector; Approve/Deny POSTs to
  /api/oauth/authorize/decision and follows the returned redirect
- Integrate page: "Connect via MCP" section with the hosted MCP URL and config
  snippets for token auth and OAuth
- Shared dashboard scope catalog (src/lib/scopes.ts) mirroring the API taxonomy

Co-Authored-By: Duyet Le <[email protected]>
Co-Authored-By: duyetbot <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @duyet, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@duyet, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 22 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0487fe45-4a3e-442c-a97b-1198e6cf9c0e

📥 Commits

Reviewing files that changed from the base of the PR and between 8c7932d and 289d836.

📒 Files selected for processing (8)
  • packages/dashboard/src/components/dashboard/integrate/integrate-content.tsx
  • packages/dashboard/src/components/dashboard/project/_api-keys-table.tsx
  • packages/dashboard/src/components/dashboard/project/_keys-tab.tsx
  • packages/dashboard/src/components/dashboard/project/_use-key-actions.ts
  • packages/dashboard/src/components/dashboard/project/project-content.tsx
  • packages/dashboard/src/components/oauth/consent-screen.tsx
  • packages/dashboard/src/lib/scopes.ts
  • packages/dashboard/src/pages/oauth/consent.astro
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dashboard-scoped-keys-oauth-ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Model Context Protocol (MCP) integration instructions, adds granular permission scope selection when creating API keys, and implements an OAuth consent screen for authorizing third-party application access to projects. The review feedback focuses on optimizing the consent screen by initializing URL parameters directly in state, adding a cleanup flag to prevent state updates on unmounted components, and omitting the project ID when denying authorization. Additionally, suggestions were made to improve keyboard accessibility in the key creation form and to make the scope labeling utility more robust against malformed scope strings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +28 to +37
const [params, setParams] = useState<URLSearchParams | null>(null);
const [projects, setProjects] = useState<ProjectItem[]>([]);
const [projectId, setProjectId] = useState("");
const [loadingProjects, setLoadingProjects] = useState(true);
const [submitting, setSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
setParams(new URLSearchParams(window.location.search));
}, []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since ConsentScreen is rendered with client:only="react" in Astro, it is guaranteed to run only on the client side. Therefore, window is always defined during the initial render. We can initialize params directly in useState to avoid an unnecessary state update and double-render on mount. Using a fallback check for typeof window also ensures safety during any static analysis or build-time checks.

  const [params] = useState<URLSearchParams>(
    () => new URLSearchParams(typeof window !== "undefined" ? window.location.search : "")
  );
  const [projects, setProjects] = useState<ProjectItem[]>([]);
  const [projectId, setProjectId] = useState("");
  const [loadingProjects, setLoadingProjects] = useState(true);
  const [submitting, setSubmitting] = useState(false);
  const [error, setError] = useState<string | null>(null);

Comment on lines +39 to +48
useEffect(() => {
if (!isSignedIn) return;
api<{ data: ProjectItem[] }>("/v1/projects")
.then((res) => {
setProjects(res.data);
if (res.data[0]) setProjectId(res.data[0].id);
})
.catch((e: unknown) => setError(e instanceof Error ? e.message : "Failed to load projects"))
.finally(() => setLoadingProjects(false));
}, [isSignedIn]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential memory leaks and state updates on an unmounted component, add a cleanup flag to the useEffect hook.

  useEffect(() => {
    if (!isSignedIn) return;
    let active = true;
    api<{ data: ProjectItem[] }>("/v1/projects")
      .then((res) => {
        if (!active) return;
        setProjects(res.data);
        if (res.data[0]) setProjectId(res.data[0].id);
      })
      .catch((e: unknown) => {
        if (!active) return;
        setError(e instanceof Error ? e.message : "Failed to load projects");
      })
      .finally(() => {
        if (!active) return;
        setLoadingProjects(false);
      });
    return () => {
      active = false;
    };
  }, [isSignedIn]);

Comment on lines +96 to +109
const res = await api<{ redirect: string }>("/oauth/authorize/decision", {
method: "POST",
body: JSON.stringify({
approve,
client_id: clientId,
redirect_uri: redirectUri,
scopes,
code_challenge: codeChallenge,
code_challenge_method: codeChallengeMethod,
state,
resource,
project_id: projectId,
}),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When denying authorization (approve is false), sending project_id is unnecessary and could be empty/invalid. It is cleaner to only include project_id in the payload when the request is approved.

Suggested change
const res = await api<{ redirect: string }>("/oauth/authorize/decision", {
method: "POST",
body: JSON.stringify({
approve,
client_id: clientId,
redirect_uri: redirectUri,
scopes,
code_challenge: codeChallenge,
code_challenge_method: codeChallengeMethod,
state,
resource,
project_id: projectId,
}),
});
const res = await api<{ redirect: string }>("/oauth/authorize/decision", {
method: "POST",
body: JSON.stringify({
approve,
client_id: clientId,
redirect_uri: redirectUri,
scopes,
code_challenge: codeChallenge,
code_challenge_method: codeChallengeMethod,
state,
resource,
...(approve ? { project_id: projectId } : {}),
}),
});

Comment on lines +136 to +141
onKeyDown={(e) => {
if (e.key === "Enter" && mode === "full") {
e.preventDefault();
submit();
}
}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Disabling Enter key submission when mode === "custom" is an unnecessary restriction for keyboard users. We can allow Enter key submission in both modes as long as the form is valid (i.e., not empty in custom mode).

Suggested change
onKeyDown={(e) => {
if (e.key === "Enter" && mode === "full") {
e.preventDefault();
submit();
}
}}
onKeyDown={(e) => {
if (e.key === "Enter" && !customEmpty) {
e.preventDefault();
submit();
}
}}

Comment on lines +85 to +90
export function scopeLabel(scope: string): string {
if (scope === "*") return "Full access";
const [resource, action] = scope.split(":");
if (action === "*") return `${resource} (all)`;
return `${resource}:${action}`;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If a scope string does not contain a colon (e.g., a malformed or custom scope), action will be undefined, resulting in a label like "resource:undefined". Adding a fallback for when action is missing makes the helper more robust.

Suggested change
export function scopeLabel(scope: string): string {
if (scope === "*") return "Full access";
const [resource, action] = scope.split(":");
if (action === "*") return `${resource} (all)`;
return `${resource}:${action}`;
}
export function scopeLabel(scope: string): string {
if (scope === "*") return "Full access";
const [resource, action] = scope.split(":");
if (!action) return resource;
if (action === "*") return resource + " (all)";
return resource + ":" + action;
}

@duyet duyet merged commit 985de3d into main Jun 18, 2026
6 checks passed
@duyet duyet deleted the claude/dashboard-scoped-keys-oauth-ui branch June 18, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant