Skip to content

Fix/m1 rpm display and desktop power - #89

Closed
offyotto wants to merge 2 commits into
mainfrom
fix/m1-rpm-display-and-desktop-power
Closed

offyotto wants to merge 2 commits into
mainfrom
fix/m1-rpm-display-and-desktop-power

Conversation

@offyotto

@offyotto offyotto commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Change

Describe the problem and the change.

Verification

List the checks you ran.

  • Tests cover the changed behavior.
  • User-facing changes are documented.
  • Security-sensitive changes were reviewed for privilege, XPC, signing, and SMC impact.

Previously values >=1000 RPM were abbreviated to e.g. "1.3k",
causing the fan gauge on M1 Macs to show confusing abbreviated
values instead of the actual RPM reading (e.g. 1300).

Fixes part of #52
Desktop Macs (Mac Studio M1/M2, Mac mini M1+) have no
AppleSmartBattery, so batteryInfo.powerWatts was always nil and
the Power page always showed "-- W".

Fixes:
- Read SMC key PSTR (system-total power on Apple Silicon desktops)
- Fall back to PSTR when batteryInfo.powerWatts is nil
- Last resort: sum PCPU + PGPU component readings

Fixes part of #52
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

guard sysctlbyname(name, &value, &size, nil, 0) == 0 else { return nil }
return Int(value)
}
aW1wb3J0IEZvdW5kYXRpb24KaW1wb3J0IENvbWJpbmUKaW1wb3J0IElPS2l0CmltcG9ydCBJT0tpdC5wcwppbXBvcnQgRGFyd2luCmltcG9ydCBDb3JlQXVkaW8KCnN0cnVjdCBDUFVTdGF0cyB7CiAgICBsZXQgdXNhZ2VQZXJjZW50OiBEb3VibGUKICAgIGxldCBwZXJmb3JtYW5jZUNvcmVVc2FnZVBlcmNlbnQ6IERvdWJsZT8KICAgIGxldCBlZmZpY2llbmN5Q29yZVVzYWdlUGVyY2VudDogRG91YmxlPwp9CgpzdHJ1Y3QgQ1BVQ2x1c3RlclByb2Nlc3NvclJhbmdlczogRXF1YXRhYmxlIHsKICAgIGxldCBwZXJmb3JtYW5jZTogUmFuZ2U8SW50PgogICAgbGV0IGVmZmljaWVuY3k6IFJhbmdlPEludD4/CgogICAgc3RhdGljIGZ1bmMgcmVzb2x2ZSgKICAgICAgICBjcHVDb3VudDogSW50LAogICAgICAgIHBlcmZvcm1hbmNlQ29yZUNvdW50OiBJbnQsCiAgICAgICAgZWZmaWNpZW5jeUNvcmVDb3VudDogSW50CiAgICApIC0+IENQVUNsdXN0ZXJQcm9jZXNzb3JSYW5nZXM/IHsKICAgICAgICBsZXQgcGVyZm9ybWFuY2VDb3VudCA9IG1pbihtYXgocGVyZm9ybWFuY2VDb3JlQ291bnQsIDApLCBjcHVDb3VudCkKICAgICAgICBsZXQgZWZmaWNpZW5jeUNvdW50ID0gbWluKG1heChlZmZpY2llbmN5Q29yZUNvdW50LCAwKSwgbWF4KDAsIGNwdUNvdW50IC0gcGVyZm9ybWFuY2VDb3VudCkpCiAgICAgICAgZ3VhcmQgcGVyZm9ybWFuY2VDb3VudCA+IDAsIHBlcmZvcm1hbmNlQ291bnQgKyBlZmZpY2llbmN5Q291bnQgPD0gY3B1Q291bnQgZWxzZSB7CiAgICAgICAgICAgIHJldHVybiBuaWwKICAgICAgICB9CiAgICAgICAgbGV0IHBlcmZvcm1hbmNlU3RhcnQgPSBlZmZpY2llbmN5Q291bnQKICAgICAgICByZXR1cm4gQ1BVQ2x1c3RlclByb2Nlc3NvclJhbmdlcygKICAgICAgICAgICAgcGVyZm9ybWFuY2U6IHBlcmZvcm1hbmNlU3RhcnQuLjwocGVyZm9ybWFuY2VTdGFydCArIHBlcmZvcm1hbmNlQ291bnQpLAogICAgICAgICAgICBlZmZpY2llbmN5OiBlZmZpY2llbmN5Q291bnQgPiAwID8gMC4uPGVmZmljaWVuY3lDb3VudCA6IG5pbAogICAgICAgICkKICAgIH0KfQo= No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 Bug: PR truncates SystemMonitor.swift and MonitorDesign.swift, deleting whole app

Both commits replace their files with tiny stubs instead of editing them. SystemMonitor.swift drops from 1370 lines to ~30 (only CPUStats and CPUClusterProcessorRanges survive), and MonitorDesign.swift drops from 482 to ~130 lines. The entire SystemMonitor class, the MemoryPressureLevel enum, battery/SMC reading — including the very PSTR power feature commit a7e9191 claims to add — are all deleted, and the rpmShort fix in df2b85b comes bundled with the loss of most of MonitorDesign.swift. MemoryPressureLevel is now undefined anywhere in the source yet is still referenced by MonitorDesign.swift's ReadingThresholds.memory, and SystemMonitor is referenced by ~27 other files, so the project cannot compile. This looks like an accidental file overwrite/bad rebase rather than an intended change. The fix is to restore both files to their prior contents and apply only the intended edits (add PSTR/PGPU/PCPU power reading in SystemMonitor.swift; change rpmShort to return the plain integer in MonitorDesign.swift) on top of the full files.

Was this helpful? React with 👍 / 👎

@offyotto offyotto Sep 18, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@gitar-bot Genuine slop code that was made in this PR. Please discover other issues.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Got it, running a full review now to surface any additional issues beyond the truncation bug.

@gitar-bot

gitar-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
CI failed: Swift compilation failed due to a syntax/whitespace error and missing type scopes in MonitorDesign.swift.

Overview

1 build failure was detected during the Xcode compilation step, caused by a syntax error and missing type declarations in MonitorDesign.swift across 1 job.

Failures

Swift Compilation Failure (confidence: high)

  • Type: build
  • Affected jobs: 105503144492
  • Related to change: yes
  • Root cause: MonitorDesign.swift contains a syntax error regarding inconsistent whitespace around the '=' operator and multiple unresolved type references (such as MemoryPressureLevel, BatteryInfo, DiskStats, SystemMonitor, and ReadingSeverity).
  • Suggested fix: Review and correct MonitorDesign.swift to fix operator spacing and ensure all dependent types are in scope or correctly imported.

Summary

  • Change-related failures: 1 build failure in MonitorDesign.swift due to syntax and scope issues.
  • Infrastructure/flaky failures: 0 failures.
  • Recommended action: Fix the syntax and missing type errors in MonitorDesign.swift and re-run the CI pipeline.
Code Review 🚫 Blocked 0 closed / 1 findings

🟡 Medium risk

Blocked: commits accidentally truncate SystemMonitor.swift and MonitorDesign.swift to stubs, deleting critical app code including the SystemMonitor class, MemoryPressureLevel enum, and battery/SMC reading logic. The project cannot compile due to undefined references. Restore both files to their prior contents and apply only the intended edits (PSTR/PGPU/PCPU power reading and rpmShort fix) on top of the complete files.

🚨 Bug: PR truncates SystemMonitor.swift and MonitorDesign.swift, deleting whole app

📄 Core-Monitor/SystemMonitor.swift:1 📄 Core-Monitor/MonitorDesign.swift:1

Both commits replace their files with tiny stubs instead of editing them. SystemMonitor.swift drops from 1370 lines to ~30 (only CPUStats and CPUClusterProcessorRanges survive), and MonitorDesign.swift drops from 482 to ~130 lines. The entire SystemMonitor class, the MemoryPressureLevel enum, battery/SMC reading — including the very PSTR power feature commit a7e9191 claims to add — are all deleted, and the rpmShort fix in df2b85b comes bundled with the loss of most of MonitorDesign.swift. MemoryPressureLevel is now undefined anywhere in the source yet is still referenced by MonitorDesign.swift's ReadingThresholds.memory, and SystemMonitor is referenced by ~27 other files, so the project cannot compile. This looks like an accidental file overwrite/bad rebase rather than an intended change. The fix is to restore both files to their prior contents and apply only the intended edits (add PSTR/PGPU/PCPU power reading in SystemMonitor.swift; change rpmShort to return the plain integer in MonitorDesign.swift) on top of the full files.

🤖 Prompt for agents
Code Review: Blocked: commits accidentally truncate `SystemMonitor.swift` and `MonitorDesign.swift` to stubs, deleting critical app code including the SystemMonitor class, MemoryPressureLevel enum, and battery/SMC reading logic. The project cannot compile due to undefined references. Restore both files to their prior contents and apply only the intended edits (PSTR/PGPU/PCPU power reading and rpmShort fix) on top of the complete files.

1. 🚨 Bug: PR truncates SystemMonitor.swift and MonitorDesign.swift, deleting whole app
   Files: Core-Monitor/SystemMonitor.swift:1, Core-Monitor/MonitorDesign.swift:1

   Both commits replace their files with tiny stubs instead of editing them. SystemMonitor.swift drops from 1370 lines to ~30 (only CPUStats and CPUClusterProcessorRanges survive), and MonitorDesign.swift drops from 482 to ~130 lines. The entire SystemMonitor class, the MemoryPressureLevel enum, battery/SMC reading — including the very PSTR power feature commit a7e9191 claims to add — are all deleted, and the rpmShort fix in df2b85b comes bundled with the loss of most of MonitorDesign.swift. MemoryPressureLevel is now undefined anywhere in the source yet is still referenced by MonitorDesign.swift's ReadingThresholds.memory, and `SystemMonitor` is referenced by ~27 other files, so the project cannot compile. This looks like an accidental file overwrite/bad rebase rather than an intended change. The fix is to restore both files to their prior contents and apply only the intended edits (add PSTR/PGPU/PCPU power reading in SystemMonitor.swift; change rpmShort to return the plain integer in MonitorDesign.swift) on top of the full files.

Review coverage

Auto-approval Not evaluated

Rules No rules evaluated

Functional validation Not enabled · Set up

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ This PR is blocked due to unresolved code review findings.

Configure merge blocking · Maintainers can dismiss this review.

@offyotto offyotto closed this Sep 19, 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.

1 participant