Fix stale overlay tap: redesign .dismissed state machine#585
Merged
bjorkert merged 1 commit intoloopandlearn:live-activityfrom Mar 29, 2026
Merged
Fix stale overlay tap: redesign .dismissed state machine#585bjorkert merged 1 commit intoloopandlearn:live-activityfrom
bjorkert merged 1 commit intoloopandlearn:live-activityfrom
Conversation
Three clearly separated .dismissed sources:
(a) endingForRestart — our own end() during planned restart, ignore
(b) iOS system force-dismiss — renewalFailed OR pastDeadline (now >= laRenewBy)
→ auto-restart on next foreground, laRenewBy preserved
(c) User decision — explicit swipe
→ dismissedByUser=true, laRenewBy=0 (renewal intent cancelled)
Remove staleDatePassed: staleDate expiry fires .ended not .dismissed.
Preserve laRenewBy on .ended and system .dismissed so handleForeground()
detects the renewal window and restarts on next foreground. Only the
user-swipe path clears laRenewBy, preventing handleForeground() from
re-entering the renewal path after the user explicitly killed the LA.
Fix handleForeground() nil-current path: reaching it means iOS ended the
LA while the renewal window was open (laRenewBy still set). A user-swipe
would have cleared laRenewBy to 0, so overlayIsShowing would be false
and this branch would never be reached — startFromCurrentState() is safe.
Set renewalWarning to 30 minutes (overlay appears 30 min before 7.5h deadline).
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
Redesign
.dismissedstate machine: Three explicitly separated sources of.dismissed— our own planned restart (endingForRestart), iOS system force-dismiss (renewalFailedorpastDeadline), and user decision (explicit swipe). Only a true user swipe setsdismissedByUser = trueand blocks auto-restart.Remove
staleDatePassed: Stale date expiry fires.ended, not.dismissed, so it was the wrong discriminator. Replaced withpastDeadline = now >= laRenewByfor the system-dismiss check.Preserve
laRenewByon.endedand system.dismissed:handleForeground()can now detect the renewal window on the next foreground event and restart automatically — whether iOS ended the LA normally or force-dismissed it. Only a user swipe clearslaRenewByto cancel the renewal intent.Fix
handleForeground()nil-current path: Whencurrentis nil and the renewal window is open, the LA was ended by iOS (a user swipe would have clearedlaRenewByto 0, makingoverlayIsShowingfalse and bypassing this branch entirely).startFromCurrentState()now proceeds correctly in this case.Widen overlay window to 30 minutes (was 20 min) before the 7.5-hour renewal deadline.
🤖 Generated with Claude Code