Repository navigation
Make mobile toast swipes reliable - #2984
Conversation
|
🚨 SLOP COP 🚨 · I am the SlopCop. I am now reviewing this pull request for security, code quality, performance, duplication, and user behavior. |
| return null; | ||
| } | ||
| const elementPosition = `${toastElement.dataset.yPosition}-${toastElement.dataset.xPosition}`; | ||
| const activeToasts = toast.getToasts(); |
There was a problem hiding this comment.
🚨 slopcop/review — This index can select and dismiss the wrong toast during another toast's exit.
Sonner keeps the exit element and its data-index for 200 ms. toast.getToasts() removes it immediately.
I reproduced this with three stacked toasts. A flick on the middle toast called the oldest toast's onDismiss.
Please use a stable toast identity. Add a test that flicks again before the first exit completes.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary
This change helps mobile notifications respond to short left, right, and upward flicks. It adds a fallback when Sonner misses a fast gesture.
Finding
- Medium: A rapid second flick can dismiss the wrong stacked notification. I reproduced this in the app with three notifications.
The exit element keeps its DOM index for 200 ms. Sonner removes the same notification from toast.getToasts() immediately.
The two lists then have different indexes. The fallback can call onDismiss for a notification that the user did not touch.
See the inline finding. Please use a stable notification identity and add a rapid stacked-notification test.
Other checks
- The security review found no security or trust-boundary issue.
- The full app test suite passed 3,805 tests. Four tests remained skipped.
- The app type check passed.
- A real Chrome mobile test dismissed one notification after one move.
- The rapid stacked test reproduced the wrong-notification dismissal.
- The event listeners attach once and detach correctly.
- Each touch start scans Sonner's retained notification history. This cost grows with long sessions, but it is a secondary concern.
I found no exact duplicate. useHorizontalDismissDrag has related drag code, but it supports one horizontal direction and panel progress.
Direct reuse would need a larger change. An upstream Sonner fix offers the cleaner long-term design.
I posted this as a comment-only review. I did not approve or request changes.
## Human comments ## What was wrong The compact-web toast gesture added in #2984 could leave Sonner's swipe state active when Safari canceled a pointer or dropped pointer capture. The toast stayed displaced, and Sonner treated the stack as interacting, which could pause later automatic dismissals indefinitely. The app also carried a second gesture implementation alongside Sonner's own tracker. ## What changed - Patch Sonner 1.7.4 to reset interrupted pointer gestures and resume toast timers on pointer cancellation or capture loss. - Keep immediate axis selection, toast-button tap/drag arbitration, and click suppression inside the toast library. - Remove the app's duplicate 184-line pointer tracker while preserving compact left, right, and upward dismissal. - Add focused regressions for both pointer cancellation and pointer-capture loss. ## How you verified - `CI=1 pnpm install --frozen-lockfile --ignore-scripts` - `pnpm exec turbo run test --filter=@bb/app --force -- 'src/components/AppToaster.test.tsx'` (10/10 passed) - `pnpm exec turbo run typecheck build --filter=@bb/app --force` - Targeted `oxfmt --check` - `git diff --check origin/main...HEAD` - The fixer also ran the full app suite (3,852 passed, 3 skipped), lint with 0 errors, and compact/desktop browser QA before handoff. > AGENT GENERATED
Human comments
What was wrong
Compact toasts render at
top-center, while Sonner derives an upward-only swipe direction from that position and processes the first pointer movement before its React-managed axis has updated. The archived-thread toast exposed a second, more important gap: its linked thread title, Undo action, and close control are buttons, and Sonner deliberately does not begin a swipe when the pointer target is a button. That made most of the real "Thread Archived" toast a swipe dead zone even though plain diagnostic toasts felt reliable.What changed
There is no server/host-daemon wire change, so
HOST_DAEMON_PROTOCOL_VERSIONis unchanged. No CLI, SDK, guide, or user-facing configuration surface changed.How you verified
130.8px, and Sonner reporteddirection: right,removed: true, andswipeOut: trueat pointer-up.pnpm exec turbo run test --filter=@bb/app --force -- --run src/components/AppToaster.test.tsx— 8 tests passed.pnpm exec turbo run typecheck --filter=@bb/app— passed.pnpm exec turbo run lint --filter=@bb/app— passed with 178 existing warnings in unrelated files and 0 errors.pnpm exec oxfmt apps/app/src/components/AppToaster.tsx apps/app/src/components/AppToaster.test.tsxandgit diff --check— passed.