Skip to content

feat(core, react): add server-side role search for member management - #416

Merged
chakrihacker merged 5 commits into
mainfrom
feat/role-server-side-search
Jul 22, 2026
Merged

feat(core, react): add server-side role search for member management#416
chakrihacker merged 5 commits into
mainfrom
feat/role-server-side-search

Conversation

@chakrihacker

@chakrihacker chakrihacker commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds server-side role search to the organization member-management modals (assign-roles and invitation-create), so role options are fetched and filtered by the API as the admin types instead of loading the full list up front.

Why

Role selection loaded the entire role list client-side, which does not scale for organizations with many roles and made the "as-you-type" filter operate on a partial/eager dataset. This PR moves filtering to the server with a debounced query, so the combobox reflects the full role catalog without over-fetching.

What

  • New useDebouncedValue hook to throttle search-as-you-type requests
  • Roles queried server-side via take + name params driven by the debounced term
  • New filterLocally prop on Combobox to defer filtering to the server
  • Selected combobox options cached so chips retain labels after the list narrows
  • Assign-roles and invitation-create modals wired to server-side search; assigned roles excluded from results
  • DEBOUNCE default, rolesSearch query key, and page-size constant added
Screenshot 2026-07-20 at 4 23 46 PM Screenshot 2026-07-20 at 4 24 04 PM Screenshot 2026-07-20 at 4 24 28 PM Screenshot 2026-07-20 at 4 24 47 PM

Packages

  • packages/core
  • packages/react
  • examples

References

Testing

  1. Start an example app and open Organization → Members.
  2. Open Assign roles on a member (and Invite member).
  3. Type in the role combobox — results should update after a short debounce, driven by the API (name param), not the full local list.
  4. Select a role, then keep typing — the selected chip should keep its label even as the list narrows.
  5. Confirm already-assigned roles do not appear in the available results.
  • This change adds unit test coverage
  • Tested for both SPA and RWA flows, all example apps working
  • All existing and new tests complete without errors

Checklist

  • Breaking change
  • Requires docs update
  • Backward compatible

Contributing

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added server-side role searching in invitation and role-assignment dialogs.
    • Role results update as users type (debounced), with assigned roles excluded from search results.
  • Bug Fixes

    • Improved loading behavior so role search doesn’t unnecessarily block modal interactions.
    • Search state is cleared when dialogs close or forms reset.
    • Role selectors remain usable even when no initial roles are loaded.

- add DEBOUNCE default and rolesSearch query key + page-size constant
- add useDebouncedValue hook to throttle search-as-you-type requests
- query roles server-side with take + name params via debounced term
- add filterLocally prop to combobox to defer filtering to the server
- cache selected combobox options so chips keep labels after list narrows
- wire assign-roles and invitation-create modals to server-side search
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@chakrihacker, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 87074e9e-4bf5-402a-973f-81b70445696e

📥 Commits

Reviewing files that changed from the base of the PR and between 6886b86 and 18edb7c.

📒 Files selected for processing (9)
  • packages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsx
  • packages/react/src/hooks/my-organization/use-member-detail.ts
  • packages/react/src/hooks/my-organization/use-organization-member-management.ts
  • packages/react/src/hooks/shared/__tests__/use-debounced-value.test.ts
  • packages/react/src/hooks/shared/use-debounced-value.ts
  • packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts
  • packages/react/src/tests/utils/__mocks__/my-organization/member-management/member.mocks.ts
  • packages/react/src/types/my-organization/member-management/organization-member-detail-types.ts
  • packages/react/src/types/my-organization/member-management/organization-member-management-types.ts
📝 Walkthrough

Walkthrough

Role management now supports debounced server-side role search. Hooks expose searched roles and search state, while assignment and invitation modals pass search input through the updated Combobox behavior.

Changes

Role search service and contracts

Layer / File(s) Summary
Role search service and contracts
packages/core/src/services/..., packages/react/src/types/..., packages/react/src/hooks/shared/use-debounced-value.ts, packages/react/src/hooks/.../use-member-management-service.ts, packages/react/src/lib/constants/...
Role query keys, service options, return types, debouncing, deferred activation, and filtered API requests now support server-side role search.

Hook orchestration and derived roles

Layer / File(s) Summary
Hook orchestration and derived roles
packages/react/src/hooks/my-organization/..., packages/react/src/tests/utils/__mocks__/..., packages/react/src/hooks/my-organization/__tests__/*
Member-detail and member-management hooks enable role search, derive searched roles while excluding assigned roles, expose search handlers, and update related tests and mocks.

Combobox and modal behavior

Layer / File(s) Summary
Combobox and modal behavior
packages/react/src/components/ui/combobox.tsx, packages/react/src/components/auth0/my-organization/shared/member-management/...
Combobox filtering and selected-option handling support external search callbacks; assignment and invitation modals reset search state and remain usable with empty server results.

View wiring and integration tests

Layer / File(s) Summary
View wiring and integration tests
packages/react/src/components/auth0/my-organization/organization-member-*.tsx, packages/react/src/components/auth0/my-organization/__tests__/*, packages/react/src/tests/utils/...
Organization views pass searched roles and search handlers to role modals, and loading-state fixtures and assertions reflect the new role-search contract.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant RoleCombobox
  participant OrganizationMemberManagement
  participant useMemberManagementService
  participant RolesAPI
  User->>RoleCombobox: Enter role search text
  RoleCombobox->>OrganizationMemberManagement: onRoleSearch(term)
  OrganizationMemberManagement->>useMemberManagementService: setRoleSearchTerm(term)
  useMemberManagementService->>RolesAPI: Fetch roles with debounced name filter
  RolesAPI-->>useMemberManagementService: Return searched roles
  useMemberManagementService-->>RoleCombobox: Render searched roles
Loading

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: rax7389

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding server-side role search for member management across core and React.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/role-server-side-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.27273% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.72%. Comparing base (5e0ad49) to head (6886b86).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...organization/use-organization-member-management.ts 0.00% 13 Missing ⚠️
...n/member-management/member-management-constants.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #416      +/-   ##
==========================================
- Coverage   88.75%   88.72%   -0.03%     
==========================================
  Files         203      204       +1     
  Lines       17376    17456      +80     
  Branches     1817     1910      +93     
==========================================
+ Hits        15422    15488      +66     
- Misses       1954     1968      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  - add enableRolesList and deferRoleSearch options to member management service
  - gate role search query behind enableRoleSearch, triggered when the
    assignRoles modal opens
  - drop eager rolesQuery/availableRoles from the member detail path
  - remove availableRoles and isFetchingAvailableRoles from detail types, props, and mocks
@chakrihacker
chakrihacker marked this pull request as ready for review July 20, 2026 09:51
- pass enableRoleSearch to member service with deferRoleSearch: true
- trigger role search via effect only on create/assignRole modal open
@chakrihacker

Copy link
Copy Markdown
Contributor Author

@coderabbitai review this PR

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@chakrihacker: I’ll review the changes in #416.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread packages/react/src/hooks/shared/use-debounced-value.ts
Comment thread packages/react/src/hooks/shared/use-debounced-value.ts
Comment thread packages/react/src/hooks/my-organization/use-organization-member-management.ts Outdated
Comment thread packages/react/src/hooks/my-organization/use-member-detail.ts
@rax7389

rax7389 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai Review the PR changes

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The Comment images show the Auth0 Members page at localhost:5173/member-management with Chrome DevTools’ Network tab open. The first image shows a member table and requests including roles?take=100 (200), while some identity-providers and members requests show 429 errors. The next images show the Invite Member and Assign Roles modals with role comboboxes open; visible options include “Apple,” “EcoWorld,” “Fire,” “member,” “Odyssey,” “Orange,” “Role 3,” and “Role 4.” The final image shows the member-detail Roles tab with the Assign Roles modal and a roles?take=50 request.

@rax7389 I’ll review the changes in #416.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/react/src/hooks/my-organization/use-organization-member-management.ts (1)

122-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for deferred role-search activation.

Cover that role search remains deferred before the create/assign-role modal opens and becomes enabled when either modal opens.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/react/src/hooks/my-organization/use-organization-member-management.ts`
around lines 122 - 126, Add tests around the use-organization-member-management
hook to verify role search remains disabled before the modal opens, then becomes
enabled when modalState.type changes to either 'create' or 'assignRole'.
Exercise both modal types and preserve the existing enableRoleSearch behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/react/src/hooks/my-organization/use-organization-member-management.ts`:
- Around line 122-126: Add tests around the use-organization-member-management
hook to verify role search remains disabled before the modal opens, then becomes
enabled when modalState.type changes to either 'create' or 'assignRole'.
Exercise both modal types and preserve the existing enableRoleSearch behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 65ee71e3-7d7d-4fb9-97fc-f10be9853ae8

📥 Commits

Reviewing files that changed from the base of the PR and between a4c9ea3 and 6886b86.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • auth0-myorganization-js-1.1.0.tgz
  • packages/core/package.json
  • packages/react/src/hooks/my-organization/use-organization-member-management.ts

Comment on lines +17 to +28
export function useDebouncedValue<T>(value: T, delayMs = 300): T {
const [debouncedValue, setDebouncedValue] = React.useState(value);

React.useEffect(() => {
const timeoutId = setTimeout(() => {
setDebouncedValue(value);
}, delayMs);

return () => clearTimeout(timeoutId);
}, [value, delayMs]);

return debouncedValue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also thinking if we could have this in combobox itself? and based on prop we could have debounced input change or non

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UDS is not the place to keep debounce, happy to discuss

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.

3 participants