Skip to content

Conversation

@Cal-L
Copy link
Contributor

@Cal-L Cal-L commented Jan 30, 2026

Description

The purpose of these changes is to extend the functionality of triggering the global Toast UI from services. In other words, with these changes, you can now show a toast from non-components by leveraging the ToastService. Example usage is ToastService.showToast or ToastService.closeToast.

Changelog

CHANGELOG entry:

Related issues

Fixes: #25463

Manual testing steps

  • Refer to unit tests since ToastService is not yet in use

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Introduces a global singleton that stores a React ref and throws/logs when unavailable, which can affect app-wide toast behavior if registration timing or lifecycle is off. Scope is otherwise small and covered by unit tests.

Overview
Enables triggering the global Toast UI from non-React code by adding a new core/ToastService singleton with showToast/closeToast APIs that proxy through a stored toast ref (and log+throw when the ref is missing).

Updates ToastContextWrapper to register its toastRef with ToastService on mount, and adds unit tests covering ref management, proxy behavior, and error paths.

Written by Cursor Bugbot for commit 7c2803c. This will update automatically on new commits. Configure here.

@Cal-L Cal-L requested a review from a team as a code owner January 30, 2026 19:31
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@Cal-L Cal-L added team-mobile-platform Mobile Platform team needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Jan 30, 2026
@Cal-L Cal-L added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed no changelog required No changelog entry is required for this change labels Jan 30, 2026
@github-project-automation github-project-automation bot moved this to Needs dev review in PR review queue Jan 30, 2026
@Cal-L Cal-L added the No QA Needed Apply this label when your PR does not need any QA effort. label Jan 30, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Jan 30, 2026
@Cal-L Cal-L enabled auto-merge January 30, 2026 21:43
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmationsRedesigned
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 80%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR introduces a new ToastService that allows showing toast notifications from non-React code (controllers, services). The changes include:

  1. A new ToastService class with showToast() and closeToast() methods
  2. Unit tests for the service
  3. A small modification to Toast.context.tsx to register the toast ref with the new service via useEffect

The risk is low because:

  • This is primarily a new feature addition, not modifying existing behavior
  • The existing ToastContext pattern continues to work unchanged
  • The new useEffect in ToastContextWrapper only registers the ref with the service
  • The ToastService is not yet being consumed anywhere in the codebase

However, since the ToastContextWrapper wraps the entire app (used in Root/index.tsx) and toasts are used across many features (accounts, permissions, predictions, perps, confirmations), I'm selecting SmokeAccounts and SmokeConfirmationsRedesigned to verify core toast functionality still works. These tags cover account-related toasts (address copying, account switching) and confirmation-related toasts which are common use cases.

Performance Test Selection:
This change introduces a new ToastService for showing toasts from non-React code. The modification to Toast.context.tsx only adds a useEffect hook to register a ref - this is a minimal change that doesn't affect rendering performance, data loading, or any critical user flows. The service itself is not yet being consumed anywhere, so there's no performance impact to measure.

View GitHub Actions results

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.45%. Comparing base (7e6bee4) to head (7c2803c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...mponent-library/components/Toast/Toast.context.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25464      +/-   ##
==========================================
- Coverage   80.28%   75.45%   -4.83%     
==========================================
  Files        4260     4261       +1     
  Lines      110124   110173      +49     
  Branches    23477    23475       -2     
==========================================
- Hits        88409    83130    -5279     
- Misses      15506    21015    +5509     
+ Partials     6209     6028     -181     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link

@Cal-L Cal-L added this pull request to the merge queue Jan 31, 2026
Merged via the queue into main with commit 1dd96c3 Jan 31, 2026
154 of 157 checks passed
@Cal-L Cal-L deleted the feat/25463-extend-toast-functionality branch January 31, 2026 02:17
@github-project-automation github-project-automation bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Jan 31, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2026
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 31, 2026
@metamaskbot metamaskbot added the release-7.65.0 Issue or pull request that will be included in release 7.65.0 label Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no changelog required No changelog entry is required for this change No QA Needed Apply this label when your PR does not need any QA effort. no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.65.0 Issue or pull request that will be included in release 7.65.0 size-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Extend toast functionality to be called from services

5 participants