Skip to content

Conversation

@fabiobozzo
Copy link
Contributor

@fabiobozzo fabiobozzo commented Nov 6, 2025

Description

This PR fixes a bug where turning off backup and sync during onboarding didn't persist the user's preference. After completing onboarding, the backup and sync toggles in Settings would still show as "ON" instead of respecting the user's choice to turn them off.

Root Cause:

  1. A useEffect in privacy-settings.js was automatically forcing backup & sync to follow the basic functionality toggle, overriding manual user choices
  2. When the main backup & sync toggle was disabled, sub-features (accounts/contacts syncing) weren't being turned off, creating visual inconsistency

Solution:

  • Removed the automatic coupling between backup & sync and basic functionality during onboarding to respect manual user choices
  • Implemented smart toggle behavior that provides both visual clarity and user convenience:
    • When B&S OFF: All sub-features also turn OFF (visual consistency)
    • When B&S ON: All sub-features also turn ON (1-click restore convenience)
  • Fixed async race conditions in cascading effects with proper error handling
  • Added comprehensive test coverage for all toggle scenarios

Changelog

CHANGELOG entry: fixed backup and sync toggle not persisting user's choice during onboarding

Related issues

Fixes: #35546

Manual testing steps

  1. Start a fresh onboarding flow (create new wallet or import SRP)
  2. Navigate to the "Default settings" screen during onboarding
  3. Click on "General" category
  4. Turn OFF the "Turn on backup and sync" toggle (should show as OFF)
  5. Complete the onboarding process
  6. Navigate to Settings → Backup and sync
  7. Verify all toggles show correctly:
    • "Turn on backup and sync": OFF ☑️
    • "Accounts": OFF ☑️
    • "Contacts": OFF ☑️

Additional test case:

  1. Repeat steps 1-4 but turn OFF "Basic functionality" toggle first
  2. Verify backup & sync automatically turns OFF (cascading effect)
  3. Complete onboarding and verify settings persist as OFF

Screenshots/Recordings

Before

  • Main backup & sync toggle showed correctly as OFF
  • Sub-feature toggles (Accounts/Contacts) incorrectly showed as ON (though disabled)

(see bug)

After

  • All toggles correctly show as OFF when user disables backup & sync during onboarding
  • User's choice persists after completing onboarding
Screen.Recording.2025-11-06.at.13.58.00.mov

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

Disables backup & sync and its sub-features when basic functionality is off (prod or onboarding) and when toggled off, and removes onboarding auto-binding to backup & sync; adds targeted tests.

  • Backup & Sync Toggle (ui/components/app/identity/backup-and-sync-toggle/backup-and-sync-toggle.tsx):
    • Disable BACKUPANDSYNC_FEATURES.main, accountSyncing, and contactSyncing when basic functionality is disabled in either production or onboarding state.
    • When user turns backup & sync off, also disable all sub-features.
    • When turning on while basic functionality is disabled, show CONFIRM_TURN_ON_BACKUP_AND_SYNC_MODAL_NAME.
    • Include onboarding basic functionality state in effect dependencies and add error guard.
  • Onboarding Privacy Settings (ui/pages/onboarding-flow/privacy-settings/privacy-settings.js):
    • Remove backup & sync auto-binding to basic functionality and related error UI/logic.
    • Keep metric reporting using selectIsBackupAndSyncEnabled.
  • Tests (backup-and-sync-toggle.test.tsx):
    • Add scenarios verifying cascade-disable under production/onboarding basic functionality states and manual toggle-off.
    • Ensure no disable occurs when both basic functionality states are enabled.

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

This commit improves the backup and sync feature by ensuring that when basic functionality is disabled, the main backup and sync feature, along with its sub-features (account syncing and contact syncing), are also turned off. Additionally, it removes unused imports and related code from the privacy settings page, streamlining the component.
@fabiobozzo fabiobozzo requested review from a team as code owners November 6, 2025 13:00
@metamaskbot metamaskbot added the team-accounts-framework Accounts Framework team label Nov 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

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.

@metamaskbot
Copy link
Collaborator

metamaskbot commented Nov 6, 2025

✨ Files requiring CODEOWNER review ✨

🔑 @MetaMask/accounts-engineers (2 files, +243 -7)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 identity/
          • 📁 backup-and-sync-toggle/
            • 📄 backup-and-sync-toggle.test.tsx +185 -4
            • 📄 backup-and-sync-toggle.tsx +58 -3

🔐 @MetaMask/web3auth (1 files, +1 -31)
  • 📁 ui/
    • 📁 pages/
      • 📁 onboarding-flow/
        • 📁 privacy-settings/
          • 📄 privacy-settings.js +1 -31

@fabiobozzo fabiobozzo changed the title fix: tie backup and sync in onboarding to settings fix: bind backup and sync in onboarding to settings Nov 6, 2025
This commit introduces new tests for the BackupAndSyncToggle component, ensuring that all backup and sync features are disabled when basic functionality is turned off. It also verifies that all sub-features are disabled when the backup and sync toggle is manually turned off. Additionally, the component's useEffect is updated to handle asynchronous feature disabling correctly.
@github-actions github-actions bot added size-M and removed size-S labels Nov 6, 2025
This commit adds new tests to the BackupAndSyncToggle component, verifying that all backup and sync features are disabled when basic functionality is turned off, both for production and onboarding states. It also checks that features remain enabled when both states are active, ensuring comprehensive coverage of the component's behavior in various scenarios.
@metamaskbot
Copy link
Collaborator

Builds ready [981d2ba]
UI Startup Metrics (1219 ± 85 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1219107715358512661363
load104691812947611001176
domContentLoaded103991212827610951165
domInteractive2114106161856
firstPaint67279132641610561151
backgroundConnect2312182456235242
firstReactRender2718177172745
getState2075592537
initialActions001001
loadScripts815676106275868941
setupStore1062841119
numNetworkReqs1367619671
BrowserifyPower User HomeuiStartup19621785242324423532423
load1032909137318212761373
domContentLoaded1024902136117912711361
domInteractive291684214384
firstPaint85124913823759611382
backgroundConnect2342242506237250
firstReactRender26243022830
getState18616421517204215
initialActions001001
loadScripts800676112717710471127
setupStore13102861328
numNetworkReqs1187125169172251
WebpackStandard HomeuiStartup8497231246908601102
load621564103683615854
domContentLoaded61455999878609835
domInteractive171273101541
firstPaint193631041192193599
backgroundConnect251274132655
firstReactRender29184583539
getState1162131316
initialActions001001
loadScripts61155798876607824
setupStore1364061428
numNetworkReqs1367219871
WebpackPower User HomeuiStartup13011157188021514511880
load66156810951437131095
domContentLoaded63655710601256941060
domInteractive39122135056213
firstPaint4146310643036981064
backgroundConnect48101664855166
firstReactRender27232812828
getState14810517319159173
initialActions001011
loadScripts63155510471226841047
setupStore1062871028
numNetworkReqs1086821959186219
FirefoxBrowserifyStandard HomeuiStartup14861286197412015621699
load1261111414648513301432
domContentLoaded1260111414648513301432
domInteractive1193434361125302
firstPaint------
backgroundConnect4526120195388
firstReactRender27217772740
getState84608721
initialActions002001
loadScripts1233109614298212951389
setupStore156206211330
numNetworkReqs1266314754
BrowserifyPower User HomeuiStartup24092071329033326403290
load13111092162216715041622
domContentLoaded13111091162216715041622
domInteractive17744550148284550
firstPaint------
backgroundConnect993325367132253
firstReactRender39295584755
getState1247619933135199
initialActions001011
loadScripts12811072159616914721596
setupStore281069214169
numNetworkReqs1347131284198312
WebpackStandard HomeuiStartup15941411214815016232025
load1358120117599714001541
domContentLoaded1358120117599714001540
domInteractive1023047757106177
firstPaint------
backgroundConnect4425111195088
firstReactRender302386113142
getState9315216719
initialActions001001
loadScripts1330118517349313751484
setupStore177144201374
numNetworkReqs1367117765
WebpackPower User HomeuiStartup24382167331629426603316
load14921304191916715671919
domContentLoaded14911304191916715671919
domInteractive13438395102178395
firstPaint------
backgroundConnect833221349100213
firstReactRender36304854248
getState1199016019134160
initialActions101011
loadScripts14601277186916215251869
setupStore32121303146130
numNetworkReqs1285731483201314
📊 Page Load Benchmark Results

Current Commit: 981d2ba | Date: 11/6/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±38ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 724ms (±36ms) 🟢 | historical mean value: 720ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±10ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 38ms 1.01s 1.31s 1.09s 1.31s
domContentLoaded 724ms 36ms 702ms 987ms 758ms 987ms
firstPaint 76ms 10ms 56ms 156ms 84ms 156ms
firstContentfulPaint 76ms 10ms 56ms 156ms 84ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: -265 Bytes (0%)
  • common: 20 Bytes (0%)

This commit updates the tests for the BackupAndSyncToggle component to ensure that when the main toggle is activated, all associated sub-features (account syncing and contact syncing) are also enabled. The tests now include checks for the asynchronous behavior of the toggle handler and confirm that the modal's callback correctly enables all features. Additionally, the component's implementation is adjusted to ensure all sub-features are activated consistently.
@metamaskbot
Copy link
Collaborator

Builds ready [bef18ac]
UI Startup Metrics (1232 ± 117 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12321082204911712951390
load106493317279911221198
domContentLoaded105792617189811161190
domInteractive2214101151865
firstPaint659166122141410631160
backgroundConnect23321728710237250
firstReactRender27185183044
getState2074782439
initialActions002001
loadScripts830704147496889959
setupStore1162441121
numNetworkReqs1367419670
BrowserifyPower User HomeuiStartup18791736236618819632366
load1035888154419912511544
domContentLoaded1028881153719812431537
domInteractive291593224393
firstPaint829196154643412481546
backgroundConnect23822128618243286
firstReactRender27243322833
getState16914919515185195
initialActions001001
loadScripts803667125718810171257
setupStore11101921119
numNetworkReqs1167224657151246
WebpackStandard HomeuiStartup85671213951038651106
load624570114491617866
domContentLoaded617565110887609853
domInteractive161285101443
firstPaint197641152204164629
backgroundConnect261178142862
firstReactRender301896103539
getState1161831316
initialActions001001
loadScripts613563109784607842
setupStore1264251419
numNetworkReqs1367719871
WebpackPower User HomeuiStartup12161128156911212591569
load62956282283652822
domContentLoaded61555280576640805
domInteractive28131242932124
firstPaint27577813239566813
backgroundConnect51162065951206
firstReactRender26242922729
getState1399115821151158
initialActions001001
loadScripts61155079573630795
setupStore962551025
numNetworkReqs1056916839163168
FirefoxBrowserifyStandard HomeuiStartup15841387232216316281959
load1327119816099814021519
domContentLoaded1326119716099814021518
domInteractive1223838867126322
firstPaint------
backgroundConnect51261752957148
firstReactRender29235762946
getState11420523834
initialActions001011
loadScripts1296117715779213741487
setupStore198211261652
numNetworkReqs1367217764
BrowserifyPower User HomeuiStartup24792174312727626963127
load14631233193423917771934
domContentLoaded14621232193424017771934
domInteractive23897633189464633
firstPaint------
backgroundConnect1154738095141380
firstReactRender433379104479
getState1149114315130143
initialActions101111
loadScripts14241204187023617351870
setupStore2951203750120
numNetworkReqs1336823560199235
WebpackStandard HomeuiStartup16911431213116017172076
load14381245182111414921696
domContentLoaded14381244182111414921696
domInteractive982821131110159
firstPaint------
backgroundConnect55221852860116
firstReactRender30249483143
getState84779817
initialActions001001
loadScripts14021226174510614641632
setupStore15880101542
numNetworkReqs1366917764
WebpackPower User HomeuiStartup25252199301925627363019
load15501270203621817332036
domContentLoaded15491269203621817332036
domInteractive16938653179338653
firstPaint------
backgroundConnect1182929284226292
firstReactRender39315054650
getState1157317930145179
initialActions101011
loadScripts15141250198420916521984
setupStore2861022946102
numNetworkReqs1306526665199266
📊 Page Load Benchmark Results

Current Commit: bef18ac | Date: 11/7/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±38ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 718ms (±36ms) 🟢 | historical mean value: 718ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±12ms) 🟢 | historical mean value: 76ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 38ms 1.01s 1.31s 1.06s 1.31s
domContentLoaded 718ms 36ms 698ms 982ms 743ms 982ms
firstPaint 75ms 12ms 56ms 176ms 84ms 176ms
firstContentfulPaint 75ms 12ms 56ms 176ms 84ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 962 Bytes (0.02%)
  • ui: -1.76 KiB (-0.02%)
  • common: 19.28 KiB (0.22%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-M team-accounts-framework Accounts Framework team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Turning off backup and sync in onboarding still leaves the toggles as "on" in settings

3 participants