Skip to content

fix(dashboard): make quota card ordering deterministic - #9329

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.50from
xz-dev:fix/quota-deterministic-order
Aug 6, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.50from
xz-dev:fix/quota-deterministic-order

Conversation

@xz-dev

@xz-dev xz-dev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Problem

The quota dashboard (`dashboard/quota`, `ProviderLimits`) ordered cards non-deterministically, so provider groups shuffled position on every quota refresh.

Root cause: `visibleConnections` re-sorted the entire flat connection list by status (critical → alert → ok → empty) then soonest reset, and `QuotaCardGrid` grouped providers by first-appearance order in that list. Each provider group's rendered position was therefore decided by whichever of its accounts happened to sort first. Since account status and reset times change on every refresh, the group order changed with them. A stale inline comment claimed `Provider order between groups is enforced separately via PROVIDER_ORDER`, but provider rank was not actually part of the comparator.

Fix

Mirror the `dashboard/providers` ordering rule (`providerPageUtils.ts::sortProviderEntriesByName`), where every sort level ends in a stable, data-independent tiebreak:

  • Provider rank (`PROVIDER_ORDER`) is the outer sort key again, so each provider group keeps a fixed slot regardless of account status.
  • Status / soonest-reset now only orders accounts inside their own group (the existing critical-first intent is preserved, scoped correctly).
  • Added the providers-page deterministic tiebreaks — locale-aware label (`compareTr`), then provider key / email / id ASCII — so equal-status accounts and aliased providers (e.g. `xai-oauth`/`xao`, both rank 16) never shuffle.

Changes

  • `utils.tsx`: new pure helpers `compareQuotaConnections()` and `compareProviderGroups()`.
  • `index.tsx`: use them in `sortedConnections` and `visibleConnections`; the status+reset comparator now runs only as the in-group `accountCompare`.
  • `QuotaCardGrid.tsx`: order provider group headers via `compareProviderGroups` instead of first-appearance.
  • `tests/unit/quota-deterministic-order.test.ts`: 7 tests covering rank dominance over account status, in-group critical-first ordering, deterministic name/email/id tiebreak, unranked-provider label fallback, aliased-provider key tiebreak, and input-order independence.

Verification

  • `node --import tsx/esm --test tests/unit/quota-deterministic-order.test.ts` → 7/7 pass
  • `provider-columns.test.ts` + `provider-limits-provider-filter.test.ts` → 17/17 pass (no regression)
  • ESLint clean on all touched files; Prettier formatted.
  • `tsc --noEmit`: no new errors in touched files (the 2 `Property 'label'` errors in `index.tsx` are pre-existing on the base branch — verified by stashing).

The quota dashboard re-sorted the entire flat connection list by status
then soonest reset, and QuotaCardGrid grouped providers by
first-appearance order. Each provider group's position was therefore
decided by whichever of its accounts happened to sort first, so groups
shifted position on every quota refresh as account status/reset changed.

Mirror the dashboard/providers rule (providerPageUtils.ts
sortProviderEntriesByName): provider rank (PROVIDER_ORDER) becomes the
outer sort key again so each group keeps a fixed slot, and status/reset
only orders accounts inside their own group. Add the providers-page
deterministic tiebreaks (locale-aware label, then provider key / email /
id ASCII) so equal-status accounts and aliased providers never shuffle.

- Add compareQuotaConnections() and compareProviderGroups() pure helpers
  to utils.tsx (providers-page pattern: every level ends in a stable,
  data-independent tiebreak).
- index.tsx: use them in sortedConnections and visibleConnections; the
  existing critical-first + soonest-reset intent now runs only as the
  in-group accountCompare.
- QuotaCardGrid.tsx: order provider group headers via
  compareProviderGroups instead of first-appearance.
- Add unit tests covering rank dominance, in-group status ordering,
  deterministic name/email/id tiebreak, unranked-provider label fallback,
  aliased-provider key tiebreak, and input-order independence.
@xz-dev
xz-dev requested a review from diegosouzapw as a code owner August 4, 2026 04:50
@diegosouzapw
diegosouzapw merged commit 88a2fd2 into cheaper-inference:release/v3.8.50 Aug 6, 2026
4 of 5 checks passed
diegosouzapw added a commit that referenced this pull request Aug 6, 2026
…9554)

* fix(quality): reconcile inherited file-size drift on the release tip

13 files sit above their frozen LOC on the clean tip 8180b49
(measured by the gate itself). The PR-mode base-relative check (#8522)
correctly lets innocent PRs pass, but per-PR rebaselines were lost
across successive conflict resolutions of this hot file during the
08-05/06 merge batch — so the absolute mode (nightly, local runs) is
permanently red and stops distinguishing real growth from inherited
drift.

Frozen values updated to the measured tip, each annotated with the
merged PR that grew the file (#9024 #9324 #9329 #9193 #9332 #9228
#9236 #9314 #9260 #8934 #9196 #9163); executors default.ts and kiro.ts
(above the 1000 cap with no frozen entry) join the frozen set.

* fix(quality): prune orphaned ESLint suppressions and clear the 5 unsuppressed errors

The 'No new ESLint warnings' job reds the whole queue with exit 2:
'There are suppressions left that do not occur anymore' — the 08-05
merge batch removed code whose violations were frozen in
eslint-suppressions.json, leaving orphaned entries (673->670 files,
4338->4333 violations after eslint --prune-suppressions).

The full-tree run also surfaced 5 real unsuppressed errors merged with
the batch, fixed here instead of suppressed (new violations must be
fixed, per policy): 4x no-explicit-any in
tests/unit/catalog-order-contract.test.ts ((conn as any).id -> typed
cast) and 1x react/no-unescaped-entities in the agent-bridge
SetupWizard (#9095).

Also restores the _comment policy header the successive hot-file
conflict resolutions had dropped (TS7 debt freeze provenance + prune
policy).

* fix(quality): absorb the two file-size growths merged while this PR was in CI

The base kept moving during the reconcile cycle: #9184 grew
src/sse/handlers/chat.ts 1857->1877 and #9005 grew
open-sse/executors/default.ts 1027->1042. Re-measured on the merged
tree; gate back to 0 violations.

* fix(tests): move the orphaned RTL ratchet test to a collected path as node:test

#8828 added tests/unit/scripts/check-rtl-ratchet.test.ts — a path no
runner collects (the node:test globs enumerate an explicit subdir list
without scripts/, and vitest.config.ts never included it), so the file
NEVER ran and the test-discovery orphan gate reds the queue. Moved to
tests/unit/ (collected by node:test) and converted from vitest
describe/it/expect to node:test+assert to match the runner and the
sibling check-*.test.ts files. 5/5 green under the real runner.

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ence#9329)

Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates — only pre-existing audit.test.ts flake).
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…heaper-inference#9554)

* fix(quality): reconcile inherited file-size drift on the release tip

13 files sit above their frozen LOC on the clean tip 30be158
(measured by the gate itself). The PR-mode base-relative check (cheaper-inference#8522)
correctly lets innocent PRs pass, but per-PR rebaselines were lost
across successive conflict resolutions of this hot file during the
08-05/06 merge batch — so the absolute mode (nightly, local runs) is
permanently red and stops distinguishing real growth from inherited
drift.

Frozen values updated to the measured tip, each annotated with the
merged PR that grew the file (cheaper-inference#9024 cheaper-inference#9324 cheaper-inference#9329 cheaper-inference#9193 cheaper-inference#9332 cheaper-inference#9228
cheaper-inference#9236 cheaper-inference#9314 cheaper-inference#9260 cheaper-inference#8934 cheaper-inference#9196 cheaper-inference#9163); executors default.ts and kiro.ts
(above the 1000 cap with no frozen entry) join the frozen set.

* fix(quality): prune orphaned ESLint suppressions and clear the 5 unsuppressed errors

The 'No new ESLint warnings' job reds the whole queue with exit 2:
'There are suppressions left that do not occur anymore' — the 08-05
merge batch removed code whose violations were frozen in
eslint-suppressions.json, leaving orphaned entries (673->670 files,
4338->4333 violations after eslint --prune-suppressions).

The full-tree run also surfaced 5 real unsuppressed errors merged with
the batch, fixed here instead of suppressed (new violations must be
fixed, per policy): 4x no-explicit-any in
tests/unit/catalog-order-contract.test.ts ((conn as any).id -> typed
cast) and 1x react/no-unescaped-entities in the agent-bridge
SetupWizard (cheaper-inference#9095).

Also restores the _comment policy header the successive hot-file
conflict resolutions had dropped (TS7 debt freeze provenance + prune
policy).

* fix(quality): absorb the two file-size growths merged while this PR was in CI

The base kept moving during the reconcile cycle: cheaper-inference#9184 grew
src/sse/handlers/chat.ts 1857->1877 and cheaper-inference#9005 grew
open-sse/executors/default.ts 1027->1042. Re-measured on the merged
tree; gate back to 0 violations.

* fix(tests): move the orphaned RTL ratchet test to a collected path as node:test

cheaper-inference#8828 added tests/unit/scripts/check-rtl-ratchet.test.ts — a path no
runner collects (the node:test globs enumerate an explicit subdir list
without scripts/, and vitest.config.ts never included it), so the file
NEVER ran and the test-discovery orphan gate reds the queue. Moved to
tests/unit/ (collected by node:test) and converted from vitest
describe/it/expect to node:test+assert to match the runner and the
sibling check-*.test.ts files. 5/5 green under the real runner.

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
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.

2 participants