Skip to content

Redesign power dashboard and add local usage reports#8

Draft
davelindo wants to merge 1 commit into
mainfrom
feature/power-dashboard-reports
Draft

Redesign power dashboard and add local usage reports#8
davelindo wants to merge 1 commit into
mainfrom
feature/power-dashboard-reports

Conversation

@davelindo

Copy link
Copy Markdown
Owner

Summary

This PR redesigns Powerflow as a compact, information-dense macOS power monitor and makes its application attribution and historical reporting useful when the popover is closed. It also hardens raw sensor validation, removes the direct Bluetooth permission path, and keeps background overhead low enough for an always-running menu bar utility.

Motivation

The previous interface left substantial space unused, exposed limited detail, and did not provide durable reporting. Application attribution was also unreliable in the background because its sampling cadence and telemetry consistency gate could discard otherwise valid process-energy intervals.

The new design focuses on three jobs:

  1. Show the current power path clearly and compactly.
  2. Explain which applications consumed measured compute energy over the last ten minutes.
  3. Preserve enough local history to understand power and battery trends over time.

What changed

Dashboard and interaction design

  • Replaces the old popover with a compact 420 × 460 Liquid Glass-style dashboard.
  • Adds Live, Reports, and Devices navigation without expanding the menu bar window.
  • Adds a Sankey-style power flow covering adapter, battery, system, package, display, and derived remainder load.
  • Adds delayed hover and click inspectors for adapter, battery, system, measured channels, application impact, and connected devices.
  • Tightens settings spacing and replaces custom menu controls with native pickers.
  • Removes unreachable legacy dashboard implementations and shared formatting duplication left behind during the redesign.

Application energy accounting

  • Reworks process sampling around monotonic CPU-time deltas instead of cumulative averages or thread-count heuristics.
  • Integrates measured compute power across each real sampling interval and apportions that energy using observed process activity shares.
  • Preserves unallocated energy rather than incorrectly forcing listed applications to sum to 100%.
  • Records fresh application-energy intervals even when an unrelated power-balance snapshot fails the consistency gate.
  • Uses a five-second background cadence while application tracking is enabled, matching the fidelity available with the popover open.
  • Aggregates a rolling ten-minute application view with energy, relative share, peak interval power, active time, and peak CPU context.

Persistent reports

  • Adds a local SQLite history repository with minute aggregation and 90-day retention.
  • Adds 1-hour, 24-hour, 7-day, 30-day, and 90-day report ranges.
  • Reports observed system energy, average and peak load, adapter time, recording coverage, temperature, battery health, capacity, and cycle changes.
  • Keeps ten-minute application samples separate from longer-term telemetry retention.
  • Coalesces telemetry and application-energy persistence into a single transaction when they share an accepted sample.
  • Recovers automatically from a corrupt history database by preserving the bad file and recreating the store.

Telemetry and battery correctness

  • Rejects non-finite, negative, and physically implausible power, adapter, fan, temperature, and capacity values before they reach the UI or reports.
  • Corrects SMC floating-point decoding and rejects non-finite payloads.
  • Resolves full-charge, design, and remaining capacity from validated battery sources.
  • Prevents contradictory package/display readings from producing an invalid flow breakdown.
  • Normalizes negative zero and small energy values in user-facing formatting.

Connected devices and permissions

  • Removes direct CoreBluetooth and IOBluetooth framework linkage and the Bluetooth usage description.
  • Deletes the permission-triggering Bluetooth reader that could leave a modal prompt stuck on screen.
  • Retains connected-device battery discovery through system profiler and IORegistry data.
  • Normalizes device names and addresses for stable deduplication without exposing private framework identifiers.

Tests, snapshots, and documentation

  • Adds coverage for detailed power-flow conservation, telemetry sanitization, CPU-time conversion, energy integration, report aggregation, retention, corrupt database recovery, and background persistence.
  • Expands layout coverage to ten light/dark dashboard, report, device, settings, and battery-report snapshots.
  • Updates README feature descriptions and regenerated visual assets.
  • Updates the Xcode project and links SQLite while removing Bluetooth frameworks.

Performance

The final Release build was profiled with the popover closed:

  • Time Profiler: 94 ms CPU over 45 seconds, approximately 0.21% of one core.
  • Activity Monitor: approximately 0.19% of one core over the measured interval.
  • Physical footprint remained stable between 19.13 and 19.19 MiB.
  • 19 idle wakeups were observed over roughly 41 seconds.
  • No additional disk writes were recorded during the trace.
  • SQLite/history work accounted for 3 ms of the Time Profiler sample; application attribution accounted for 42 ms.
  • Persisted application-energy intervals remained five seconds apart while hidden.

Privacy review

  • No network transmission, analytics, or updater behavior is added.
  • Application activity and report history remain local to the Mac.
  • The proposed source, fixtures, generated assets, and staged metadata were scanned for personal names, local usernames, home paths, email addresses, credentials, hostnames, serial identifiers, and real network/device addresses; none were found.
  • The MAC-like values in tests are explicitly synthetic fixtures.
  • All 13 committed PNG files passed CRC validation. Their EXIF contains only resolution, color-space, and pixel-dimension fields; no author, location, timestamp, device, or user metadata is present.
  • Commit metadata uses the GitHub noreply identity.

Verification

  • xcodebuild -project Powerflow.xcodeproj -scheme Powerflow -destination "platform=macOS" test
    • Passed: 76 tests, 0 failures; 10 opt-in layout snapshots skipped by the standard suite.
  • scripts/verify_layout_snapshots.sh
    • Passed: 10 snapshot tests, 0 failures.
  • xcodebuild -project Powerflow.xcodeproj -scheme Powerflow -configuration Release -destination "platform=macOS" build
    • Passed: Release build succeeded.
  • git diff --check
    • Passed.
  • plutil -lint Resources/Info.plist
    • Passed.

Reviewer notes

  • Per-application wattage is necessarily an estimate because macOS does not expose public per-process power telemetry. The implementation attributes intervals from measured compute energy and clearly labels results as estimated.
  • Historical energy represents periods recorded while Powerflow was running; report coverage is surfaced alongside totals.
  • The PR intentionally does not add charging or power-control behavior.

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