Skip to content

Scoped PAT: View token permissions - #48003

Merged
djhi merged 11 commits into
scopedpat/root-branchfrom
scopedpat/view-permissions
Jul 29, 2026
Merged

djhi merged 11 commits into
scopedpat/root-branchfrom
scopedpat/view-permissions

Conversation

@djhi

@djhi djhi commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Third stacked PR for scoped PAT extracted from the prototype #47783 to ease reviewing.
Previous stacked PR is #47979
Next stacked PR is #47999

This PR add a way to view the tokens permissions

Summary by CodeRabbit

  • New Features

    • Added a “View permissions” option for scoped access tokens.
    • Scoped token permissions now open in a dedicated viewing panel.
    • Scoped token support is enabled by default.
  • Bug Fixes

    • Improved token deletion confirmation to clearly identify the selected token.
    • Deletion dialogs now close correctly after successful removal.

@djhi
djhi requested a review from a team as a code owner July 16, 2026 13:02
@supabase

supabase Bot commented Jul 16, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@vercel

vercel Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Jul 29, 2026 8:53am
studio-staging Ready Ready Preview, Comment Jul 29, 2026 8:53am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 29, 2026 8:53am
design-system Skipped Skipped Jul 29, 2026 8:53am
docs Skipped Skipped Jul 29, 2026 8:53am
ui-library Skipped Skipped Jul 29, 2026 8:53am
zone-www-dot-com Skipped Skipped Jul 29, 2026 8:53am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7fc28fa9-819e-47cb-aa3c-4b446ec20171

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

AccessTokenList now supports viewing permissions for scoped tokens and uses selected-token state for deletion confirmation across classic and scoped tokens. The component also defaults scopedTokensEnabled to true.

Changes

Access token actions

Layer / File(s) Summary
Token selection and deletion state
apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx
Deletion confirmation and mutation handling now use tokenToDelete, dispatching by token kind and clearing the selection after success or close.
Scoped-token permissions action
apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx
Scoped-token menus include a “View permissions” action that opens ViewTokenSheet for the selected token.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • supabase/supabase#48384: Updates the same access-token component with related scoped-token actions and selection state.

Suggested reviewers: awaseem

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too brief and misses the required template sections like change type, current behavior, new behavior, and additional context. Add the template sections, including YES/NO for CONTRIBUTING.md, change type, current behavior, new behavior, and any relevant issues or screenshots.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: viewing token permissions for scoped PATs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scopedpat/view-permissions

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.

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  3 minutes, 49 seconds
commit  e1116a4

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

retryDelay: 1000,
}
)
console.log({ token })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rouge Console!

@djhi
djhi requested a review from awaseem July 17, 2026 14:31
Base automatically changed from scopedpat/scoped-token-creation-sheet to scopedpat/root-branch July 28, 2026 13:41
@djhi
djhi requested a review from a team as a code owner July 28, 2026 13:41
djhi added a commit that referenced this pull request Jul 28, 2026
Second stacked PR for scoped PAT extracted from the prototype #47783 to
ease reviewing.
Previous stacked PR is #47886
Next stacked PR is #48003

This PR:
- refactor the scoped token creation form in a multi-step fashion

## How to test

Go to
https://studio-staging-git-scopedpat-scoped-token-creat-80c55b-supabase.vercel.app/dashboard/account/tokens

- Click the _Generate new token_ button
- Try submitting immediately. It should display errors correctly
- Configure everything except permissions and try submitting. It should
display a warning about missing permissions
- Configure the permissions and submit. It should display the review
step
- Try going back, modify anything and submit

- Create the token. It should display the token value with a button to
copy it and a checkbox to confirm the copy. You cannot close the sheet
at this step until you check the box and click _Done_.
@djhi

djhi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx (1)

90-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Preserve the token-kind/ID relationship instead of casting.

Define MergedAccessToken as a discriminated union and let the kind branch narrow id before dispatching. The current casts suppress type checking and can hide mismatches if either token shape changes.

As per coding guidelines, avoid TypeScript as casts and model multi-state values as discriminated unions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx`
around lines 90 - 92, Update MergedAccessToken to a discriminated union keyed by
kind, with classic tokens carrying a numeric id and scoped tokens carrying a
string id. In the tokenToDelete branch, use the kind check to narrow id
naturally before calling deleteClassicToken or deleteScopedToken, and remove
both TypeScript casts.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx`:
- Around line 39-50: Update AccessTokenList and useMergedAccessTokens so
scoped-token request failures are propagated through the hook and rendered by
the list before keeping scopedTokensEnabled defaulted to true; otherwise restore
the default to opt-in until scoped errors are handled. Ensure failures do not
produce a partial list or “No access tokens found” state.

---

Nitpick comments:
In `@apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx`:
- Around line 90-92: Update MergedAccessToken to a discriminated union keyed by
kind, with classic tokens carrying a numeric id and scoped tokens carrying a
string id. In the tokenToDelete branch, use the kind check to narrow id
naturally before calling deleteClassicToken or deleteScopedToken, and remove
both TypeScript casts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dbdee218-e023-41fb-974c-af4cbc2e6a31

📥 Commits

Reviewing files that changed from the base of the PR and between bccc18a and 6453f33.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Account/AccessTokens/AccessTokenList.tsx

@djhi
djhi merged commit eb4aafa into scopedpat/root-branch Jul 29, 2026
27 checks passed
@djhi
djhi deleted the scopedpat/view-permissions branch July 29, 2026 09:23
djhi added a commit that referenced this pull request Jul 29, 2026
Fourth stacked PR for scoped PAT extracted from the prototype #47783 to
ease reviewing.
Previous stacked PR is #48003
Next stacked PR is #48002

This PR:
- fix some accessibility issues
- add unit tests

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Added coverage for creating scoped access tokens at the project,
organization, and account levels.
* Verified validation for required fields, successful token creation,
clipboard copying, and completion flow.

* **Chores**
* Added temporary browser console logging when viewing a scoped access
token.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants