Conversation
…templates
The 'Add Machine Identity to Template' modal was only fetching the first
50 identities (backend default limit) and filtering client-side. Orgs with
more than 50 machine identities would not see all identities in the dropdown.
Changes:
- Add debounced search input that sends name filter to the server via
the existing search API ( operator)
- Disable client-side filtering on the dropdown (filterOption={() => true)
since the server handles filtering
- Keep a separate query for name resolution in the table
- Cache identity names in a ref to handle identities outside the fetched page
Co-Authored-By: unknown <>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile SummaryImplements server-side search for machine identity dropdown in project templates to fix issue where organizations with >50 identities couldn't find identities outside the first 50 results. The change replaces client-side filtering with debounced server-side search using Key changes:
Implementation notes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: ae70ebc |
Co-Authored-By: unknown <>
Co-Authored-By: unknown <>
|
@greptile re-review the latest commit |
...tesTab/components/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
Show resolved
Hide resolved
victorvhs017
left a comment
There was a problem hiding this comment.
Tested and looks good
Context
When adding a machine identity to a project template via the "Assign Existing" flow, the identity dropdown only showed a subset of the organization's identities. The root cause: the component called
useSearchOrgIdentityMemberships({ search: {} })without specifying alimit, so the backend applied its default limit of 50. TheFilterableSelectthen performed client-side filtering on just those 50 results — meaning any identities outside the first 50 (sorted alphabetically) were invisible regardless of what the user typed.This was reported by a customer whose
taf_*identities were not appearing in the dropdown despite existing in the organization.Before: Dropdown fetches first 50 identities, filters client-side only. Orgs with >50 identities can't find some of them.
After: Dropdown sends the user's search text to the server as a
name: { $contains: ... }filter (debounced at 300ms), matching how the Organization Machine Identities page already works.Steps to verify the change
Important things for reviewers
knownIdentityNamesRefcache (lines ~130–136): AuseRef<Map>is populated viauseEffect(triggered whensearchedIdentitiesororgIdentitieschange) to cache identity names. This avoids stale names in the table when an identity was found via search but falls outside the name-resolution query's limit. Note: sincesearchedIdentitiesandorgIdentitiesare arrays recreated from.map()on each render, the effect will fire on every render — this is functionally correct but could be optimized withuseMemoon those arrays if performance becomes a concern.limit: 100on the name-resolution query: This is an improvement over the implicit 50 default but still won't fully resolve names for orgs with >100 identities in the table view. The ref cache mitigates this. A dedicated batch-lookup-by-ID endpoint would be the ideal long-term solution.filterOption={() => true}: Client-side filtering is fully disabled since the server handles search. During the 300ms debounce window after typing, the dropdown briefly shows results from the previous server response.Updates since initial revision
knownIdentityNamesRefpopulation from render-time mutation to auseEffect(per React best practices, raised by Greptile review)setIdentitySearchInput("")reset inhandleAddOrgIdentityandhandleCloseAddIdentityModalto prevent stale dropdown results when reopening the modal (raised by Devin Review)Link to Devin run: https://app.devin.ai/sessions/d1a8cb051f3d43bd943088cbc553e2c2
Requested by: @0xArshdeep
Type
Checklist
type(scope): short description