feat: Implement AppLifecycleService and refactor to fix auto updater
#530
+264
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Alright here's what I found in the cave...
context: the auto updater seems to be broken because the
before-quitevent handler unconditionally calledevent.preventDefault()followed byapp.exit(0)to perform cleanup.the bug: when
autoUpdater.quitAndInstall()was invoked, it triggered thebefore-quitevent, but the handler would intercept it, prevent the default behavior, and forcibly exit the app before the updater could complete its installation flow.solution: this PR introduces a new
AppLifecycleServicethat centralizes all shutdown logic and tracks anisQuittingForUpdateflag. Now when installing an update, theUpdatesServicefirst callslifecycleService.shutdown()to gracefully clean up, then setslifecycleService.setQuittingForUpdate()before callingquitAndInstall(). Thebefore-quithandler now checks this flag and returns early if set, allowing the auto updater to proceed unblocked. This separates the "normal quit with cleanup" path from the "quit for update" pathNOTE: There is a different event sequence for
quitAndInstall()Excerpt taken from electron docs
The Event Sequence for
quitAndInstall()Normal quit:
before-quitemittedcloseeventswill-quitemittedquitAndInstall()sequence (different!):closeevents firstbefore-quitemitted after windows are closed