Repository navigation
fix(macos): handle the no-sensor case — report "N/A" and keep the fan turning - #5
Merged
Merged
Conversation
Fan RPM and every temperature come from readHwmon(), which reads /sys/class/hwmon — Linux-only. On macOS that path does not exist, so fanRpm is null and the HUD rendered it as "Stopped", i.e. it stated the fan was stopped while the fan was in fact spinning. Add LiveStats.sensorsAvailable (true when hwmon reported any device) and use it to show an "N/A" state instead of "Stopped" in the HUD and in the cooling detail panel. Linux behaviour is unchanged: there hwmon exists, so a null fanRpm still means the fan really is stopped.
On macOS there is no hwmon at all, so fanRpm is always null and the 3D fan never turned — it read as broken rather than merely unmeasured, even while the real fan was spinning. When live data is present but sensorsAvailable is false, fall back to a slow idle spin so the model stays alive. Linux is unchanged: there hwmon exists, so a null reading genuinely means the fan is stopped.
Owner
|
@yuxino Thank you for the great contribution! 🙌 Really appreciate you digging into the macOS disk image issue and providing such a thorough fix. It’s great to have you contributing to PC·XRAY! 🚀 |
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 #4
Problem
Fan RPM and every temperature come from
readHwmon(), which reads/sys/class/hwmon— Linux-only. On macOS there is no such path, sofanRpmand all temperatures arenull. Two things then went wrong:Cooling.tsxdoeslive?.fanRpm ?? 0. It read as broken rather than merely unmeasured.Change 1 — stop claiming "Stopped"
LiveStatsgainssensorsAvailable, true only when hwmon reported at least one device. The two places that render the fan now tell three cases apart:Change 2 — keep the fan turning
Cooling.tsxnow picks its animation speed through one helper:On a platform with no sensors the blades idle-spin instead of sitting dead. Linux keeps its exact previous behaviour — including correctly showing a genuinely stopped fan.
Looped capture from this Mac — frozen before, turning after:
What this does NOT do
It does not invent a macOS sensor source; there is none without root (routes checked in #4). The HUD and the cooling panel still say "N/A" because the speed genuinely is not measured — the idle spin is a visual affordance (a laptop fan is always turning), not a reading. Temperatures still show "—".
Tested
/api/livereportssensorsAvailable: false; the HUD wentFan Stopped→Fan N/A.pnpm typecheckpasses.sensorsAvailable: true, so both the text and the animation are unchanged.