Skip to content

Fit the panel on screen; cheaper daemon ticks and energy sampling - #2

Merged
arshdwani merged 1 commit into
mainfrom
fit-panel-and-tune
Oct 28, 2026
Merged

arshdwani merged 1 commit into
mainfrom
fit-panel-and-tune

Conversation

@arshdwani

Copy link
Copy Markdown
Owner

What

  • Panel fits the screen. With Settings open the Control tab needs 1001 pt; a 14" MacBook has 923 pt below the menu bar, so the popover (and the fallback window) ran off the bottom. The panel is now capped at the screen's free height and the tab scrolls between the fixed header and footer. A small PanelStack layout keeps the panel's height exact, so the popover and window size to it as before (a plain VStack made the window open at its 214 pt minimum).
  • Daemon: SMC key info is cached in smc.c (halves kernel calls per read) and each key is read once per tick instead of twice. SMC read: 0.5–0.7 ms → 0.21 ms; tick ≈ 3.5 ms → 1.1 ms.
  • Energy tab: app display names are cached; EnergyMonitor.sample() 6.7 ms → 1.5 ms.
  • Fixes: the automatic-update-checks switch now redraws immediately (it read UserDefaults without observing it), and turning it off hides the banner, as at launch. "Resumes below X%" → "Resumes at X%", matching the policy (pct <= limit - sailing).
  • Snapshots (./build.sh snapshot) keep rendering the full tab: without a height cap there's no ScrollView, which ImageRenderer can't draw.

Checked

  • ./build.sh test: all policy tests pass.
  • Popover heights unchanged on every tab that fits; Control + Settings: 1001 → 883 pt, scrolls to "Launch at login".
  • Window: opens at its natural height (703 pt), follows tab changes, capped at 915 pt (main: 1033 pt, off-screen).

- With Settings open the panel was taller than a 14" screen and ran off the
  bottom, in the popover and in the window. It is now capped at the screen's
  height and the tab scrolls between the fixed header and footer.
- Daemon: SMC key info is looked up once, and each key is read once per tick
  instead of twice (about 3x less CPU per tick).
- Energy tab: app names are cached; a sample took 6.7 ms, now 1.5 ms.
- The automatic update checks switch now flips right away, and turning it
  off hides the update banner, as it does at launch.
- "Resumes at X%" now matches when charging actually resumes.
@arshdwani
arshdwani merged commit da7c868 into main Oct 28, 2026
2 checks passed
@arshdwani
arshdwani deleted the fit-panel-and-tune branch October 28, 2026 14:05
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