Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Nov 7, 2025

Adds a new required constructor argument ensureOnboardingComplete. This should be a promise that resolves once the user has been onboarded. We can use this to ensure that a user has fully onboarded and decided whether to opt-out of Snaps before using Snaps at all. The function is used as part of assertCanUsePlatform.


Note

Require onboarding completion via new ensureOnboardingComplete hook and asynchronously gate Snap operations (install, start, handle requests, registry updates) until onboarding finishes.

  • SnapController API:
    • Add required constructor hook ensureOnboardingComplete(): Promise<void> and store internally.
    • Make platform check async: #assertCanUsePlatform now awaits onboarding completion, then validates feature flags.
    • Await platform check in updateRegistry, startSnap, installSnaps, #updateSnap, and handleRequest.
  • Tests:
    • Add test ensuring requests wait for onboarding completion before execution.
    • Update helpers to pass mocked ensureOnboardingComplete by default.
    • Adjust call-count expectations and minor timing in affected tests; remove a couple of unused delegated actions in test utils.

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

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.28%. Comparing base (c8affd0) to head (dd19141).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3731   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files         418      418           
  Lines       12163    12177   +14     
  Branches     1881     1886    +5     
=======================================
+ Hits        11954    11968   +14     
  Misses        209      209           

☔ 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.


expect(result).toStrictEqual({ [MOCK_LOCAL_SNAP_ID]: truncatedSnap });

expect(messenger.call).toHaveBeenCalledTimes(12);
Copy link
Member Author

Choose a reason for hiding this comment

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

These seem to be changes in timing for when lifecycle hooks are called, due to the added async code we don't get as long in processing the side-effect before we reach the assertion.

snapController.removeSnap(snap.id),
promise,
]);
const removeSnap = async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a hack, but unsure how else to reproduce the race condition now

@FrederikBolding FrederikBolding changed the title feat: Wait for onboarding before allowing usage of SnapController feat!: Wait for onboarding before allowing usage of SnapController Nov 12, 2025
@FrederikBolding FrederikBolding changed the title feat!: Wait for onboarding before allowing usage of SnapController feat!: Ensure user has onboarded before allowing usage of SnapController Nov 12, 2025
@FrederikBolding FrederikBolding marked this pull request as ready for review November 12, 2025 14:49
@FrederikBolding FrederikBolding requested a review from a team as a code owner November 12, 2025 14:49
*
* @returns A promise that resolves when onboarding is complete.
*/
ensureOnboardingComplete: () => Promise<void>;
Copy link
Member

Choose a reason for hiding this comment

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

Can we not get this from the onboarding controller state?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately onboarding controller only exists on extension. On mobile the onboarding state is stored in Redux only, so we'll have to come up with a way to monitor that.

@FrederikBolding FrederikBolding added this pull request to the merge queue Nov 19, 2025
Merged via the queue into main with commit 31bd332 Nov 19, 2025
125 checks passed
@FrederikBolding FrederikBolding deleted the fb/wait-for-onboarding branch November 19, 2025 09:18
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.

3 participants