Skip to content

Commit fd020af

Browse files
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 <cursoragent@cursor.com>
1 parent c7905b4 commit fd020af

4 files changed

Lines changed: 22 additions & 15 deletions

File tree

src/lib/helpers/oauth2-authorization-details.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ export async function searchOrganizations(
287287
try {
288288
const queries = [Query.offset(offset), Query.limit(limit)];
289289
const trimmed = term.trim();
290-
if (trimmed !== '') queries.push(Query.search('name', trimmed));
290+
// startsWith over search: search is full-text (word-boundary) matching,
291+
// which drops partial-fragment matches; this mirrors the project search.
292+
if (trimmed !== '') queries.push(Query.startsWith('name', trimmed));
291293

292294
const orgs = await getTeamOrOrganizationList(queries);
293295
return {

src/lib/helpers/oauth2-scopes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ export interface PermissionGroup {
476476
heading: string;
477477
/** Contextual note under the heading, e.g. which resources it applies to. */
478478
note?: string;
479+
/** Whether the consent screen lets the user collapse this group. */
480+
collapsible?: boolean;
479481
lines: PermissionLine[];
480482
}
481483

@@ -666,6 +668,7 @@ export function buildConsentPermissions(model: ConsentScopeModel): PermissionGro
666668
groups.push({
667669
heading: 'Projects',
668670
note: 'Applies only to the projects you select below.',
671+
collapsible: true,
669672
lines: projectLines
670673
});
671674
}
@@ -680,6 +683,7 @@ export function buildConsentPermissions(model: ConsentScopeModel): PermissionGro
680683
groups.push({
681684
heading: 'Organizations',
682685
note: 'Applies only to the organizations you select below.',
686+
collapsible: true,
683687
lines: organizationLines
684688
});
685689
}

src/routes/(public)/oauth2/consent-card.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,7 @@
686686
{#if showPermissions}
687687
<div class="panel-body">
688688
{#each permissionGroups as group (group.heading)}
689-
{@const collapsible =
690-
group.heading === 'Projects' ||
691-
group.heading === 'Organizations'}
689+
{@const collapsible = group.collapsible === true}
692690
<div class="perm-group">
693691
<div class="perm-group-head">
694692
{#if collapsible}

src/routes/(public)/oauth2/resource-selector.svelte

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,20 @@
112112
const currentTerm = term;
113113
const offset = results.length;
114114
loadingMore = true;
115-
const page = await find(currentTerm, offset, PAGE_SIZE);
116-
if (currentTerm !== term) return;
117-
118-
const seen = new Set(results.map((resource) => resource.id));
119-
const next = page.resources.filter((resource) => !seen.has(resource.id));
120-
results = [...results, ...next];
121-
hasMore = page.hasMore;
122-
const merged = { ...names };
123-
for (const resource of next) merged[resource.id] = resource;
124-
names = merged;
125-
loadingMore = false;
115+
try {
116+
const page = await find(currentTerm, offset, PAGE_SIZE);
117+
if (currentTerm !== term) return;
118+
119+
const seen = new Set(results.map((resource) => resource.id));
120+
const next = page.resources.filter((resource) => !seen.has(resource.id));
121+
results = [...results, ...next];
122+
hasMore = page.hasMore;
123+
const merged = { ...names };
124+
for (const resource of next) merged[resource.id] = resource;
125+
names = merged;
126+
} finally {
127+
loadingMore = false;
128+
}
126129
}
127130
128131
function handleResultsScroll(event: Event) {

0 commit comments

Comments
 (0)