Repository navigation
✨ dashboard: toast countdown progress bar - #15556
Conversation
…to-left Every timed toast's 2px bottom bar now shares one lifetime with its dismiss timer through --toast-ttl, set on the toast by toastCountdownBar; the bar scales from 1 to 0 with its origin on the left so the filled region recedes right-to-left. Pointer hover or keyboard focus inside the toast clears the timer, banks the remaining milliseconds and pauses the bar's animation at the same instant; leaving re-arms the timer for exactly the remainder and resumes the bar, so the two never drift. dismissToast cancels any pending countdown before a rewrite or manual close so a stale timer cannot fire. The bar is the severity token at 40% over transparent (currentColor 35% for an unclassed toast), with no track, so it reads in dark and light mode without competing with the copy; it stays under reduced motion (a linear countdown is information, not decoration). Sticky errors and persistent spinner toasts still carry no bar. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Conclusion: traced the countdown state machine in tooltips-dialogs.js and the CSS; the timer and bar stay in lockstep in every path I could construct. Looks correct to me.
What I verified (static-src/js/tooltips-dialogs.js)
toastCountdownBarsets--toast-ttlon the toast beforeappendChild(bar)(:751-753), so the CSS animation (alerts-toasts.css:88,animation: toast-bar-drain var(--toast-ttl, 3000ms) linear forwards) starts with the right duration on insertion, andcd.resume()starts the timer in the same tick.- Re-arm under the pointer:
el.matches(':hover')/el.contains(document.activeElement)pre-set the flags (:779-780),resume()then returns early, and:782parks the barpaused— so a toast rewritten while hovered does not drain while held. pause()banksremainingfromDate.now() - startedAtand no-ops when the timer is not running;resume()is guarded byel._countdown !== cd, so a stale closure from a cancelled countdown cannot re-arm aftertoastCountdownCancelnullsel._countdown.remainingreaching 0 while paused degenerates tosetTimeout(fire, 0)on leave — fine.focusoutchecksel.contains(e.relatedTarget); a nullrelatedTarget(focus leaving the window) resumes, which is the right default.dismissToastnow callstoastCountdownCancel(el)first (:845), so the oldsetTimeoutcan no longer fireonExpireagainst a rewritten toast — that was the latent bug in the previous version, where the timer was an anonymoussetTimeoutnobody could clear. Listeners are wired once per element (_countdownWired), so repeated re-arms do not stack handlers.
One design note, not a defect: prefers-reduced-motion: reduce previously hid the bar (display: none) and now keeps it animating (alerts-toasts.css:95). The body argues the bar is information, not decoration; a 2 px linear scale is about as gentle as motion gets, so I think that is defensible, just flagging that it is a deliberate reversal of the earlier choice.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission → 060-reviewed: check-pending |
|
stage 060-reviewed → 050-review-pending: required-check-pending:build-and-test |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #15555
Owner request: "all toast messages need a horizontal progress bar which runs right to left to countdown the time the message has until closed. subtle and easy to read." The first cut (#15231) added the bar; this finishes it.
What changes
dismissToast(el, msg)— arms through the singletoastCountdownBar(el, ms, onExpire)helper (3 call sites, unchanged). Sticky toasts (errors,stageTrackerResultToast) and the persistent spinner toast carry no bar because they have no deadline.transform-origin: left; scaleX(1→0), so the filled region recedes from the right. Duration is the toast's real lifetime, published on the toast as--toast-ttland consumed by the CSS animation.mouseenter/focusinclears the dismiss timer, banks the remaining ms and setsanimation-play-state: pausedin the same tick;mouseleave/focusoutre-arms a timer for exactly the remainder and resumes the bar. A toast re-armed under the pointer stays held until the pointer leaves.dismissToastcancels any pending countdown first, so a rewrite or manual × can't be followed by a stale timer.color-mix(in srgb, var(--green) 40%, transparent)(currentColor35 % for an unclassed toast); no track. Tokens only — no new raw hex/rgba forTestStyleRatchet.aria-hidden; the toast's role/aria-live are untouched.dashboard-sections.mdgains a paragraph under Result toasts. Changelog fragment added.TestToastCountdownBarWiredToDismissTimerupdated for the new contract (--toast-ttl, pause/resume wiring, cancel on dismiss, nodisplay:noneunder reduced motion).Verified (Puppeteer, headless Chrome, 6 s toasts; sticky error for contrast)
Instrumented run: on hover the first toast's bar froze at
scaleX(0.461)withremaining = 2711 ms(0.461 × 6000 ≈ 2766 — in sync), held there for 1.5 s while the siblings kept draining, then resumed and dismissed ~2.7 s after the pointer left. Sticky error: no bar, no--toast-ttl.Local:
go build ./...andgo test ./pkg/dashboard/...green.