Commit 48891cd
chore(runway): cherry-pick fix(perps): improve connection toast (swipe dismiss, delay, styling) cp-7.64.0 (#25659)
- fix(perps): improve connection toast (swipe dismiss, delay, styling)
cp-7.64.0 (#25569)
## **Description**
This PR improves the Perps WebSocket connection toast (the banner that
shows "Your connection is offline", "Connecting...", or "Connected" when
the WebSocket state changes).
## **Changelog**
CHANGELOG entry: Added swipe-to-dismiss and 1 second delay for the Perps
connection banner; improved toast styling with default/muted backgrounds
and highest z-index.
## **Related issues**
Fixes: #25570
Jira issue: https://consensyssoftware.atlassian.net/browse/TAT-2453
## **Manual testing steps**
```gherkin
Feature: Perps connection toast
Scenario: user sees and dismisses offline banner
Given user is on a screen where Perps WebSocket is connected
When connection drops and 1 second passes
Then the "Your connection is offline" banner appears at the top
And user can swipe the banner left or right to dismiss it
And after dismissing, the banner does not show again until connection is restored and drops again
Scenario: banner does not flicker on quick reconnect
Given user is on a screen where Perps WebSocket is connected
When connection drops and reconnects within 1 second
Then the offline banner does not appear
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
See here https://consensyssoftware.atlassian.net/browse/TAT-2453
### **After**
<!-- [screenshots/recordings] -->
<img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17
Pro - 2026-02-03 at 11 39 17"
src="https://github.com/user-attachments/assets/8656ba68-5dd3-4584-bae0-765aa60e1f51"
/>
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk because it changes toast display timing/state transitions
(new 1s delay and user-dismiss suppression) and adds gesture-driven
dismissal, which could affect when users see connection status banners.
>
> **Overview**
> **Improves Perps WebSocket connection toast UX and behavior.** The
toast can now be swipe-dismissed left/right; dismissing sets a
`userDismissed` flag so repeated `Disconnected` banners are suppressed
until reconnection, while `Connecting`/`Connected` can still show and
clear the suppression.
>
> **Reduces banner flicker and refreshes styling.**
`useWebSocketHealthToast` now delays `Disconnected`/`Connecting` toasts
by 1s (and cancels the timer on reconnect/unmount), while `Connected`
still shows immediately; the toast UI adds a wrapper/inner muted
background and updates tests to reflect the new delay and
animation/timer behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d73b504. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
[9642300](9642300)
Co-authored-by: Michal Szorad <michal.szorad@consensys.net>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent a1313ef commit 48891cd
7 files changed
Lines changed: 373 additions & 82 deletions
File tree
- app/components/UI/Perps
- components/PerpsWebSocketHealthToast
- hooks
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
163 | 206 | | |
164 | 207 | | |
165 | 208 | | |
| |||
app/components/UI/Perps/components/PerpsWebSocketHealthToast/PerpsWebSocketHealthToast.context.tsx
Lines changed: 62 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
4 | 10 | | |
| |||
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
16 | 28 | | |
17 | 29 | | |
18 | 30 | | |
| |||
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
25 | | - | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| |||
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
56 | 69 | | |
57 | 70 | | |
58 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
59 | 99 | | |
60 | 100 | | |
61 | 101 | | |
62 | 102 | | |
63 | 103 | | |
64 | 104 | | |
65 | | - | |
| 105 | + | |
66 | 106 | | |
67 | 107 | | |
68 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
69 | 112 | | |
70 | 113 | | |
71 | 114 | | |
72 | 115 | | |
73 | 116 | | |
74 | 117 | | |
75 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
76 | 130 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 131 | + | |
80 | 132 | | |
81 | 133 | | |
82 | 134 | | |
| |||
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 16 | + | |
| 17 | + | |
23 | 18 | | |
24 | 19 | | |
| 20 | + | |
| 21 | + | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
| |||
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
| |||
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
253 | 255 | | |
254 | 256 | | |
255 | 257 | | |
| |||
0 commit comments