Skip to content

Conversation

@Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Jul 21, 2025

This adds support for the onActive and onInactive lifecycle hooks. It's accomplished by exposing a new setActive action in the Snap controller, which should be called by the clients when the active status changes.

Related to #3541.

*
* @param active - A boolean indicating whether the client is active or not.
*/
setActive(active: boolean) {
Copy link
Member Author

@Mrtenz Mrtenz Jul 21, 2025

Choose a reason for hiding this comment

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

This seems to be the easiest solution given that at least the extension doesn't seem to emit any events when the active status changes. I'm open to other suggestions though.

https://github.com/MetaMask/metamask-extension/blob/6e6be317110039c50f85d2768d24e9c81f3f395b/app/scripts/metamask-controller.js#L8585-L8592

@Mrtenz Mrtenz marked this pull request as ready for review July 21, 2025 20:00
@Mrtenz Mrtenz requested a review from a team as a code owner July 21, 2025 20:00
@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.26%. Comparing base (8c54f0c) to head (213b366).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3542   +/-   ##
=======================================
  Coverage   98.26%   98.26%           
=======================================
  Files         411      411           
  Lines       11624    11637   +13     
  Branches     1810     1814    +4     
=======================================
+ Hits        11422    11435   +13     
  Misses        202      202           

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

cursor[bot]

This comment was marked as outdated.

@Mrtenz Mrtenz requested a review from GuillaumeRx July 22, 2025 09:17
@Mrtenz Mrtenz requested a review from GuillaumeRx July 22, 2025 09:40
@Mrtenz Mrtenz added this pull request to the merge queue Jul 22, 2025
Merged via the queue into main with commit fb11d7a Jul 22, 2025
120 checks passed
@Mrtenz Mrtenz deleted the mrtenz/active-lifecycle-hook branch July 22, 2025 09:48
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