Skip to content

fix: treat deprecated scopes as selectable and fix badge count#3035

Merged
HarshMN2345 merged 1 commit intomainfrom
fix-deprecated-scopes-selection
May 8, 2026
Merged

fix: treat deprecated scopes as selectable and fix badge count#3035
HarshMN2345 merged 1 commit intomainfrom
fix-deprecated-scopes-selection

Conversation

@HarshMN2345
Copy link
Copy Markdown
Member

Deprecated scopes were excluded from category toggle and Select All, causing the selected scope count badge to disagree with actual state. Badge count now reads from activeScopes directly instead of effectiveScopes to avoid reactivity lag. Deprecated scopes still display the Deprecated badge for visibility.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 8, 2026

Greptile Summary

This PR fixes two related issues in the API key scopes selector: deprecated scopes were excluded from category-level batch toggling, and the per-category badge count used effectiveScopes (which applies a legacy-to-newer scope remapping) instead of activeScopes directly, causing the badge to lag or miscount.

  • Category toggle fix: removes the !s.deprecated guard from onCategoryChange so deprecated scopes participate in batch select/deselect alongside non-deprecated ones.
  • Badge count fix: switches scopesLength to read activeScopes[n.scope] directly instead of effectiveScopes.includes(n.scope), eliminating the reactivity lag caused by the intermediate getEffectiveScopes transformation.

Confidence Score: 3/5

The badge count fix is correct, but the header checkbox state computed by categoryState still runs through getEffectiveScopes, which can diverge from the new badge count and cause the checkbox to show indeterminate when everything is actually selected.

The categoryState function was not updated alongside the badge-count change. It converts scope IDs with getEffectiveScopes before checking membership, so deprecated scopes whose IDs remap (e.g. collections.read to tables.read) are not found in scopeSet. Now that category toggles include deprecated scopes, a fully-selected category containing such a scope will show indeterminate on the header checkbox. Clicking that checkbox to fix it calls onCategoryChange and silently deselects the whole category.

The single changed file scopes.svelte needs attention, specifically the categoryState function at lines 169–183.

Important Files Changed

Filename Overview
src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte Removes !s.deprecated guard from category toggle and switches badge count from effectiveScopes to activeScopes; fixes badge discrepancy but leaves categoryState using getEffectiveScopes mapping, which can cause the header checkbox to show indeterminate when all scopes (including deprecated) are selected.

Comments Outside Diff (1)

  1. src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte, line 169-183 (link)

    P1 categoryState mismatch after deprecated scope inclusion

    categoryState builds scopeSet via getEffectiveScopes(scopes), which remaps legacy IDs (e.g. collections.readtables.read). After this PR allows batch-toggling deprecated scopes, a user who selects all scopes in a category — including a deprecated one like collections.read — will produce scopes = [..., 'collections.read']. getEffectiveScopes converts that to tables.read, so scopeSet never contains 'collections.read'. When categoryState iterates scopesByCategory and checks scopeSet.has('collections.read'), it returns false, causing activeInCategory.length < scopesByCategory.length and an 'indeterminate' result instead of true. The header checkbox then shows indeterminate; if the user clicks it to "fix" it, onCategoryChange fires and unintentionally deselects everything. The badge count (now reading activeScopes directly) and the header checkbox state will diverge on any category containing deprecated compat-pair scopes.

Reviews (1): Last reviewed commit: "fix: treat deprecated scopes as selectab..." | Re-trigger Greptile

@HarshMN2345 HarshMN2345 merged commit 5ebd8c8 into main May 8, 2026
4 checks passed
@HarshMN2345 HarshMN2345 deleted the fix-deprecated-scopes-selection branch May 8, 2026 11:40
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