Repository navigation
Conversation
Both provider cards picked the CooldownTimer target with
.filter(([k]) => k.startsWith("modelLock_")).map(([, v]) => v)
.filter(Boolean).sort()[0]
- the earliest lock, expired or not. isCooldown came from a separate scan
that did compare against now, so a connection carrying one lapsed lock and
one live one showed the cooldown badge (correct) beside a timestamp in the
past. CooldownTimer renders nothing once its target has gone by, so the
countdown silently disappeared exactly when there was more than one lock.
getEarliestModelLockUntil already existed for this -- its docblock says
"Used for UI cooldown display" -- and skips expired entries. Both cards now
ask it instead of keeping a fourth and fifth copy of the scan.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A connection carries one flat field per model lock —
modelLock_<model>, plusmodelLock___allfor the account-level one. Both provider cards picked the timestamp for their countdown like this:Earliest lock, expired or not.
isCooldownis computed separately, a few lines below, by a scan that does compare againstDate.now().So on a connection with one lapsed lock and one still live — which is the normal state after a per-model cooldown ends while an account-level one is running, or the other way round — the two disagree:
isCooldown→true, from the live lock. Correct.modelLockUntil→ the lapsed one, because it sorts first.CooldownTimersets its label to""and returnsnullas soon as its target is in the past. The badge says the connection is in cooldown and the countdown beside it is simply gone, with no error and nothing in the console.ConnectionRow.jseven carries a comment saying the effect handles theDate.now()comparison — it does, but only forisCooldown, not for the value that reaches the timer.The change
getEarliestModelLockUntilalready exists inopen-sse/services/accountFallback.js, its docblock says "Used for UI cooldown display", and it skips expired entries. Both cards now call it — for the timer target and forisCooldown— instead of keeping a fourth and fifth hand-rolled copy of the scan.The literal
"modelLock_"is currently spelled out in six places across the dashboard and once more as a localconstinsrc/app/api/models/availability/route.js, all of them re-deriving whatMODEL_LOCK_PREFIXand this helper already say. I have limited this PR to the two that were actually wrong; the rest is a tidy-up that can stand on its own.Verification
npx next build— 0 errors.The first five pin the helper's behaviour, including the exact reported shape: a lapsed lock that sorts first alongside two live ones.
The last four are a source-level check that both cards import the helper and no longer scan
modelLock_by hand. They are there because this bug is invisible to a behavioural test — the cards are client components and this repo has no React renderer in its test setup, so a card could go back to its own inline scan with every other test still green. That is exactly how the two copies drifted apart in the first place. RevertingConnectionsCard.jsalone fails those two cases and nothing else, which is the check I ran.