Repository navigation
fix(settings): re-poll reminder permission on foreground return - #929
Merged
Merged
Conversation
…ings.app
`openSystemSettings()` backgrounds the app into Settings.app without the
Settings screen ever leaving the view hierarchy, so the reminder section's
`.task { await model.onAppear() }` never re-fired on return — the row stayed
on the stale `denied` status until the user left and re-entered Settings.
Add a `scenePhase == .active` `.onChange` hook that re-calls the existing
`model.onAppear()` refresh path (reused, not duplicated). `onAppear()`'s
#817 one-shot migration is already TOCTOU-guarded, so repeat calls are safe.
Co-Authored-By: Claude Fable 5 <[email protected]>
CR round 1: the comment claimed BoardView / MinesweeperBoardView as precedent for this pattern, but their scenePhase handlers switch on .background/.inactive to pause and flush — the opposite edge. Only BannerSlotView (#341) is the same `guard newPhase == .active` re-poll. Comment-only; no behavior change. Co-Authored-By: Claude Fable 5 <[email protected]>
wei18
enabled auto-merge (squash)
July 21, 2026 09:32
This was referenced Jul 21, 2026
wei18
added a commit
that referenced
this pull request
Jul 21, 2026
…nd re-poll (#932) Closes the two contract gaps left open by the navigation audit: - SUD-BOARD-LOAD-FAILED listed three LoadState cases; there are four. .completedRedirect (#842) is a race guard that renders Completion inline when the open-time precheck finds the SavedGame already completed, rather than building a playable GameViewModel. MS reaches the same outcome via a different structure (its tier-2 guard view), so the apps mirror behaviorally but not structurally — worth knowing before unifying them. - REMINDER-DENIED said the user "returns manually" from the Settings.app deep-link, which was accurate only because no foreground hook existed. #929 added a scenePhase re-poll, so the row now re-reads permission state on every foreground return; noted along with why repeat calls are safe. Co-authored-by: Claude Fable 5 <[email protected]>
wei18
added a commit
that referenced
this pull request
Jul 23, 2026
…ives its status re-poll (#948) * fix(settings): host reminder sheets at screen root so the primer survives its status re-poll The daily-reminder primer sheet self-dismissed ~1s after presenting: both it and the denied-explainer were `.sheet` modifiers on ReminderSettingsSection's `Section`, a presentation host nested inside the Settings List. The tap-time async permission-status write swaps that Section's `switch model.status` row content mid-presentation; List row diffing duplicates the host, UIKit rejects the second present ("already presenting") and tears the primer down. Reproduced 4/4 on device + sim; distinct from #909's model-caching bug (intact). Both sheets now attach at the SettingsScreen root — a stable host outside any List row — still driven by the same ReminderSettingsModel via SettingsScreenReminderConfig. Adds a locale-independent `reminders.primer.sheet` anchor and an E2E regression guard (open primer, wait 3s past the old teardown window, assert still present). scenePhase re-poll (#929) and detents preserved. Closes #940 Co-Authored-By: Claude Fable 5 <[email protected]> * docs(settings): reword #940 binding comment and primer-anchor inventory line Round-1 review cosmetics: the comment overstated the AudioSettingsSection precedent (that wraps a non-optional model); reworded to describe the actual optional-nil behavior. Also detached the reminders.primer.sheet anchor from the "icon tile" phrase in the element inventory. Part of #940. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
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.
Found by a navigation-contract audit of all 22 screen contracts. The reminder row in Settings never refreshes after the user returns from the system Settings deep-link, so it keeps showing a stale
deniedstate.Why it happens
ReminderPermissionModel.openSettings()callsUIApplication.shared.open(openNotificationSettingsURLString), which backgrounds the app into Settings.app — this view never leaves the hierarchy. On return, SwiftUI does not re-fire.task(it only re-fires on identity change), so the existing.task { await model.onAppear() }— the only refresh path — never runs again. A grep acrossSettingsUIfound zeroscenePhase/willEnterForeground/didBecomeActivehooks.The intent was already documented:
ReminderPermissionModel.swift:37says the status is "refreshed viarefreshStatus()(call on foreground / before presenting the primer)". The foreground half was never wired.Symptom: grant permission in system Settings → return to the app → the reminder row still reads as denied until the user leaves Settings and re-enters. No data loss; the UI simply lies.
Fix
Add a
scenePhasere-poll alongside the existing.task, reusingmodel.onAppear()rather than duplicating the refresh call. This mirrors the pattern already used byBoardView,MinesweeperBoardViewandBannerSlotView(guard newPhase == .active), and is naturally cross-platform — unlike a UIKit-onlyNotificationCenterobserver. macOS has noopenNotificationSettingsURLString(the denial explainer shows textual guidance instead), so macOS never had the bug, but the hook is harmless there.Repeat calls are safe:
refreshStatus()is a plain re-read, and the #817 one-shot migration insideonAppear()is guarded bygetIsScheduled() == nilplus a post-await TOCTOU re-check. A new test pins this.Verification
swift test --package-path Packages/SettingsKit— 51 tests / 9 suites pass (including 2 new).swift test --package-path Packages/SudokuKit --no-parallel --filter Settings— 50 tests / 12 suites pass.swift test --package-path Packages/MinesweeperKit --no-parallel— 370 tests / 63 suites pass.swiftlint --stricton the changed files — 0 violations. No snapshot baselines changed.New tests: one drives denied → authorized-in-system-Settings → foreground return and asserts the status is re-read; one asserts a repeated
onAppear()neither re-runs the #817 migration nor clobbers a user's explicitdisable().Shared
SettingsKit, so both apps get the fix — both suites verified.🤖 Generated with Claude Code