src/preferences/settings-window/tabs/controls/OverrideClickResolverSpecs.md
Line coverage:
OverrideClickResolver.swift93% · refreshed 2026-05-27 by/coverage-explore
In Settings, each shortcut can override the global Appearance values (style / size / theme /
shortcut-style). A segmented control shows either the global value (no override) or the override value.
OverrideClickResolver.decide is the pure kernel for "what should a click on that segment do": given the
clicked index, whether an override is currently set, the stored override value, the current global index,
and a valueAtIndex encoder, it returns .skip (no change) or .write(value:) (set/update the override).
The key invariant it encodes (the rules the user stated): an override's set/unset state and its value are independent. Clicking the currently-displayed value never changes state; clicking a different value writes/updates the override; and the only way to unset an override is the link button (never modeled as a click here).
hasOverride + globalIndex, not from UserDefaults. This matters
because the registered default for an override key can differ from the global — comparing against
UserDefaults (the old bug) wrote/skipped incorrectly..write re-encodes the new index via valueAtIndex (the persisted string isn't assumed to equal the
index).nil stored value with no override falls back to the global as the displayed value.Mirrors OverrideClickResolverTests.swift 1:1.
.skip..skip..skip (set-state survives; only the link button unsets)..skip (regression: don't compare against UserDefaults)..write..write (still set, new value)..write (regression: previously skipped)..write (stays set).valueAtIndex, not the raw index..write..skip..write (defensive: don't silently no-op).