Skip to content

fix(dashboard): preserve quota cutoff drafts during refresh - #7909

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
hydraxman:fix/quota-cutoff-draft-reset
Jul 21, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
hydraxman:fix/quota-cutoff-draft-reset

Conversation

@hydraxman

Copy link
Copy Markdown
Contributor

Summary

  • preserve unsaved Provider Quota cutoff values when live quota polling recreates modal props
  • re-seed cutoff drafts only when the modal opens or targets a different connection
  • add a focused component regression and changelog fragment

Problem

The cutoff modal seeded local draft state from windows and current inside an effect that depended on both object references. Provider quota refreshes recreate those values, so an unrelated parent render reran the effect and replaced an operator's in-progress input with the persisted value or an empty string.

Related Issues

Dev Design

QuotaCutoffModal now receives the stable connection ID and tracks the previous open state and seeded connection. The effect keeps complete React dependencies, but only writes draft state on an open transition or connection-ID change. Save, reset, validation, provider defaults, persistence, and quota selection are unchanged.

Alternatives considered were memoizing the parent props, which would leave the modal coupled to parent allocation behavior, and dropping effect dependencies, which would risk stale seed values.

Validation

  • Base RED: focused regression failed because a same-connection refresh changed the edited value from 10 back to 2
  • npx vitest run --config vitest.config.ts tests/unit/ui/quota-cutoff-modal-draft-reset-7889.test.tsx — 1 passed
  • Focused quota UI matrix — 12 passed
  • npm run test:vitest:ui — 960 passed; 3 unrelated burn-rate-chart failures reproduced unchanged on the base revision
  • focused ESLint on the two production files and regression test
  • npm run typecheck:core
  • npm run check:dashboard-typecheck — within the frozen baseline
  • npm run check:file-size
  • npm run check:complexity
  • npm run check:changelog-integrity
  • npm run check:test-discovery
  • npm run test:coverage — not run locally; remote CI owns the full coverage gate

Tests Added Or Updated

  • tests/unit/ui/quota-cutoff-modal-draft-reset-7889.test.tsx
    • retains an unsaved value across same-connection prop refreshes
    • loads persisted values when the active connection changes

Coverage Notes

The regression exercises the state-lifetime branch added by this change. No production path is left without focused coverage.

Reviewer Notes

This is limited to modal draft initialization. It does not change API payloads, persisted cutoff values, or routing behavior.

@hydraxman
hydraxman requested a review from diegosouzapw as a code owner July 20, 2026 23:02
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Verified this locally: checked out the branch, ran the new regression test (tests/unit/ui/quota-cutoff-modal-draft-reset-7889.test.tsx) directly — passes, and it correctly exercises both halves of the fix (same-connection refresh keeps the unsaved draft, switching connections reseeds it). ESLint and tsc --noEmit are clean on both touched files, and the branch merges cleanly against the current release/v3.8.49 tip. The root-cause diagnosis (effect keyed on object/array identity of windows/current, which quota polling recreates on every refresh) is accurate, and keeping the full dependency list while gating the write with wasOpenRef/seededConnectionIdRef is a clean way to fix it without an eslint-disable.

One thing for the maintainer to reconcile before merge: PR #7921 lands a functionally equivalent fix for the same root cause in the same file (using a ref-based read of windows/current instead of the open/connection-transition guard). Only one of the two should land for #7889 — flagging so they don't get merged independently and double up the changelog entry. Nothing to change in this PR on its own merits — it's correct, minimal, and tested as-is.

@diegosouzapw
diegosouzapw merged commit 62cbbcd into cheaper-inference:release/v3.8.49 Jul 21, 2026
3 checks passed
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Merged — thanks @hydraxman! The wasOpenRef/seededConnectionIdRef gate is a clean fix for the QuotaCutoffModal snapping bug (#7889), and your PR landed before an equivalent internal one so the credit's yours. Nicely tested. (Merged on real CI green — a parallel monaco 0.56 dep bump had left our local validation box with stale node_modules, unrelated to this PR.)

@diegosouzapw diegosouzapw mentioned this pull request Jul 23, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
Co-authored-by: Bryan Nathan <bryan@users.noreply.github.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
Co-authored-by: Bryan Nathan <bryan@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.

fix: 'Edit cutoffs' input resets to default / clears immediately on Provider Quota page

3 participants