Skip to content

fix(ui-react): use server-side filtering for device search#6129

Merged
gustavosbarreto merged 1 commit intomasterfrom
fix/ui-react/device-filter
Apr 7, 2026
Merged

fix(ui-react): use server-side filtering for device search#6129
gustavosbarreto merged 1 commit intomasterfrom
fix/ui-react/device-filter

Conversation

@luizhf42
Copy link
Copy Markdown
Member

@luizhf42 luizhf42 commented Apr 7, 2026

What

Device search on the tenant device list page now queries the API with a base64-encoded filter instead of filtering client-side.

Why

The previous implementation filtered devices locally after fetching, which only searched within the current page (10 devices). With more than one page of devices, search results were incomplete. The Vue UI already sends server-side filters correctly; this aligns the React UI with that behavior.

Changes

  • useDevices hook: Merged buildTagFilter into a unified buildFilter(search, tags) that combines name and tag filters into a single base64-encoded array. Added search param to the hook interface.
  • Devices page: Replaced local .filter() with a debounced (300ms, trimmed) search input that passes the query to useDevices for server-side filtering. Page resets to 1 on new input.
  • Tests: Added unit tests for buildFilter covering search-only, tags-only, combined, and empty-input cases.

Testing

  • Search for a device name that exists beyond the first page of results — it should now appear
  • Verify whitespace-only input does not trigger an API call
  • Confirm tag filtering still works independently and in combination with search

The device search on the main UI page was filtering locally, which only
searched within the current page of results. This sends a base64-encoded
filter query param to the API instead, matching the Vue UI behavior and
searching across all devices.
@luizhf42 luizhf42 requested a review from a team as a code owner April 7, 2026 17:01
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Claude finished @luizhf42's task in 3m 27s —— View job


Code Review Complete

Reviewed 3 files across code quality, security, testing, TypeScript/React patterns, and architecture — no issues found. The code looks good as-is.

Highlights:

  • buildFilter cleanly unifies name + tag filters into a single base64-encoded array matching the backend's expected format (pkg/api/query/filter.go)
  • Debounce implementation is correct with proper cleanup
  • Tests cover all meaningful input partitions
  • No breaking changes to existing callers of useDevices (all new params are optional with defaults)
  • Filter format is consistent with the Vue UI's existing approach

If you push additional changes and want a new review, tag @shellhub-io/admin and a team member can trigger it.

@luizhf42 luizhf42 self-assigned this Apr 7, 2026
@luizhf42 luizhf42 added kind/bug Something isn't working area/ui labels Apr 7, 2026
@gustavosbarreto gustavosbarreto merged commit 638946f into master Apr 7, 2026
23 checks passed
@gustavosbarreto gustavosbarreto deleted the fix/ui-react/device-filter branch April 7, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ui kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants