Skip to content

Skip restoring a toggle already in its remembered state [patch] - #65

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/restore-skips-current-state
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/restore-skips-current-state

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #61

What changed

  • TrayAppBuilder.LoadPreferences now reads each persisted toggle's getter (via a new internal TrayToggleItem.ReadState()) and calls the setter only when the current state differs from the remembered value.
    • A flip-style setter (_ => controller.Toggle(), as in the class example and CLAUDE.md) no longer inverts a remembered value that already matches.
    • A setter that acquires a resource on true is no longer asked to acquire it again.
  • The getter read sits inside the existing FatalError.IsNotFatal handling, 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 (false and true): 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

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
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit ecaa832 into main Nov 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants