Skip to content

Prevent copied-code toast stacking - #1095

Merged
tannerlinsley merged 1 commit into
mainfrom
agent/dedupe-code-copy-toast
Aug 2, 2026
Merged

Prevent copied-code toast stacking#1095
tannerlinsley merged 1 commit into
mainfrom
agent/dedupe-code-copy-toast

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Aug 2, 2026

Copy link
Copy Markdown
Member

What changed

Allow the shared toast wrapper to accept Sonner's stable id option, then reuse one ID for code-copy confirmations.

Root cause and impact

CodeBlockView created a new toast for every copy action. Repeated copies therefore accumulated distinct notifications and could cover the documentation viewport, as reported in #960.

With a stable code-copy toast ID, Sonner updates the existing confirmation instead of stacking another one. Other notifications keep their current independent behavior.

Closes #960

Validation

  • pnpm test
  • TypeScript clean
  • oxlint clean
  • 143 tests passed; 1 environment-gated docs smoke test skipped
  • Commit hook reran formatting and the full test gate successfully
  • git diff --check

Risk

Low. The new toast option is optional, and only code-copy confirmations opt into deduplication.

Summary by CodeRabbit

  • Bug Fixes
    • Improved code-copy notifications to prevent duplicate toast messages when copying code repeatedly.

@tannerlinsley tannerlinsley added the source-audit Tracked by the automated source audit label Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Toast options now support optional identifiers. ToastProvider passes identifiers to Sonner. Code-copy confirmations use the stable identifier code-copied.

Changes

Toast identifier support

Layer / File(s) Summary
Toast option and provider forwarding
src/components/ToastProvider.tsx
Toast options accept string or numeric identifiers. ToastProvider forwards the identifier to Sonner with the configured duration.
Code-copy notification identifier
src/components/markdown/CodeBlockView.tsx
Code-copy confirmation notifications use the identifier code-copied.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes assign a stable ID to copied-code toasts, allowing Sonner to replace the existing notification as required by issue #960.
Out of Scope Changes check ✅ Passed All changes support the linked issue by extending toast ID handling and applying it only to copied-code notifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing repeated copied-code toast notifications from stacking.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/dedupe-code-copy-toast

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com bcbd6c1 Commit Preview URL

Branch Preview URL
Aug 02 2026, 03:12 PM

@tannerlinsley
tannerlinsley merged commit 57b452f into main Aug 2, 2026
7 checks passed
@tannerlinsley
tannerlinsley deleted the agent/dedupe-code-copy-toast branch August 2, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

source-audit Tracked by the automated source audit

Projects

None yet

2 participants