Skip to content

Improve OAuth2 consent screen UX#3116

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat-oauth2-consent-improvements
Jul 11, 2026
Merged

Improve OAuth2 consent screen UX#3116
ChiragAgg5k merged 2 commits into
mainfrom
feat-oauth2-consent-improvements

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

  • Recognize both hosted MCP resource URIs (https://mcp.appwrite.io and https://mcp.appwrite.io/mcp) so grants with either audience get the MCP-specific consent screen
  • Add missing descriptions for the Organization and Organization memberships scopes
  • Make the Projects and Organizations permission lists collapsible (open by default)
  • Paginate the project and organization pickers with infinite scroll instead of a fixed result cap
  • Remove the per-scope copy buttons
  • Allow switching accounts from the consent screen via a dropdown on the account chip

Screenshots

MCP consent with account chip

01-mcp-consent-and-switch-account

Account menu (switch account)

Clicking the account chip opens a menu with the current account and a "Use a different account" action, which signs out and restarts the OAuth request from login.

08-account-menu-open

09-switch-account-login

Collapsible permission groups

Projects expanded with Organizations collapsed (MCP narrowing editor):

02-custom-permissions-projects-open-organizations-collapsed

Read-only permission view with both groups collapsed:

07-project-and-organization-permissions-collapsed

Organization scope descriptions

06-organization-permission-descriptions

Project / organization pickers with infinite scroll

First page of results:

03-project-picker-first-page

After scrolling (next page loaded):

04-project-picker-after-infinite-scroll

05-organization-picker-after-infinite-scroll

Test plan

  • Authorize an MCP client whose token audience is https://mcp.appwrite.io/ and verify the MCP consent screen (narrowing editor) renders
  • Collapse/expand the Projects and Organizations permission lists
  • Scroll the project and organization pickers past the first page and verify more results load
  • Switch accounts from the consent screen and verify the OAuth request resumes after signing in with the other account
  • Verify device flow consent still renders (no switch-account menu)

Made with Cursor

Recognize both hosted MCP resource URIs, add missing organization scope
descriptions, make permission groups collapsible, paginate project and
organization pickers with infinite scroll, remove per-scope copy buttons,
and add account switching via a dropdown on the account chip.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves the OAuth2 consent screen UX across several dimensions: it recognizes both https://mcp.appwrite.io and https://mcp.appwrite.io/mcp as MCP resource URIs, replaces the fixed 8-result caps with infinite-scroll pagination for the project and organization pickers, makes the Projects/Organizations permission lists collapsible, adds missing scope descriptions, removes per-scope copy buttons, and wires up an account-switch dropdown that logs out and replays the original authorize request with the new account.

  • Pagination (searchProjects, searchOrganizations): Projects use a limit+1 sentinel across sequential org queries to detect hasMore; organizations use the API's total field. The offset-tracking logic across multiple orgs in searchProjects is correct, including the edge cases where an org is exhausted mid-page or errors silently.
  • Account switching: The original authorize URL is stored in sessionStorage keyed by request_urigrant_id, propagated through every phase transition, and used to restart the flow after logout; the chain correctly handles the PAR → grant URL rewrite step.
  • Collapsible groups: Toggle state is stored as undefined (open default) / false (closed) / true (explicitly reopened) and the render check !== false correctly treats both undefined and true as open.

Confidence Score: 5/5

Safe to merge — the changes are additive UX improvements with no mutations to auth logic or grant approval paths.

All three core additions (pagination, collapsible groups, account switching) were traced end-to-end and the logic holds. The sessionStorage propagation chain through PAR → request_uri → grant_id is correct, the multi-org offset arithmetic in searchProjects handles boundary cases properly, and the loadingMore guard in the infinite-scroll component prevents duplicate fetches.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/helpers/oauth2-authorization-details.ts Replaces SEARCH_LIMIT+client-side search with paginated searchProjects/searchOrganizations; pagination logic across multiple orgs is correct using limit+1 detection for projects and orgs.total for organizations
src/lib/helpers/oauth2-mcp.ts Adds the bare https://mcp.appwrite.io host to DEFAULT_MCP_RESOURCE_URLS so grants with either audience variant get the MCP consent screen
src/lib/helpers/oauth2-scopes.ts Adds descriptions for organization and organization.memberships scopes, and marks Projects/Organizations permission groups as collapsible
src/routes/(public)/oauth2/consent-card.svelte Removes per-scope copy buttons, adds collapsible permission groups, and adds account-switch dropdown; pointer/keyboard dismiss handlers use a try/finally cleanup pattern via Svelte effect
src/routes/(public)/oauth2/consent/+page.svelte Adds switchAccount flow: resume URL is stored in sessionStorage keyed by grant/request_uri/authorize URL and propagated through every phase transition, logout+goSignIn replays the original authorize request with the new account
src/routes/(public)/oauth2/resource-selector.svelte Replaces fixed-result find() with paginated find(term, offset, limit); infinite-scroll guard (loadingMore + hasMore) is correct, and loadMore is also triggered when adding an item reduces visible suggestions

Reviews (2): Last reviewed commit: "Address Greptile review" | Re-trigger Greptile

Comment thread src/routes/(public)/oauth2/consent-card.svelte Outdated
Comment thread src/lib/helpers/oauth2-authorization-details.ts Outdated
Comment thread src/routes/(public)/oauth2/resource-selector.svelte
Replace heading-string matching with an explicit collapsible flag on
PermissionGroup, use startsWith instead of full-text search for the
organization picker, and reset loadingMore via finally on stale-term
early returns.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ChiragAgg5k
ChiragAgg5k merged commit b584206 into main Jul 11, 2026
4 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat-oauth2-consent-improvements branch July 11, 2026 11:35
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