Repository navigation
feat(studio): lifecycle and role-aware scoped token view sheet - #48848
Conversation
Extracts the token view sheet slice of #48742 (w3b6x9/scoped-pat-access-feedback, commit 56ef87a). The role-evaluation logic (estimateRoleLevel, computeTokenRoleContext, applySelectionToRoleContext, groupFailingResources) already landed on master via #48805 and #48809 — this PR only wires the view sheet up to it: - Bindings whose project/org was deleted (FGA bindings erased) render a "resources no longer exist" state; bindings the user can no longer reach render an anonymous count with a "No longer accessible" badge and a "removed from" admonition. - Accessible resources list their name plus ref/slug; capabilities show "Exceeds your role" pills and the risk badge reflects what the owner's current role actually allows. - Header split into separate "Access control" and "API docs" buttons. - Everything recomputes from live org/project/permission queries (no stored state) and degrades to no warnings while loading or on self-hosted. Also gives DocsButton an optional `label` prop (defaults preserve existing behavior for every other consumer) so the two header buttons can carry distinct text. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
📝 WalkthroughWalkthrough
ChangesScoped access-token review
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ViewTokenSheet
participant useTokenAccessEvaluation
participant PermissionsAPI
participant OrganizationProjectAPI
participant TokenSummaryRows
ViewTokenSheet->>useTokenAccessEvaluation: token bindings and selected permissions
useTokenAccessEvaluation->>PermissionsAPI: load permissions
useTokenAccessEvaluation->>OrganizationProjectAPI: load organizations and projects
useTokenAccessEvaluation-->>ViewTokenSheet: access evaluation
ViewTokenSheet->>TokenSummaryRows: capability and resource summaries
TokenSummaryRows-->>ViewTokenSheet: warnings and summary rows
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
apps/studio/components/interfaces/Account/AccessTokens/hooks/useCapabilitySummary.ts (1)
47-63: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueType the endpoint pairs as a tuple.
endpoints: string[][]allows any array length. The consumer inViewTokenSheet.tsxline 333 destructures each element as[method, path]. A tuple type documents that contract and catches shape changes at compile time.♻️ Proposed tuple typing
const capabilityGroups = useMemo(() => { - const groups: { entry: PermissionCatalogEntry; mode: PermissionMode; endpoints: string[][] }[] = - [] + const groups: { + entry: PermissionCatalogEntry + mode: PermissionMode + endpoints: [string, string][] + }[] = [] for (const category of activeByCategory) { for (const { entry, mode } of category.entries) { const capabilityScopes = getEntryScopes(entry, mode) const endpoints = getEnabledEndpointsForCapability({ capabilityScopes, allGrantedScopes: grantedScopes, permissionScopeMap, }) if (endpoints.length > 0) { groups.push({ entry, mode, endpoints: endpoints.map((e) => [e.method, e.path]) }) }🤖 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/hooks/useCapabilitySummary.ts` around lines 47 - 63, Update the capabilityGroups type in the useCapabilitySummary memo to declare endpoints as fixed two-element string tuples rather than string[][], preserving the existing [method, path] mapping and its consumer contract.apps/studio/components/interfaces/Account/AccessTokens/Scoped/TokenSummaryRows.tsx (1)
76-78: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDo not derive the risk description by stripping a prefix.
risk.text.replace(${risk.level} —, '')depends on the exact prefix and em dash thatcomputeOverallRiskproduces. If that formatting changes, thereplacesilently does nothing and the level appears twice in the UI, once in theBadgeand once in the text.Expose the description as its own field on
OverallRiskinAccessToken.permissions.tsand render it directly.🤖 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/Scoped/TokenSummaryRows.tsx` around lines 76 - 78, Update the OverallRisk type and computeOverallRisk in AccessToken.permissions.ts to expose the risk description as a dedicated field, then update TokenSummaryRows to render that field directly instead of stripping the level prefix from risk.text. Preserve the existing Badge level rendering and risk text content.
🤖 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/Scoped/TokenSummaryRows.tsx`:
- Line 76: Replace the invalid leading-px class on the TokenSummaryRows text
span with an existing line-height utility such as leading-tight or
leading-normal, preserving the surrounding styling.
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.test.tsx`:
- Around line 69-80: Update the test around renderSheet so negative warning
assertions wait for role evaluation to settle, rather than relying on the
organization query marker. Add a waitFor or assert a rendered capability row
whose content depends on access.entries, then perform the existing queryByText
absence checks after that synchronization point.
---
Nitpick comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/hooks/useCapabilitySummary.ts`:
- Around line 47-63: Update the capabilityGroups type in the
useCapabilitySummary memo to declare endpoints as fixed two-element string
tuples rather than string[][], preserving the existing [method, path] mapping
and its consumer contract.
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/TokenSummaryRows.tsx`:
- Around line 76-78: Update the OverallRisk type and computeOverallRisk in
AccessToken.permissions.ts to expose the risk description as a dedicated field,
then update TokenSummaryRows to render that field directly instead of stripping
the level prefix from risk.text. Preserve the existing Badge level rendering and
risk text content.
🪄 Autofix
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: 6ce73f50-c431-442d-a251-ccd029024ab5
📒 Files selected for processing (10)
apps/studio/components/interfaces/Account/AccessTokens/AccessToken.constants.tsapps/studio/components/interfaces/Account/AccessTokens/AccessToken.fixtures.tsapps/studio/components/interfaces/Account/AccessTokens/AccessToken.permissions.tsapps/studio/components/interfaces/Account/AccessTokens/Scoped/ExceedsRoleBadge.tsxapps/studio/components/interfaces/Account/AccessTokens/Scoped/TokenSummaryRows.tsxapps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.test.tsxapps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsxapps/studio/components/interfaces/Account/AccessTokens/hooks/useCapabilitySummary.tsapps/studio/components/interfaces/Account/AccessTokens/hooks/useTokenAccessEvaluation.tsapps/studio/components/ui/DocsButton.tsx
| <span className="flex"> | ||
| <Badge variant={RISK_TONE_VARIANT[risk.tone]}>{risk.level} Risk</Badge> | ||
| </span> | ||
| <span className="text-sm text-foreground leading-px"> |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether `leading-px` is defined as a custom utility or used elsewhere.
rg -n --glob '!**/node_modules/**' 'leading-px'
fd -t f -e ts -e js 'tailwind.config' | xargs -r rg -n -C4 'lineHeight'Repository: supabase/supabase
Length of output: 155
🏁 Script executed:
#!/bin/bash
set -u
echo "Tracked references to leading-px:"
git grep -n --leading-px || true
echo
echo "Tailwind config files:"
git ls-files | rg '(^|/)(tailwind\.config\.(js|ts|cjs|mjs)|tailwind\.config\.css|globals\.css|global\.css|index\.css)$' | sed -n '1,80p'
echo
echo "CSS/custom config references to lineHeight:'leading-px'/'px'/'px', leading, tight:"
git grep -n "lineHeight\\s*:\\s*['\"]px['\"]" || true
git grep -n "leading-*\\b" | rg '(^| apps/studio/)' | sed -n '1,120p' || trueRepository: supabase/supabase
Length of output: 28955
🏁 Script executed:
#!/bin/bash
set -u
echo "TokenSummaryRows context:"
sed -n '60,85p' apps/studio/components/interfaces/Account/AccessTokens/Scoped/TokenSummaryRows.tsx
echo
echo "Exact leading-px matches in tracked files:"
git grep -n -- 'leading-px' || true
echo
echo "Studio/global/custom Tailwind/config CSS leading/padding/spacing candidates:"
for f in apps/studio/tailwind.config.css apps/studio/tailwind.config.ts apps/studio/tailwind.config.js apps/studio/tailwind.config.cjs apps/ui-library/tailwind.config.css packages/ui/tailwind.config.css packages/ui-patterns/tailwind.config.css packages/common/tailwind.config.css apps/studio/styles/globals.css apps/ui-library/styles/globals.css packages/ui/styles/globals.css; do
if [ -f "$f" ]; then
echo "--- $f"
rg -n -C2 "px|leading|lineHeight|line-height" "$f" || true
fi
done
echo
echo "Any direct `@apply` or CSS variable using px-based leading-like helpers:"
git grep -n "leading-px\\|line-height\\s*:\\s*[0-9]px\\|--leading-px\\|lineHeight\\s*:.*px" || trueRepository: supabase/supabase
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' 'TokenSummaryRows context:'
sed -n '60,85p' apps/studio/components/interfaces/Account/AccessTokens/Scoped/TokenSummaryRows.tsx
printf '%s\n'
printf '%s\n' 'Exact leading-px matches in tracked files:'
git grep -n -- 'leading-px' || true
printf '%s\n'
printf '%s\n' 'Focused Tailwind/CSS candidates for px-based line height utilities:'
for f in apps/studio/tailwind.config.css apps/studio/tailwind.config.ts apps/studio/tailwind.config.js apps/studio/tailwind.config.cjs apps/ui-library/tailwind.config.css packages/ui/tailwind.config.css packages/ui-patterns/tailwind.config.css packages/common/tailwind.config.css apps/studio/styles/globals.css apps/ui-library/styles/globals.css packages/ui/styles/globals.css; do
if [ -f "$f" ]; then
printf '%s\n' "--- $f"
rg -n -C2 "px|leading|lineHeight|line-height" "$f" || true
fi
doneRepository: supabase/supabase
Length of output: 2970
Replace the invalid leading-px utility.
leading-px is not defined in this codebase and is not part of Tailwind’s default line-height scale. Change it to an existing utility such as leading-tight or leading-normal so the text line height is applied.
🤖 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/Scoped/TokenSummaryRows.tsx`
at line 76, Replace the invalid leading-px class on the TokenSummaryRows text
span with an existing line-height utility such as leading-tight or
leading-normal, preserving the surrounding styling.
| renderSheet() | ||
|
|
||
| // Bound org resolves with its name and slug, meaning evaluation completed without warnings. | ||
| expect(await screen.findByText(MOCK_ORG.name)).toBeInTheDocument() | ||
| expect(screen.getByText(MOCK_ORG.slug)).toBeInTheDocument() | ||
| expect(screen.queryByText('Exceeds your role')).toBeNull() | ||
| expect( | ||
| screen.queryByText('Some permissions exceed your current role for the selected resources') | ||
| ).toBeNull() | ||
| expect(screen.queryByText('This token no longer has access')).toBeNull() | ||
| expect(screen.queryByText("This token's resources no longer exist")).toBeNull() | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Make the negative assertions wait for the role evaluation.
findByText(MOCK_ORG.name) resolves when the organizations query settles. The role warnings depend on /platform/profile/permissions, which is a separate query with no ordering guarantee. The queryByText assertions on lines 74-79 can therefore run before the evaluation completes and pass even if a warning would appear later.
Await a marker that only renders after the evaluation completes, then assert the absences. The risk caveat text "Based on what your current role allows this token to do." is one such marker, but it renders only when a permission exceeds the role, so it does not fit this test. A waitFor on the settled state, or an assertion on a rendered capability row that depends on access.entries, is a better anchor.
🤖 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/Scoped/ViewTokenSheet.test.tsx`
around lines 69 - 80, Update the test around renderSheet so negative warning
assertions wait for role evaluation to settle, rather than relying on the
organization query marker. Add a waitFor or assert a rendered capability row
whose content depends on access.entries, then perform the existing queryByText
absence checks after that synchronization point.
Source: Coding guidelines
🎭 Playwright Test Results (next)Details
Flaky testsFeatures › queue-table-operations.spec.ts › Queue Table Operations › pending changes persist when switching between tables Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
Braintrust eval report
|
…for-pitr-archiving-stale * origin/master: (342 commits) feat(studio): role-aware access feedback in scoped token creation (#48858) Initialize notebook editor page (#48842) test(docs): scan changed pages for WCAG 2.1 A/AA in warn mode (#48727) docs(auth): clarify audit logs storage options and configuration (#48852) feat(studio): warn that scoped tokens don't support the MCP server (#48849) feat(studio): lifecycle and role-aware scoped token view sheet (#48848) feat(www): add Open Authorization Integration Addendum (#48804) feat(studio): add legacy token mode to scoped pat creation flow (#48844) Add blog post: Supabase is now a connector on Perplexity Computer (#48776) feat(studio): enforce expiry scoped pat (#48811) fix(studio): model scoped pat permissions as OR-of-AND alternatives - smaller version (#48809) fix(ui): opaque default button hover fills (#48837) fix(ui): restore normal alert text wrapping (#48840) feat: notebook content schema (#48813) fix(ui): remove extra spacing before custom reports section (#48796) feat(marketing): add hint text below Go page form labels (#48824) Initialize notebooks store (#48801) Use white wordmark for QA.tech primary logo (#48827) fix titleless Admonition alignment (#48784) fix inconsistent product menu dividers (#48787) ...
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Extracts the token view sheet slice of #48742 (w3b6x9/scoped-pat-access-feedback, commit 56ef87a). The role-evaluation logic (estimateRoleLevel, computeTokenRoleContext, applySelectionToRoleContext, groupFailingResources) already landed on master via #48805 and #48809 — this PR only wires the view sheet up to it:
Also gives DocsButton an optional
labelprop (defaults preserve existing behavior for every other consumer) so the two header buttons can carry distinct text.Summary by CodeRabbit
New Features
Bug Fixes