Skip to content

feat(toast): migrate to sonner library - #589

Merged
bordalix merged 6 commits into
masterfrom
wt-toast-sonner-20260430
May 7, 2026
Merged

bordalix merged 6 commits into
masterfrom
wt-toast-sonner-20260430

Conversation

@sahilc0

@sahilc0 sahilc0 commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace custom React Context-based toast implementation with sonner
  • Maintain backward compatibility via useToast() hook
  • Simplify Toast.tsx from 97 lines to 35

Changes

  • Add sonner@2.0.7 dependency
  • ToastProvider now wraps children with sonner's <Toaster />
  • useToast() returns { toast } for backward compat (consumers can migrate to importing toast directly)
  • Preserve existing toast styling (dark theme, shadows, 2s duration)

Test plan

  • Build passes
  • 179 unit tests pass
  • QR tap-to-copy shows toast
  • Copy buttons throughout app show toast

Summary by CodeRabbit

  • New Features

    • Replaced custom toast system with an external toast library for consistent notifications and a 2000ms default duration.
    • Backup screen can preload a developer private key when running in a dev environment.
  • Style

    • Added toast UI styles to improve positioning and layout of notifications.
  • Chores

    • Added a runtime dependency for the new toast library and performed a minor code cleanup.

Replace custom React Context-based toast implementation with sonner.
Maintains backward compatibility via useToast() hook that returns { toast }.

- Add sonner@2.0.7 dependency
- Simplify Toast.tsx from 97 lines to 35
- Preserve existing toast styling (colors, shadows, duration)
@sahilc0
sahilc0 requested review from bordalix and pietro909 April 30, 2026 17:51
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Deploying wallet-bitcoin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 467f230
Status: ✅  Deploy successful!
Preview URL: https://5db6aaa8.wallet-bitcoin.pages.dev
Branch Preview URL: https://wt-toast-sonner-20260430.wallet-bitcoin.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 467f230
Status: ✅  Deploy successful!
Preview URL: https://a9c8f268.arkade-wallet.pages.dev
Branch Preview URL: https://wt-toast-sonner-20260430.arkade-wallet.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Deploying tmp-boltz-upstream-mainnet-arkade-wallet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 467f230
Status: ✅  Deploy successful!
Preview URL: https://b127dff4.tmp-boltz-upstream-mainnet-arkade-wallet.pages.dev
Branch Preview URL: https://wt-toast-sonner-20260430.tmp-boltz-upstream-mainnet-arkade-wallet.pages.dev

View logs

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — clean library swap, no protocol impact

Reviewed full diff + all 8 consumer call sites. This is a UI-only change (toast notifications) with zero protocol-critical surface.

Findings

CI failure — Prettier formatting (must fix before merge)
src/components/Toast.tsx fails the format:check step. Run pnpm format:write or prettier --write src/components/Toast.tsx and push.

Backward compatibility — verified ✅
All 8 consumers use const { toast } = useToast() → toast('string'). The new useToast() returns { toast } wrapping sonner's toast function, which accepts a string as its first argument. All call sites are compatible without changes:

  • src/components/Text.tsx:68
  • src/components/Table.tsx:18
  • src/components/ExpandAddresses.tsx:36
  • src/screens/Settings/Backup.tsx:38
  • src/screens/Settings/Logs.tsx:19
  • src/screens/Settings/Delegates.tsx:126
  • src/screens/Wallet/Receive/QrCode.tsx:58

Test wrappers (ToastProvider in test files) remain compatible — ToastProvider still renders {children}.

Minor nits (non-blocking):

  • toast-in / toast-out CSS keyframe animations were referenced in the old code but defined inline (not in a CSS file), so no dead CSS to clean up. Clean.
  • The fallback colors #1a1a1a / #fafafa on var(--toast-bg) / var(--toast-color) are a nice improvement over the old code which had no fallbacks.
  • textAlign: 'center' as const — correct TypeScript narrowing, fine.

Not protocol-critical. No VTXO, signing, forfeit, round, or exit path code touched.


🔧 Action needed: fix Prettier formatting, then this is good to merge.

🤖 Arkana

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — clean library swap, no protocol impact

Reviewed full diff + all 8 consumer call sites. This is a UI-only change (toast notifications) with zero protocol-critical surface.

Findings

CI failure — Prettier formatting (must fix before merge)
src/components/Toast.tsx fails the format:check step. Run pnpm format:write or prettier --write src/components/Toast.tsx and push.

Backward compatibility — verified ✅
All 8 consumers use const { toast } = useToast() → toast('string'). The new useToast() returns { toast } wrapping sonner's toast function, which accepts a string as its first argument. All call sites are compatible without changes:

  • src/components/Text.tsx:68
  • src/components/Table.tsx:18
  • src/components/ExpandAddresses.tsx:36
  • src/screens/Settings/Backup.tsx:38
  • src/screens/Settings/Logs.tsx:19
  • src/screens/Settings/Delegates.tsx:126
  • src/screens/Wallet/Receive/QrCode.tsx:58

Test wrappers (ToastProvider in test files) remain compatible — ToastProvider still renders {children}.

Minor nits (non-blocking):

  • No orphaned CSS — old toast-in/toast-out animations were inline styles, not in a stylesheet. Clean.
  • Fallback colors #1a1a1a/#fafafa on CSS vars are an improvement over the old code which had no fallbacks.
  • textAlign: 'center' as const — correct TypeScript narrowing.

Not protocol-critical. No VTXO, signing, forfeit, round, or exit path code touched.


🔧 Action needed: fix Prettier formatting, then this is good to merge.

🤖 Arkana

@coderabbitai

coderabbitai Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5cf4a1c3-be34-4c75-854d-6ece1b854d83

📥 Commits

Reviewing files that changed from the base of the PR and between bd2e957 and 467f230.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json
  • src/providers/config.tsx
  • src/screens/Settings/Backup.tsx
💤 Files with no reviewable changes (1)
  • src/screens/Settings/Backup.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/providers/config.tsx

Walkthrough

Replaces the custom toast implementation with sonner (adds sonner), re-exports toast, adapts useToast and ToastProvider to render sonner’s Toaster with new CSS, adds VITE_DEV_NSEC typing, conditionally overrides config.aspUrl from VITE_ARK_SERVER in dev when appropriate, and removes a stray console.log in backup settings.

Changes

Toast System Migration

Layer / File(s) Summary
Dependency
package.json
Added sonner ^2.0.7.
Imports / Exports / Hook
src/components/Toast.tsx
Import Toaster and toast from sonner; re-export toast; useToast now returns { toast }.
Provider / UI
src/components/Toast.tsx, src/components/Toast.css
ToastProvider now renders sonner’s Toaster (position, classNames, styles, duration 2000ms); added .arkade-toast-toaster and centering/content CSS.
Tests / Docs
(none changed)
No test or documentation files altered in this cohort.

Dev Environment Overrides

Layer / File(s) Summary
Env Typing
src/vite-env.d.ts
Added readonly VITE_DEV_NSEC?: string to ImportMetaEnv.
Config Constants / Helper
src/providers/config.tsx
Imported devServer and added shouldUseDevEnvArkServer helper.
Config Loading / Wiring
src/providers/config.tsx
Reads VITE_ARK_SERVER into devArkServer and conditionally overrides config.aspUrl during initial config load when dev-server conditions are met.
Feature Toggle / Screen
src/screens/Settings/Backup.tsx
Removed a stray console.log in toggleNostrBackup; behavior otherwise unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(toast): migrate to sonner library' accurately and specifically describes the main change: replacing the custom toast implementation with the sonner library.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 wt-toast-sonner-20260430

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 and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Toast.tsx`:
- Around line 12-33: Prettier flagged formatting in the Toast component JSX
(around the Toaster usage); re-run the project's formatter (e.g., Prettier) on
src/components/Toast.tsx or manually reformat the JSX block containing Toaster
and children so it matches the repo's style rules, then save and commit the
updated file; specifically ensure the Toaster prop formatting (position,
richColors, toastOptions, style) and trailing commas/spacing conform to the
configured formatter so CI style checks pass.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09216df2-a37b-4a91-bbc5-2af15b194c89

📥 Commits

Reviewing files that changed from the base of the PR and between 580df0f and 1e46de0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • src/components/Toast.tsx

Comment thread src/components/Toast.tsx Resolved
@sahilc0

sahilc0 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Merge order

This PR is independent and can merge anytime.

Related PRs:

This sonner migration is standalone — no dependency on Tailwind.

@sahilc0 sahilc0 mentioned this pull request Apr 30, 2026
3 tasks done

@bordalix bordalix left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sahilc0 personal opinion, but I think the text in the toast should be centered:

Screen.Recording.2026-05-05.at.16.13.08.mov

sahilc0 added 2 commits May 6, 2026 15:46
Center Sonner toast boxes and their text so short copy confirmations hug their content instead of using the default fixed-width left-aligned layout.

Add scoped toast CSS for the Sonner toaster and content wrapper while preserving the existing toast colors, padding, duration, and top-center placement.
Keep local dev sessions on the configured Arkade server when VITE_DEV_NSEC and VITE_ARK_SERVER are present, even if earlier localStorage pointed at the localhost ASP.

Allow the Backup screen to reveal the dev nsec directly in development so the funded default wallet can exercise private-key copy toasts without an impossible password prompt.
@sahilc0

sahilc0 commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@bordalix updated this based on your suggestion. Good call — the default Sonner layout keeps a fixed-width toast with left-anchored content, so I added a scoped override to center the toast and make it hug the message content.

@sahilc0
sahilc0 requested a review from bordalix May 6, 2026 19:47

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Re-reviewed new commits — still approved

Three commits since my last review (April 30):

40ea642 — fix(toast): format sonner toaster props

Prettier fix I flagged. ✅

e36624e — fix(toast): center sonner content

New Toast.css with data-sonner-toaster centering overrides. Addresses bordalix's feedback. CSS-only, no logic changes. ✅

bd2e957 — chore(dev): honor funded wallet env

Extends existing VITE_DEV_NSEC pattern (already in wallet.tsx, App.tsx) to two more files:

  • config.tsx: shouldUseDevEnvArkServer() overrides aspUrl when DEV && VITE_DEV_NSEC && VITE_ARK_SERVER && aspUrl === devServer. Guard on aspUrl === devServer prevents accidentally redirecting a mainnet wallet. Correct.
  • Backup.tsx: Skips password verification in dev mode, sets nsec directly from env. import.meta.env.DEV guard ensures dead-code elimination in prod builds. Consistent with existing pattern.
  • Backup.tsx:91: Removed console.log that was printing config (potentially including sensitive data). Good cleanup.
  • vite-env.d.ts: Adds VITE_DEV_NSEC type declaration. .env.local is gitignored. ✅

Minor nit (non-blocking): shouldUseDevEnvArkServer already checks import.meta.env.VITE_ARK_SERVER is truthy, making the && devArkServer check at the call site redundant. Harmless.

Not protocol-critical. No VTXO, signing, forfeit, round, or exit path code touched.

🤖 Arkana

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/providers/config.tsx`:
- Around line 76-77: The predicate shouldUseDevEnvArkServer currently ties the
VITE_ARK_SERVER override to VITE_DEV_NSEC; remove that unrelated gate so the
override only requires dev mode and the VITE_ARK_SERVER flag. Update the
function (shouldUseDevEnvArkServer) to return true when import.meta.env.DEV &&
import.meta.env.VITE_ARK_SERVER && aspUrl === devServer, removing the
import.meta.env.VITE_DEV_NSEC check.

In `@src/screens/Settings/Backup.tsx`:
- Around line 48-50: The code uses import.meta.env.VITE_DEV_NSEC (checked under
import.meta.env.DEV) to setNsec directly, which exposes a secret via
client-facing VITE_* env vars; replace this with a non-sensitive, clearly
test-only fixture or load the value from a local-only mechanism that never
enters the frontend build (e.g., a developer-only config file or secure IPC/read
from filesystem in dev mode). Update the branch that references
import.meta.env.VITE_DEV_NSEC and setNsec to instead use the sanitized test
value or local-only loader and add a comment documenting that this value is
strictly test/dev-only and must not be committed to production or a VITE_* env
var.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66f5eab9-e667-452f-a64f-0710e356e77a

📥 Commits

Reviewing files that changed from the base of the PR and between 1e46de0 and bd2e957.

📒 Files selected for processing (5)
  • src/components/Toast.css
  • src/components/Toast.tsx
  • src/providers/config.tsx
  • src/screens/Settings/Backup.tsx
  • src/vite-env.d.ts

Comment thread src/providers/config.tsx Resolved
Comment thread src/screens/Settings/Backup.tsx Resolved
Remove the Backup screen shortcut that read VITE_DEV_NSEC directly from client code, keeping private key display on the normal password verification path.

Keep the local Ark server override independent from the funded wallet env so stale localhost config can still recover during development.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Re-reviewed — 4 new commits since last review, all clean

What changed

40ea642 — format fix
Addresses the Prettier issue I flagged. ✅

e36624e — toast centering CSS
New Toast.css with sonner override selectors for centered positioning. Pure cosmetic, no issues.

bd2e957 — dev server config override
shouldUseDevEnvArkServer() in config.tsx:76-77 is properly triple-gated: import.meta.env.DEV && import.meta.env.VITE_ARK_SERVER && aspUrl === devServer. Cannot fire in production. Clean.

35fb075 — remove console.log + add VITE_DEV_NSEC type

  • Removes console.log('Updating backup with new config', newConfig) from Backup.tsx:91 — good, stops leaking config objects to console.
  • Adds VITE_DEV_NSEC type declaration to vite-env.d.ts — just TypeScript typing for an env var already consumed by App.tsx and wallet.tsx on main.

Scope note

PR has expanded beyond toast migration to include dev-environment tooling. Consider splitting if this grows further, but current scope is fine.

Not protocol-critical. No VTXO, signing, forfeit, round, or exit path code touched.

🤖 Arkana

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Re-reviewed — 4 new commits since last review, all clean

What changed

40ea642 — format fix
Addresses the Prettier issue I flagged. ✅

e36624e — toast centering CSS
New Toast.css with sonner override selectors for centered positioning. Pure cosmetic, no issues.

bd2e957 — dev server config override
shouldUseDevEnvArkServer() in config.tsx:76-77 is properly triple-gated: import.meta.env.DEV && import.meta.env.VITE_ARK_SERVER && aspUrl === devServer. Cannot fire in production. Clean.

35fb075 — remove console.log + add VITE_DEV_NSEC type

  • Removes console.log('Updating backup with new config', newConfig) from Backup.tsx:91 — good, stops leaking config objects to console.
  • Adds VITE_DEV_NSEC type declaration to vite-env.d.ts — just TypeScript typing for an env var already consumed by App.tsx and wallet.tsx on main.

Scope note

PR has expanded beyond toast migration to include dev-environment tooling. Consider splitting if this grows further, but current scope is fine.

Not protocol-critical. No VTXO, signing, forfeit, round, or exit path code touched.

🤖 Arkana

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Re-reviewed new commits — still clean, approval maintained

Focused on delta since my last review (3 new commits + merge from master).

New changes reviewed

src/components/Toast.css — centering CSS for sonner toasts. Pure layout, no issues.

src/providers/config.tsx — shouldUseDevEnvArkServer() overrides localhost:7070 with VITE_ARK_SERVER in dev. Gated by import.meta.env.DEV → dead code in production builds. Safe.

src/screens/Settings/Backup.tsx — removes a stray console.log. Trivial.

src/vite-env.d.ts — adds VITE_DEV_NSEC type declaration for the already-used env var in App.tsx:103-104 and wallet.tsx:155. Was previously missing from the type file.

Security note ✅

Commit chore(dev): honor funded wallet env briefly added a Backup screen shortcut that read VITE_DEV_NSEC directly. Commit fix(dev): avoid exposing funded key in backup correctly reverted that — keeping the private key on the normal password-verification path. Good catch by the author.

Minor nit (non-blocking)

config.tsx:76: shouldUseDevEnvArkServer already checks import.meta.env.VITE_ARK_SERVER is truthy, then line 144 checks devArkServer (same value) again. Redundant but harmless.

Not protocol-critical. No VTXO, signing, forfeit, round, or exit path code touched.

🤖 Arkana

@bordalix
bordalix merged commit 7066839 into master May 7, 2026
6 checks passed
@bordalix
bordalix deleted the wt-toast-sonner-20260430 branch May 7, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants