Skip to content

Add opt-in Apple Silicon CPU temperature sampling - #22

Merged
fdussert merged 2 commits into
fdussert:mainfrom
FlorianBruniaux:codex/mac-thermals-optin
Oct 15, 2026
Merged

fdussert merged 2 commits into
fdussert:mainfrom
FlorianBruniaux:codex/mac-thermals-optin

Conversation

@FlorianBruniaux

@FlorianBruniaux FlorianBruniaux commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The CPU tile can show Apple Silicon CPU temperature measured by the optional third-party tool macmon. The Screen privacy checkbox is off by default. Fremkit does not install macmon; the user installs it separately and then enables the checkbox.

After consent, the server reads only /opt/homebrew/bin/macmon or /usr/local/bin/macmon, requesting one background sample at most once every 10 seconds while the system channel is active. The first reading starts in a neutral state. Polling never waits for macmon. A failed refresh keeps the last good sample until it is 30 seconds old, then rejects it. The channel reports cpu.tempSource and cpu.tempError; the CPU tile explains missing, failed, invalid or unsupported readings and uses the existing system temperature when available. Disabling consent stops subsequent macmon reads.

The system provider is registered where the config store is available. The branch is rebased on the account-email privacy setting from #25 and preserves both independent switches. This PR is separate from the disk, memory, swap and uptime changes in #16.

Validation

  • pnpm typecheck and pnpm build passed after the rebase.
  • Server tests: 1,407 passed with test/app.test.ts excluded locally because its external favicon request timed out in this environment. UI tests: 385 passed.
  • Focused thermal and uptime tests: 25 passed.
  • Hardware temperature accuracy and the XENEON tile layout have not been verified with macmon installed. The live Fremkit installation was not changed for this PR.

@fdussert fdussert left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting this out so quickly, Florian! This is very close. Everything the #16 review asked for on the server side is there: nothing is spawned while the setting is off, it is read on every poll so toggling needs no restart, the reader returns the cached value right away and refreshes in the background, execFile uses fixed paths with an argument list, a timeout and maxBuffer, stale samples are rejected both when parsing and when reading, and gpuCelsius is gone. The system channel keeps its shape, so existing tiles are unaffected. Typecheck, the full suites and the UI build pass on my side. I could not test a real reading: macmon is not installed on this machine.

A few things before merging:

  1. Consent wording (ui/src/shared/locales/{en,fr}.ts). This checkbox is consent to run a third-party program, so it should name that program and say who installs it. Something like:

    • en label: "Read the CPU temperature with macmon"
    • en hint: "Off by default. macmon is a third-party open-source tool that Fremkit does not install; install it yourself (brew install macmon). Once on, on Apple Silicon, the server runs /opt/homebrew/bin/macmon or /usr/local/bin/macmon every 10 seconds to take one sample. Nothing else is run and the reading stays on this Mac. Without it, the CPU tile shows the temperature macOS reports, when it reports one."
    • fr label: "Lire la température du CPU avec macmon"
    • fr hint: "Désactivé par défaut. macmon est un outil tiers open source que Fremkit n'installe pas : installez-le vous-même (brew install macmon). Une fois activé, sur Apple Silicon, le serveur lance /opt/homebrew/bin/macmon ou /usr/local/bin/macmon toutes les 10 secondes pour une mesure. Rien d'autre n'est lancé et la mesure reste sur ce Mac. Sans lui, la tuile CPU affiche la température que macOS fournit, quand il en fournit une."

    Please also keep the new locale keys after the claudeUsage ones, in the same order as the checkboxes.

  2. Provider wiring (server/src/app.ts). Swapping systemProvider by identity inside the providers loop is easy to miss. Could you drop systemProvider from providers/index.ts and register createSystemProvider({ ... }) in app.ts next to createClaudeAccountProvider({ enabled }), with the same comment about the store living there?

  3. Feedback when macmon is missing or failing. The reader computes unconfigured / offline / invalid, but system.ts drops it, so someone who ticks the box without macmon installed sees nothing change and gets no hint why. An optional cpu.tempSource: 'macmon' | 'system' | null on the channel (backward compatible) would let the admin or the tile say so. Also, a single failed refresh currently clears the last good sample (mac-thermals.ts). Since the 30 s guard already bounds how old a sample can be, keeping the last good reading and setting error would match how the other providers behave.

  4. CHANGELOG. The entry opens a second ### Added under ## Unreleased. Please move it into the existing one and lead with a bold phrase like the other entries, for example: "CPU temperature from macmon. On Apple Silicon, the CPU tile can show the temperature measured by macmon, if you installed it. Turn it on under Screen → Privacy; it is off by default."

  5. Naming. privacy.macThermals only covers the CPU, and the setting is really consent to run macmon. Something like privacy.macmonTemperature would say what it covers. We have another privacy key coming (showAccountEmail) in the same spots in schema.ts, migrate.ts, types.ts and ScreenInspector.vue, so expect a small rebase depending on merge order.

  6. Style. createSystemProvider's returned object was not re-indented (system.ts), and a few lines in mac-thermals.ts and in the tests are very dense. Formatting them like the rest of server/ would help. The new migration test could also go inside the existing privacy describe block.

  7. Commits. "Reject stale cached temperature samples" reads as a fixup of the first commit. Could you squash it and add a short body explaining the why (opt-in, background refresh, stale rejection)?

  8. Docs (nice to have). A sentence in docs/widgets.md on how to install macmon and which two paths are tried.

Thanks again, the background refresh came out very clean!

@FlorianBruniaux
FlorianBruniaux force-pushed the codex/mac-thermals-optin branch 2 times, most recently from 6f9f9e7 to cffdd63 Compare October 15, 2026 15:53
@FlorianBruniaux
FlorianBruniaux force-pushed the codex/mac-thermals-optin branch from cffdd63 to 80b2240 Compare October 15, 2026 16:17
fdussert added a commit that referenced this pull request Oct 15, 2026
They compared the whole privacy section with toEqual, so the first
branch to add a key there (#14, #22) would break them with no git
conflict to say why. toMatchObject checks the two keys this setting is
about and nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FlorianBruniaux
FlorianBruniaux force-pushed the codex/mac-thermals-optin branch from 80b2240 to 3ae515a Compare October 15, 2026 16:31
@fdussert

Copy link
Copy Markdown
Owner

Thanks Florian, the rebase onto #16 looks good and system.ts reads much better now. Two small things before we merge:

  1. The branch still conflicts with main on CHANGELOG.md (Focus the exact cmux surface for Claude sessions #11 landed after your rebase).
  2. server/test/system-uptime.test.ts still imports systemProvider, which now only exists for that test (export const systemProvider = createSystemProvider() in system.ts). Could the test use createSystemProvider() so the module-level export can go?

Optionally: put the two locale keys after the claudeUsage ones, and start the reader in a neutral state so "macmon missing" doesn't flash before the first sample.

Heads-up on merge order: #25 (privacy.showAccountEmail) is about to land and touches the same privacy literals (schema.ts, migrate.ts, types.ts, ScreenInspector.vue, four UI tests), so expect small textual conflicts on your next rebase. Then feel free to mark it ready.

@FlorianBruniaux
FlorianBruniaux force-pushed the codex/mac-thermals-optin branch from 3ae515a to fa2299c Compare October 15, 2026 16:54
@FlorianBruniaux
FlorianBruniaux marked this pull request as ready for review October 15, 2026 16:54
@fdussert

Copy link
Copy Markdown
Owner

Thanks Florian, every point is addressed and the provider reads cleanly now. Could you rebase once more onto main? #14 (Codex) landed and adds codexAccount/codexHistorySources to the same privacy literals (schema.ts, migrate.ts, types.ts, ScreenInspector.vue and the four UI tests), so keep both sets of keys next to showAccountEmail. Optionally, the "· System temperature" suffix gets cut off at 8×4. Then it's good to merge.

FlorianBruniaux and others added 2 commits October 15, 2026 20:01
Keep the third-party reader inert until consent, refresh in the background, and reject expired samples without losing a recent reading on one failed refresh.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@fdussert
fdussert force-pushed the codex/mac-thermals-optin branch from fa2299c to a38e3d9 Compare October 15, 2026 18:01

@fdussert fdussert left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Florian — every point is addressed: consent wording that names macmon, the provider wired in app.ts, tempSource/tempError, no flash before the first sample, and the uptime test on createSystemProvider(). Approving. I rebased this on main myself to get it into 0.3.0: conflicts only, both sides kept, no change to your code, and you stay the author of every commit. If you push to this branch again, please git pull --rebase first. Thanks!

@fdussert
fdussert merged commit f689611 into fdussert:main Oct 15, 2026
1 check passed
@fdussert fdussert mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants