fix: use parseAsSafeArrayOf for dashboard page array query params - #4801
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesDashboard filter URL state refactor
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
30915bb to
1158abc
Compare
cc76ad9 to
0008078
Compare
0008078 to
11d1653
Compare
1158abc to
5274612
Compare
11d1653 to
c74e500
Compare
5274612 to
17dcf7e
Compare
17dcf7e to
a089f20
Compare
c74e500 to
255e8e0
Compare
Merge activity
|
The base branch was changed.
) ## Summary Dashboard filter query parameters were being stored as comma-separated strings in the URL, requiring manual parsing and serialization on every read and write. This replaces that approach with a proper array-aware query parameter parser (`parseAsSafeArrayOf`) and uses `parseAsBoolean` for the `missing_cost_only` flag, so filter values are stored and consumed as native arrays and booleans directly from URL state. ## Changes - Replaced `parseAsString` with `parseAsSafeArrayOf` for all array-typed filter parameters (`providers`, `models`, `virtual_key_ids`, `selected_key_ids`, `objects`, `status`, `routing_rule_ids`, `routing_engine_used`, `stop_reasons`, `user_ids`, `team_ids`, `customer_ids`, `business_unit_ids`, `aliases`) - Replaced `parseAsString` with `parseAsBoolean` for `missing_cost_only`, removing the need to compare against the string `"true"` - Removed the local `parseCsvParam` helper and all intermediate `useMemo` variables that existed solely to parse CSV strings into arrays — `urlState` values are now used directly - Removed `.join(",")` serialization calls in `setFilters`; arrays are passed directly to `setUrlState` - MCP tool name and server label fields (`mcp_tool_names`, `mcp_server_labels`) remain as strings for now, with their own minimal memo wrappers retained - Removed a stale `urlState.period` reference from the `setFilters` dependency array ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [x] UI (React) - [ ] Docs ## How to test Apply filters on the dashboard (providers, models, virtual keys, statuses, etc.) and verify: 1. URL query parameters reflect the selected values correctly 2. Refreshing the page restores all filters as expected 3. The `missing_cost_only` toggle persists as `true`/`false` in the URL rather than a string 4. Clearing filters resets URL params to their defaults ```sh cd ui pnpm i || npm i pnpm build || npm run build ``` ## Screenshots/Recordings N/A — behavior is unchanged from the user's perspective; this is an internal state management refactor. ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations None. This change only affects how filter values are serialized into and parsed from the URL query string. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Dashboard filter query parameters were being stored as comma-separated strings in the URL, requiring manual parsing and serialization on every read and write. This replaces that approach with a proper array-aware query parameter parser (
parseAsSafeArrayOf) and usesparseAsBooleanfor themissing_cost_onlyflag, so filter values are stored and consumed as native arrays and booleans directly from URL state.Changes
parseAsStringwithparseAsSafeArrayOffor all array-typed filter parameters (providers,models,virtual_key_ids,selected_key_ids,objects,status,routing_rule_ids,routing_engine_used,stop_reasons,user_ids,team_ids,customer_ids,business_unit_ids,aliases)parseAsStringwithparseAsBooleanformissing_cost_only, removing the need to compare against the string"true"parseCsvParamhelper and all intermediateuseMemovariables that existed solely to parse CSV strings into arrays —urlStatevalues are now used directly.join(",")serialization calls insetFilters; arrays are passed directly tosetUrlStatemcp_tool_names,mcp_server_labels) remain as strings for now, with their own minimal memo wrappers retainedurlState.periodreference from thesetFiltersdependency arrayType of change
Affected areas
How to test
Apply filters on the dashboard (providers, models, virtual keys, statuses, etc.) and verify:
missing_cost_onlytoggle persists astrue/falsein the URL rather than a stringScreenshots/Recordings
N/A — behavior is unchanged from the user's perspective; this is an internal state management refactor.
Breaking changes
Related issues
N/A
Security considerations
None. This change only affects how filter values are serialized into and parsed from the URL query string.
Checklist
docs/contributing/README.mdand followed the guidelines