Fix LA not refreshing on foreground after stale overlay#576
Merged
bjorkert merged 1 commit intoloopandlearn:live-activityfrom Mar 26, 2026
Merged
Conversation
startIfNeeded() unconditionally reused any existing activity, which meant that on cold start (app killed while stale overlay was showing) willEnterForeground is never sent, handleForeground never runs, and viewDidAppear → startFromCurrentState → startIfNeeded just rebinds to the stale activity — leaving the overlay visible. Fix: before reusing an existing activity in startIfNeeded(), check whether its staleDate has passed or the renewal window is open. If so, end it (awaited) and call startIfNeeded() again so a fresh activity with a new 7.5h deadline is started. Also add cancelRenewalFailedNotification() to handleForeground() so the "Live Activity Expiring" system notification is dismissed whenever the foreground restart path fires, not only via forceRestart(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
startIfNeeded()reused stale activities on cold start — when the app is killed while the renewal overlay is showing,willEnterForegroundis never sent on relaunch, sohandleForeground()never runs. The cold-start path (viewDidAppear → startFromCurrentState → startIfNeeded) found the existing stale activity and rebound to it, leaving the overlay visible. Fix: before reusing an existing activity, checkexisting.content.staleDateand the renewal window; if stale, end it (awaited) and restart.handleForeground()clearedlaRenewalFailedandlaRenewBybut never calledcancelRenewalFailedNotification(), leaving the system notification visible after the LA successfully restarted.Test plan
🤖 Generated with Claude Code