Skip to content

feat(menubar): customizable metric widgets in the status item (#82)#84

Open
caezium wants to merge 1 commit into
mainfrom
feat/menubar-metrics
Open

feat(menubar): customizable metric widgets in the status item (#82)#84
caezium wants to merge 1 commit into
mainfrom
feat/menubar-metrics

Conversation

@caezium

@caezium caezium commented Jun 16, 2026

Copy link
Copy Markdown
Owner

What

Satisfies #82 — let users choose which metrics appear in the menu bar and how each is displayed, the way a desktop system monitor does. Replaces the single fixed " 42% · 5.2G" string in Metrics mode with a configurable, reorderable row of metric widgets.

Re-implemented in Burrow's own MIT Swift + Brand design system (no GPL code copied; the look/UX follows the common menu-bar-monitor conventions).

Widget styles

  • Value42%
  • Label + valueCPU 42%
  • Bar — mini fill bar + value (utilization-coloured)
  • Sparkline — mini line chart (net/disk off the 1 Hz ring; CPU/RAM/GPU off a snapshot-cadence ring)
  • Speed ↓↑ — two-line down/up rate (network & disk I/O)
  • Battery glyph — battery icon + % with charging state

Metrics: CPU, RAM, GPU, disk used, network, disk I/O, fan, temperature, battery. Each offers only the styles that make sense for it; colour mode is per-widget (by utilization / accent / monochrome / by pressure).

How it's wired

  • Store.menuBarItems — ordered [MenuBarItem] (metric + style + colour), JSON-persisted. Default = CPU + memory, and Metrics mode stays opt-in (default is the icon) → no change for existing users until they customize.
  • MenuBarWidgets.swift (new) — the model + MenuBarRenderer, which draws the row into an NSImage via a drawing handler so monochrome text re-resolves for light/dark menu bars. The status button keeps its existing click/right-click action untouched (no custom hit-testing view).
  • StatusBarController builds the values from the live feed (a snapshot sink + a 1 Hz sink) and re-renders. Drawing is a few strings/shapes and reads only already-published live values — no NSWorkspace/blocking work on the main thread (consistent with the hang fixes in fix(perf): eliminate the main-thread App Hangs (Sentry triage) #83).
  • SettingsView ▸ Menu Bar — an editor (add / remove / reorder, per-metric style + colour pickers) shown when Display = Metrics; edits persist + re-render the status item live.

Test plan

  • xcodebuild Debug build succeeds, no new warnings.
  • Settings ▸ Menu Bar → Display = Metrics: the configured row appears in the status bar.
  • Add / remove / reorder metrics; switch styles (value / label / bar / sparkline / speed / battery) and colour modes — confirm each renders and updates live.
  • Check legibility on a light and a dark menu bar.
  • Confirm net/disk speed + sparkline animate at ~1 Hz; CPU/RAM update at the sample cadence.
  • Left-click still opens the popover; right-click still shows the quick menu.

Notes

Replaces the fixed "42% · 5.2G" metrics string with a configurable, reorderable row of metric widgets, the way a desktop system monitor lets you pick what to glance at.

- Store.menuBarItems: an ordered [MenuBarItem] (metric + style + colour), JSON-persisted. Defaults to the historical CPU + memory pair, and only ever shows in Metrics mode (which stays opt-in - the default is still the icon), so nothing changes for existing users until they customise.

- MenuBarWidgets.swift (new): MenuBarMetric (CPU/RAM/GPU/disk/net/IO/fan/temp/battery), MenuBarWidgetStyle (value / label+value / bar / sparkline / speed-down-up / battery glyph), MenuBarColorMode (utilization/accent/mono/pressure), and MenuBarRenderer which draws the whole row into an NSImage via a drawing handler so monochrome text tracks the light/dark menu bar. Re-implemented in our own MIT Swift + Brand tokens.

- StatusBarController renders the row from the live feed: a snapshot sink (CPU/RAM/GPU/disk/fan/temp/battery + cpu/mem/gpu sparkline rings) and a 1 Hz sink (live net/disk rates + their sparklines off the ring). Drawing is a few strings + shapes; it never walks the running-app list or does other blocking work on main - consistent with the hang fixes in #83.

- SettingsView > Menu Bar gains a metrics editor (add / remove / reorder, per-metric style + colour pickers) shown when Display = Metrics; edits persist and re-render the status item live.

Build: xcodebuild Debug succeeds, no new warnings. Satisfies #82.
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