Repository navigation
Skip restoring a toggle already in its remembered state [patch] - #65
Merged
Merged
Conversation
LoadPreferences called every persisted toggle's setter with the remembered value. A setter written as a flip (as the class example's is) then inverted a toggle whose remembered value matched its current state, and a setter that takes a resource on true took it a second time. Restore now reads the toggle's getter first and leaves it alone when it already matches; the getter read sits inside the same refusal handling as the setter. Fixes #61 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4brDwN4YAzA6oCKV6
|
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.



Fixes #61
What changed
TrayAppBuilder.LoadPreferencesnow reads each persisted toggle's getter (via a new internalTrayToggleItem.ReadState()) and calls the setter only when the current state differs from the remembered value._ => controller.Toggle(), as in the class example and CLAUDE.md) no longer inverts a remembered value that already matches.trueis no longer asked to acquire it again.FatalError.IsNotFatalhandling, so a throwing getter is reported like a refusing setter and restore continues with the next toggle.No public API change.
Tests
LoadPreferences_WhenTheToggleIsAlreadyInTheRememberedState_DoesNotCallTheSetter(falseandtrue): flip-style setter counting calls; ends in the remembered state with zero setter calls.LoadPreferences_WhenTheGetterThrows_KeepsGoingAndHandsBackTheMessage: guards the new getter read.With the state check removed, all three fail; with it, the full suite passes (163 passed, 1 skipped). Release build is clean.
Generated by Claude Code