Skip to content

✨ dashboard: toast countdown progress bar - #15556

Merged
clubanderson merged 2 commits into
v5from
feat/toast-countdown-pause
Oct 29, 2026
Merged

clubanderson merged 2 commits into
v5from
feat/toast-countdown-pause

Conversation

@clubanderson

Copy link
Copy Markdown
Member

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

  • One mechanism. Every timed toast — success/info/warning, an error given an explicit deadline, and an in-flight toast resolved by dismissToast(el, msg) — arms through the single toastCountdownBar(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.
  • Right-to-left drain. 2 px bar on the bottom edge, 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-ttl and consumed by the CSS animation.
  • Pause on hover / focus-within, in sync with the timer. mouseenter/focusin clears the dismiss timer, banks the remaining ms and sets animation-play-state: paused in the same tick; mouseleave/focusout re-arms a timer for exactly the remainder and resumes the bar. A toast re-armed under the pointer stays held until the pointer leaves. dismissToast cancels any pending countdown first, so a rewrite or manual × can't be followed by a stale timer.
  • Subtle, both themes. Severity token at 40 % via color-mix(in srgb, var(--green) 40%, transparent) (currentColor 35 % for an unclassed toast); no track. Tokens only — no new raw hex/rgba for TestStyleRatchet.
  • Reduced motion keeps the bar (it's already linear) — a countdown is information, not decoration. The bar is aria-hidden; the toast's role/aria-live are untouched.
  • Docs: dashboard-sections.md gains a paragraph under Result toasts. Changelog fragment added. TestToastCountdownBarWiredToDismissTimer updated for the new contract (--toast-ttl, pause/resume wiring, cancel on dismiss, no display:none under 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) with remaining = 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.

t ≈ 0 mid (~3 s) hover held (1st toast) near end
dark dark t0 dark mid dark hover dark near end
light light t0 light mid light hover light near end

Local: go build ./... and go test ./pkg/dashboard/... green.

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15530 🐛 fix(dashboard): issue-row linked PR passes null when the lineage chip is empty same files src/pkg/dashboard/static/index.html
#15526 🌱 dashboard: split stage_tracker.go into 4 files same files src/docs/dashboard-sections.md
#15550 🐛 Activity monitor: an adoption pair never asks a human to pick a PR same files src/pkg/dashboard/static/index.html

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

  • toastCountdownBar sets --toast-ttl on the toast before appendChild(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, and cd.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 :782 parks the bar paused — so a toast rewritten while hovered does not drain while held.
  • pause() banks remaining from Date.now() - startedAt and no-ops when the timer is not running; resume() is guarded by el._countdown !== cd, so a stale closure from a cancelled countdown cannot re-arm after toastCountdownCancel nulls el._countdown. remaining reaching 0 while paused degenerates to setTimeout(fire, 0) on leave — fine.
  • focusout checks el.contains(e.relatedTarget); a null relatedTarget (focus leaving the window) resumes, which is the right default.
  • dismissToast now calls toastCountdownCancel(el) first (:845), so the old setTimeout can no longer fire onExpire against a rewritten toast — that was the latent bug in the previous version, where the timer was an anonymous setTimeout nobody 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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 060-reviewed: check-pending

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 060-reviewed → 050-review-pending: required-check-pending:build-and-test

@clubanderson
clubanderson merged commit add985e into v5 Oct 29, 2026
77 of 78 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/toast-countdown-pause branch October 29, 2026 23:27
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ dashboard: toast countdown bar should pause on hover/focus and drain right-to-left

1 participant