feat: remember the selected profile across launches - #45
Open
bakirgdev-symphony wants to merge 1 commit into
Open
bakirgdev-symphony wants to merge 1 commit into
bakirgdev-symphony wants to merge 1 commit into
Conversation
activeProfile is initialised to .silent and never restored, so every restart, update, crash or logout silently hands the machine back to Apple's curve. Nothing tells the user: the daemon keeps running, the menu bar icon stays put, and the only symptom is that the machine runs hotter than it did yesterday until someone notices and re-picks a profile. A fan profile is a standing preference. Persist the chosen id and resolve it at launch, before startMonitoring() constructs the ThermalMonitor — restoring after that point would update the menu but not the monitor. Persisted from the three places the user expresses intent (selectProfile, setSmart, resetAuto) rather than from a didSet on activeProfile: the monitor's onUpdate writes that property every 500ms and its in-flight value can still carry the previous profile for one tick after a switch. Smart is not in loadAll() and a custom profile may have been deleted since it was chosen, so restore falls back to Apple's default rather than leaving the menu showing a profile the monitor is not running.
Author
|
hi. read #44 |
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.
What this fixes
AppState.activeProfileis initialised to.silentand never restored. Every app restart, update, crash or logout silently hands the machine back to Apple's fan curve.There is no signal that it happened. The daemon keeps running, the menu bar icon stays where it was, and the only symptom is that the machine runs hotter than it did yesterday until someone notices and re-picks a profile. On a machine that heats quickly this is the difference between the curve engaging on schedule and the 95°C safety override being the first thing that spins the fans.
The current
UserDefaultssurface persistsuseFahrenheitand the update-check bookkeeping, but not the one setting the whole app exists to express.Changes
Sources/ThermalForgeApp/AppState.swiftonly, no new dependencies, no protocol or daemon changes.activeProfileKeydefault.restoredProfile()resolves the stored id againstFanProfile.loadAll()at launch.startMonitoring(). That ordering matters:startMonitoring()passesactiveProfileinto theThermalMonitorit constructs, so restoring after that point would update the menu but leave the monitor on Silent.selectProfile,setSmart,resetAuto— rather than from adidSetonactiveProfile. The monitor'sonUpdatewrites that property every 500ms and its in-flight value can still carry the previous profile for one tick after aswitchProfile, so adidSetwould briefly persist the profile the user just moved away from.smartis not inloadAll()and is resolved explicitly. A custom profile deleted since it was chosen falls back to.silent, so the menu can never show a profile the monitor is not actually running.Interaction with existing behaviour
adoptDaemonStateOnLaunchstill reflects it andonFanCommandstill bails whileexternalHold != nil; the restored profile simply does not act until the hold clears.resetAuto(the Default button) persists.silent, so "give me back Apple's curve" is itself remembered rather than being undone by the next launch..silent, which is today's behaviour.Verification
swift build -c releaseclean (Swift 6.3.3, Xcode 26.6, arm64).swift test: 48 tests in 8 suites, all pass.Independent of #44 — separate branch off
main, no overlapping hunks.