From fd020af6fd229d0763163757b0e7e28f4fef80f8 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 11 Jul 2026 11:25:25 +0530 Subject: [PATCH] Address Greptile review 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 --- .../helpers/oauth2-authorization-details.ts | 4 +++- src/lib/helpers/oauth2-scopes.ts | 4 ++++ .../(public)/oauth2/consent-card.svelte | 4 +--- .../(public)/oauth2/resource-selector.svelte | 23 +++++++++++-------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/lib/helpers/oauth2-authorization-details.ts b/src/lib/helpers/oauth2-authorization-details.ts index 367d3d3d2..3d6caf744 100644 --- a/src/lib/helpers/oauth2-authorization-details.ts +++ b/src/lib/helpers/oauth2-authorization-details.ts @@ -287,7 +287,9 @@ export async function searchOrganizations( try { const queries = [Query.offset(offset), Query.limit(limit)]; const trimmed = term.trim(); - if (trimmed !== '') queries.push(Query.search('name', trimmed)); + // startsWith over search: search is full-text (word-boundary) matching, + // which drops partial-fragment matches; this mirrors the project search. + if (trimmed !== '') queries.push(Query.startsWith('name', trimmed)); const orgs = await getTeamOrOrganizationList(queries); return { diff --git a/src/lib/helpers/oauth2-scopes.ts b/src/lib/helpers/oauth2-scopes.ts index 2775ce7fe..9cc3554bb 100644 --- a/src/lib/helpers/oauth2-scopes.ts +++ b/src/lib/helpers/oauth2-scopes.ts @@ -476,6 +476,8 @@ export interface PermissionGroup { heading: string; /** Contextual note under the heading, e.g. which resources it applies to. */ note?: string; + /** Whether the consent screen lets the user collapse this group. */ + collapsible?: boolean; lines: PermissionLine[]; } @@ -666,6 +668,7 @@ export function buildConsentPermissions(model: ConsentScopeModel): PermissionGro groups.push({ heading: 'Projects', note: 'Applies only to the projects you select below.', + collapsible: true, lines: projectLines }); } @@ -680,6 +683,7 @@ export function buildConsentPermissions(model: ConsentScopeModel): PermissionGro groups.push({ heading: 'Organizations', note: 'Applies only to the organizations you select below.', + collapsible: true, lines: organizationLines }); } diff --git a/src/routes/(public)/oauth2/consent-card.svelte b/src/routes/(public)/oauth2/consent-card.svelte index d91a7bca3..68018bb10 100644 --- a/src/routes/(public)/oauth2/consent-card.svelte +++ b/src/routes/(public)/oauth2/consent-card.svelte @@ -686,9 +686,7 @@ {#if showPermissions}
{#each permissionGroups as group (group.heading)} - {@const collapsible = - group.heading === 'Projects' || - group.heading === 'Organizations'} + {@const collapsible = group.collapsible === true}
{#if collapsible} diff --git a/src/routes/(public)/oauth2/resource-selector.svelte b/src/routes/(public)/oauth2/resource-selector.svelte index 510b9b5d1..1f458097c 100644 --- a/src/routes/(public)/oauth2/resource-selector.svelte +++ b/src/routes/(public)/oauth2/resource-selector.svelte @@ -112,17 +112,20 @@ const currentTerm = term; const offset = results.length; loadingMore = true; - const page = await find(currentTerm, offset, PAGE_SIZE); - if (currentTerm !== term) return; + try { + const page = await find(currentTerm, offset, PAGE_SIZE); + if (currentTerm !== term) return; - const seen = new Set(results.map((resource) => resource.id)); - const next = page.resources.filter((resource) => !seen.has(resource.id)); - results = [...results, ...next]; - hasMore = page.hasMore; - const merged = { ...names }; - for (const resource of next) merged[resource.id] = resource; - names = merged; - loadingMore = false; + const seen = new Set(results.map((resource) => resource.id)); + const next = page.resources.filter((resource) => !seen.has(resource.id)); + results = [...results, ...next]; + hasMore = page.hasMore; + const merged = { ...names }; + for (const resource of next) merged[resource.id] = resource; + names = merged; + } finally { + loadingMore = false; + } } function handleResultsScroll(event: Event) {