Repository navigation
fix(pill): stop capturing UserDefaults in the look observer - #476
Merged
Merged
Conversation
The look observer in GlassBackdropCache.startObserving captured defaults and a local lastLook var in a @sendable closure, giving three SendableClosureCaptures warnings (315:62, 316:27, 317:13). lastLook is now an instance property and the closure calls a main-actor defaultsDidChange() through a weak self. Adds tests for unrelated writes, changed looks and the initial look.
scttbnsn
requested review from
ALARGECOMPANY,
biggest-littlest and
dstahl11
as code owners
October 26, 2026 03:38
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
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.
The look observer in GlassBackdropCache.startObserving captured the defaults and a local lastLook var in a @sendable notification closure. That produced three SendableClosureCaptures warnings (capture of UserDefaults at 315:62, reference to lastLook at 316:27, mutation of lastLook at 317:13) that a warnings-as-errors build only passed because they were not promoted.
lastLook is now an instance property, and the closure only calls a new main-actor defaultsDidChange() through a weak self, which reads the settings the cache already stores. Behavior is the same: an unrelated defaults write does nothing, a skin or size change prewarms once. Added tests for the unrelated-write, changed-look and start-of-observing cases.
Verified: swift build -Xswiftc -warnings-as-errors prints 0 Sources warnings (only the known mlx-swift_Cmlx.bundle missing-creator build-system warning remains), swift-format lint --strict is clean on both files, and scripts/swift-test.sh --no-parallel --filter 'GlassPill|PillFollowUp' passes 38 tests in 9 suites.