Repository navigation
feat(toast): queue toasts behind a limit, in priority order, and pause them away from the front - #2517
Open
im-apratap wants to merge 1 commit into
Open
feat(toast): queue toasts behind a limit, in priority order, and pause them away from the front#2517im-apratap wants to merge 1 commit into
im-apratap wants to merge 1 commit into
Conversation
…e them away from the front `base/toast.Manager.Visible(limit)` dropped the oldest toast and kept the newest, and `Advance` counted every toast's timeout down while it was hidden, so a toast the user never saw expired. A repeated id moved its toast to the newest slot, and nothing kept an error or a running job's progress in front. The Manager takes a Limit and presents the highest priority first, then the oldest, the rest waiting in their place with their motion and timeout not started; Waiting counts them. Push merges a repeated id into its toast's place, and PushPriority puts an error or progress ahead of the toasts waiting. ui.Toaster pauses the timeouts while the app is not in front, counts what waits, and shows errors and toasts that stay until dismissed first. ui.Toasts reads its toasts as a polite status region with Polite and takes entering and leaving from Motion, none under ReduceMotion. Part of nsgo-dev#2507. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This branch has not been deployed
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.
Part of #2507. This is the queue and the status region; the keyboard-focus pause and the Escape scoping are noted at the end.
What changes
base/toast.Managertakes aLimitand presents the highest priorities first, then the oldest, rather than the newest and dropping the oldest from view.Visible()returns what shows andWaiting()how many are behind it. A waiting toast keeps its place and does not move at all: its entering motion and its timeout start when it shows, so a toast the reader never saw no longer expires unseen.Pushof an existing id updates that toast where it is, keeping its position and its status, instead of moving it to the newest slot; one that is leaving shows again.PrioritywithPriorityNormalandPriorityHighandManager.PushPriorityorder the queue, so an error or a running job's progress stays in front of the toasts waiting.ui.ToastergivesToastErrorand a toast with a negativeDurationhigh priority without asking, andToastContent.Prioritysays otherwise.ui.Toasterpassescx.Env().Lifecycle() != core.LifecycleActivethroughAdvance, so a window in the background holds the countdown instead of running toasts out unseen.Toaster.Waiting()is a signal's value, so a stack's own+Nfollows the queue.toast.Toast.Politereads it ascore.RoleStatus, which is a polite live region, rather thancore.RoleAlert;ui.Toasts.Politeapplies it to every toast but errors.ui.Toasts.Motionsets the entering and leaving durations (Sonner's where a field is zero), andReduceMotionleaves none.tsx/toasts.gofollows:visible(limit)sets the manager's limit, and entries expose theirpriority.Verification
go tool nsgo check -target linux— vetted forlinux_arm64andlinux_x64.go tool nsgo test ./base/toast— 4 passed, includingTestToastLimitQueuesAndPushMergesInPlace(queue order, in-place merge, priority, the leaving toast making room) andTestToastWaitingKeepsItsTimeoutUntilItShows(a waiting toast's timeout begins when it shows).go tool nsgo test ./ui— 269 passed, includingTestToastsQueue(limit 1 shows the oldest, an error takes the slot, a polite toast readsRoleStatusand an errorRoleAlert, and a background window holds the countdown).go tool nsgo test ./tsx— 311 passed.go tool nsgo test -run Toast ./examples/gallery— 2 passed.go run ./tools/changelog check— valid.Still open in #2507
coresets itsFocusWithinstate internally and exposes no query or signal for a view to read it, so this needs a core API first. I did not invent one here.OnCancel), as before; scoping it depends on the same focus information.I can follow up on both once the focus API is settled, or add whichever of them you want in this PR.
🤖 Generated with Codebuff