Skip to content

fix(admin): filter users by the name the list shows - #2070

Open
rohanchkrabrty wants to merge 4 commits into
mainfrom
fix/admin-user-display-name-filter
Open

rohanchkrabrty wants to merge 4 commits into
mainfrom
fix/admin-user-display-name-filter

Conversation

@rohanchkrabrty

Copy link
Copy Markdown
Contributor

Summary

  • The Name column in the admin users list and the org members list shows the title, or the name when the title is empty. Its filter and sort read only the title, so a user without a title could not be found by the name the list showed.
  • Add a display_name RQL field to SearchUsers and SearchOrganizationUsers. It is computed at query time as COALESCE(NULLIF(title, ''), name), so there is no new column and no migration. The title and name filters do not change.
  • The admin SDK maps the Name column to display_name for filter and sort. The org members list now shows the name when the title is empty.
  • SearchUsers checks its RQL query against a new user.SearchFields struct, so user.User no longer has rql tags. An unsupported filter operator on SearchUsers now returns ErrBadInput.

The Name column in the admin users list and the org members list shows
the title, or the name when the title is empty. Its filter and sort read
only the title, so a user without a title could not be found by the name
the list showed.

Add a display_name RQL field to SearchUsers and SearchOrganizationUsers.
It reads COALESCE(NULLIF(title, ''), name) at query time, so there is no
new column and no migration. The title and name filters do not change.

SearchUsers now checks its RQL query against user.SearchFields, so
user.User no longer has rql tags. An unsupported filter operator on
SearchUsers now returns ErrBadInput.

The org members list now shows the name when the title is empty.
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Dec 3, 2026 11:03am UTC

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c678622 and f6310f0.

Files selected for processing: 1

  • web/sdk/admin/views/organizations/details/members/columns.tsx

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • User and organization member lists display a person’s title as their display name, falling back to their name when no title is set. Avatar initials use the resolved display name.
    • Display names can be filtered and sorted in user and organization member lists.
  • Bug Fixes
    • Display-name filtering and sorting now use the same title-or-name fallback shown in the lists. Filtering by title continues to match only the title.

User search and organization-member results now support display_name, derived from a non-empty title or the user’s name. Admin views display this value and map title-based sorting and filtering to it.

Changes: User display names

Layer / File(s) Summary
Search and response contracts
core/user/user.go, core/aggregates/orgusers/service.go, internal/api/v1beta1connect/user.go
RQL search fields now use a dedicated SearchFields struct. Search query transformation and validation use that struct. Aggregated organization users expose display_name.
Computed fields and PostgreSQL queries
internal/store/postgres/user_search_fields.go, internal/store/postgres/user_repository.go, internal/store/postgres/org_users_repository.go, internal/store/postgres/*_test.go
PostgreSQL queries resolve display_name from a non-empty title or fall back to the name. User and organization-user queries support display-name filtering and sorting. User query preparation returns errors for unsupported filter operators. Tests cover these query behaviors.
Admin display and query mappings
web/sdk/admin/views/organizations/details/members/*, web/sdk/admin/views/users/list/list.tsx, web/sdk/admin/views/users/util.ts
Organization-member rows display the title or fall back to the name, and derive the avatar initial from the selected value. Admin query mappings use display_name for title sorting and filtering. getUserName accepts only the title and name fields.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: whoabhisheksah

Merge Risk: Minimal · previous review c6786

This change lets admin user lists filter and sort by the name they display, using the title when present and the name otherwise. It has no known merge-blocking issues and is covered by query and integration tests.

Pre-merge checks: Passed 2

Check name Status Explanation
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.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9ad4924 and c678622.

Files selected for processing: 5

  • core/user/user.go
  • internal/store/postgres/user_repository.go
  • internal/store/postgres/user_repository_test.go
  • web/sdk/admin/views/organizations/details/members/columns.tsx
  • web/sdk/admin/views/users/util.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@rohanchkrabrty
rohanchkrabrty removed the request for review from Shreyag02 December 3, 2026 08:05
@coveralls

coveralls commented Dec 3, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 47092150236

Coverage increased (+0.02%) to 56.486%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 15 uncovered changes across 4 files (58 of 73 lines covered, 79.45%).
  • 3 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
internal/store/postgres/user_search_fields.go 20 14 70.0%
internal/store/postgres/org_users_repository.go 25 20 80.0%
internal/api/v1beta1connect/user.go 2 0 0.0%
internal/store/postgres/user_repository.go 26 24 92.31%

Coverage Regressions

3 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
internal/store/postgres/user_repository.go 3 78.97%

Coverage Stats

Coverage Status
Relevant Lines: 42437
Covered Lines: 23971
Line Coverage: 56.49%
Coverage Strength: 22.12 hits per line

💛 - Coveralls

getNonRoleField now handles only org_joined_at and passes every other name to userField, which moves next to userComputedFields. compare is renamed to buildComparisonCondition to match the other condition builders.
SearchUsers checks the group-by key in addSort, so grouping by display_name returns ErrBadInput instead of a Postgres error. user.SearchFields keeps the metadata filter that user.User allowed. The org members list uses getUserName and an uppercase avatar letter, the same as the users list.
The members Name cell still shows getUserName, but the avatar goes back to the title initial, then the email initial, as on main.

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall the approach is right, and performance holds up. I checked filter+sort with EXPLAIN ANALYZE on a local seed of 100k users and a 20k-member org. display_name stays a full scan, same as the old title filter, so no regression. A few inline notes below: two should-fixes, one consistency nit, and a couple of questions.

query = query.OrderAppend(userField(sort.Name).Asc())
case "desc":
query = query.OrderAppend(goqu.I(sort.Name).Desc())
query = query.OrderAppend(userField(sort.Name).Desc())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should-fix: the sort appends only the user-selected field, with no stable tiebreaker. Rows that share a display_name (common now, since every user without a title falls back to name) can repeat or get skipped across OFFSET pages. Adding a final users.id ASC here, and in the org users sort, would make pagination deterministic.

if field, ok := userComputedFields[name]; ok {
return field
}
return goqu.I(TABLE_USERS + "." + name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should-fix: userField falls through to goqu.I(users.) for any name not in userComputedFields, and addFilter has no allow-list of valid fields. So an unknown RQL filter field builds users. and Postgres errors. A filter on displayname returns a 500 on this branch (reproduced locally). Validating filter names against an allow-list and returning ErrBadInput would make it a clean 400. Note OrgUsersRepository.validateFilters already allow-lists, SearchUsers does not. This was already true for createdat.

// DataTable filter sends them pre-wrapped.
case "like":
return goqu.Cast(goqu.I(columnName), "TEXT").Like(filter.Value.(string)), nil
return goqu.Cast(field, "TEXT").Like(filter.Value.(string)), nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: the two lists handle like differently. Org users uses case-sensitive LIKE with caller-owned wildcards (this line), but SearchUsers.addFilter uses ILIKE and wraps the value in %..% itself. Same operator, different behavior between the Users list and the Org Members list. Worth making them consistent.

}

var userComputedFields = map[string]searchField{
COLUMN_DISPLAY_NAME: goqu.L("COALESCE(NULLIF(?, ''), ?)",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

question: NULLIF(title, '') only treats an exactly empty title as absent, so a whitespace-only title would still win over the name. Should a spaces-only title fall back to name too? And on sort order: under byte-order collation, capitalized titles sort before lowercase names, so should the display_name sort use LOWER()? What collation does prod run?

This branch was successfully deployed

1 active deployment
Preview — f6310f0f Deployed Dec 3, 2026 by vercel[bot]
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