Repository navigation
feat(dashboard): per-provider dropdown filter on the quota dashboard #4495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
diegosouzapw
merged 1 commit into
release/v3.8.33
from
feat/port-pr-769-quota-dashboard-filter
Jun 21, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Port of decolua/9router PR #769 — provider dropdown filter for the quota | ||
| // dashboard. The upstream PR added the dropdown plus an "Expiring first" sort | ||
| // toggle; OmniRoute already always sorts by soonest reset within each status | ||
| // group (see ProviderLimits/index.tsx `visibleConnections`), so only the | ||
| // dropdown is genuinely new here. These tests guard the pure helpers that | ||
| // back the dropdown so regressions in the inline `useMemo` predicates fail | ||
| // loudly instead of silently widening / breaking the filter. | ||
|
|
||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
|
|
||
| import { | ||
| buildProviderOptions, | ||
| matchesProviderFilter, | ||
| } from "../../src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx"; | ||
|
|
||
| test("PR#769: matchesProviderFilter — 'all' lets every connection through", () => { | ||
| assert.equal(matchesProviderFilter({ provider: "openai" }, "all"), true); | ||
| assert.equal(matchesProviderFilter({ provider: "anthropic" }, "all"), true); | ||
| // Defensive: even a malformed connection still matches the "all" sentinel | ||
| // so the dropdown's default never collapses the list to zero. | ||
| assert.equal(matchesProviderFilter({}, "all"), true); | ||
| assert.equal(matchesProviderFilter(null, "all"), true); | ||
| }); | ||
|
|
||
| test("PR#769: matchesProviderFilter — exact match on a specific provider key", () => { | ||
| assert.equal(matchesProviderFilter({ provider: "openai" }, "openai"), true); | ||
| assert.equal(matchesProviderFilter({ provider: "openai" }, "anthropic"), false); | ||
| // Case-sensitive: provider keys are normalized upstream, so the filter must | ||
| // not match "OpenAI" against "openai" — that would silently union two | ||
| // distinct registry rows. | ||
| assert.equal(matchesProviderFilter({ provider: "OpenAI" }, "openai"), false); | ||
| }); | ||
|
|
||
| test("PR#769: matchesProviderFilter — non-string provider is excluded under a specific filter", () => { | ||
| // Connections with a missing or non-string provider field cannot match a | ||
| // specific provider; only the "all" sentinel accepts them. This keeps | ||
| // dropdown filtering deterministic when the API returns partial rows. | ||
| assert.equal(matchesProviderFilter({}, "openai"), false); | ||
| assert.equal(matchesProviderFilter({ provider: undefined }, "openai"), false); | ||
| assert.equal(matchesProviderFilter({ provider: 42 as unknown }, "openai"), false); | ||
| assert.equal(matchesProviderFilter(null, "openai"), false); | ||
| }); | ||
|
|
||
| test("PR#769: matchesProviderFilter — empty filter string is treated like 'all'", () => { | ||
| // Defensive: if the persisted localStorage value is somehow blanked the | ||
| // dropdown should keep listing everything instead of hiding all rows. | ||
| assert.equal(matchesProviderFilter({ provider: "openai" }, ""), true); | ||
| }); | ||
|
|
||
| test("PR#769: buildProviderOptions — de-duplicates and sorts alphabetically", () => { | ||
| const connections = [ | ||
| { provider: "openai" }, | ||
| { provider: "anthropic" }, | ||
| { provider: "openai" }, | ||
| { provider: "gemini" }, | ||
| { provider: "anthropic" }, | ||
| ]; | ||
| assert.deepEqual(buildProviderOptions(connections), ["anthropic", "gemini", "openai"]); | ||
| }); | ||
|
|
||
| test("PR#769: buildProviderOptions — drops missing/empty/non-string provider keys", () => { | ||
| const connections = [ | ||
| { provider: "openai" }, | ||
| { provider: "" }, | ||
| { provider: undefined }, | ||
| { provider: null as unknown }, | ||
| { provider: 42 as unknown }, | ||
| {}, | ||
| { provider: "anthropic" }, | ||
| ]; | ||
| assert.deepEqual(buildProviderOptions(connections), ["anthropic", "openai"]); | ||
| }); | ||
|
|
||
| test("PR#769: buildProviderOptions — honors a custom comparator (e.g. Turkish-aware)", () => { | ||
| // The production call site passes `compareTr` so locale-aware ordering | ||
| // applies. The helper must thread the comparator through Array#sort | ||
| // unchanged — verify with a reverse comparator instead of pulling in the | ||
| // real i18n helper. | ||
| const reverse = (a: string, b: string) => b.localeCompare(a); | ||
| const out = buildProviderOptions([{ provider: "a" }, { provider: "c" }, { provider: "b" }], reverse); | ||
| assert.deepEqual(out, ["c", "b", "a"]); | ||
| }); | ||
|
|
||
| test("PR#769: buildProviderOptions — returns [] for an empty connection list", () => { | ||
| assert.deepEqual(buildProviderOptions([]), []); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a potential UI/state desynchronization bug when a stale provider filter is loaded from
localStorage(e.g., if a provider was used in a previous session but is no longer present in the current session's connections).In the dropdown UI, the
<select>element falls back to"all"if the persistedproviderFilteris not present inproviderOptions:However,
visibleConnectionsfilters using the rawproviderFilterstate directly:This causes the list of connections to be completely empty (since no connection matches the stale provider), while the dropdown UI falsely displays "All providers" as selected.
To fix this, we should resolve the active provider filter inside
visibleConnectionsusing the same fallback logic (by checking if the filter is"all"or exists in the current connections).