Skip to content

feat: choose CPU, memory or both in the System monitor widget - #598

Merged
Seb-GRAF merged 1 commit into
mainfrom
feat/system-monitor-memory
Nov 12, 2026
Merged

Seb-GRAF merged 1 commit into
mainfrom
feat/system-monitor-memory

Conversation

@Seb-GRAF

@Seb-GRAF Seb-GRAF commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The System monitor widget always shows CPU on the bar. Settings → Bar → Content → Display changes how CPU is drawn, but it can't show memory instead of CPU, or both.

Closes #587

Changes

  • Shows in Settings → Bar → Content → Display, for System monitor widgets: CPU (default), Memory, CPU and memory, Memory and CPU. Each metric gets its own symbol (cpu, memorychip) and value, and Show (icon, value, meter, graph) applies to every metric shown. Both choices write the widget's layout, as Display already did, so the configuration format doesn't change. A widget with no layout is still CPU with its graph, and existing layouts are recognized as before. While the layout is a hand-written one (Custom layout), Shows is hidden, because none of its choices matches that layout.
  • The system provider reports series.cpu and series.memory, the last 60 samples, kept by its native sampler (NativeMetrics, one per running source, not BarStore). The memory graph uses "source": "memory". CPU graphs keep drawing without a source, from the widget's value history, so an existing CPU graph draws exactly as before. Like the CPU baseline, the series start over after startup or resume.
  • Why this over the alternatives. Today the graph block can only draw the provider's value (CPU) or a series the provider sends, and system sent none. A CPU-only graph would have given memory a meter whenever Graph was chosen, so Display would mean different things for each metric. Hiding Graph for memory would have kept memory from ever getting the look that is the default for CPU. Adding the series is additive provider output, with no configuration property, and lets Display apply the same way to both.
  • Memory's value. fields.memory is a bare number (54), while CPU's value comes from text (18%). Memory's value is a nested row with zero spacing: {"type":"row","style":{"spacing":0},"children":[{"type":"field","field":"memory"},{"type":"text","text":"%"}]}. It draws 54% with no gap, so no provider field was added.
  • WidgetMetricDisplay.layout(for:) and current(_:sources:) now take the list of values shown. Battery and sound pass a single source and get the same layouts as before.
  • Docs: docs/providers.md (the new series), docs/create-a-widget.md (the Display paragraph), docs/widgets.md (System monitor) and docs/settings.md (what Content holds). The command line has no Display choice, so it has none for Shows either.
  • Scenes: system-monitor-shows-settings draws the System monitor's Content tab set to CPU and memory, Graph and value. system-monitor-memory-bar draws the default CPU widget next to a memory graph, CPU and memory meters, and memory and CPU icons and values.

Testing

  • swift build --build-tests; swift test --filter "WidgetSettingsTests|batteryDisplay|DefaultLayoutTests|ArchitectureRules|schemaListsTheSame|WidgetTests": all pass. testSystemStartsWithItsGraphAndKeepsIconAndValueAsAChoice now checks that every Shows × Display layout is recognized as that same pair, and that no layout means CPU with its graph.
  • StableBar --render-scenes from a debug build drew both new scenes. The Content tab reads Shows: CPU and memory and Show: Graph and value. On the bar, the memory graph follows series.memory, the default CPU graph is unchanged, and memory reads 54% with no gap.
  • scripts/check.sh --quick and npx commitlint --from origin/main pass.
  • The screens bot draws the before and after images from main and from this branch, including the two new scenes. Its docs/essentials-settings image changes too: it draws the System monitor's Content tab, which now has the Shows row.
  • Rebased onto main after feat: add GPU usage to the system provider #584 added the GPU value: system reports values.gpu and fields.gpu as well as series.cpu and series.memory.
  • Not checked: the app itself wasn't launched, so live sampling of series.memory was seen only through the scenes' sample data. The graph's line is 1.5 points in the explicit layouts, as for battery and sound, against 1.2 in CPU's default layout.

Merging

A single feat commit; any merge method works.

Claude Opus 5.5 via Claude Code

@Seb-GRAF
Seb-GRAF requested a review from M4n0x as a code owner November 12, 2026 08:17
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The System monitor now supports CPU, memory, or both metrics in either order. Its inspector adds a Shows picker, and the system provider returns up to 60 CPU and memory history samples for graphs.

Changes: System monitor metrics

Layer / File(s) Summary
Multi-source display layouts
Sources/StableBar/WidgetSettings.swift, Tests/StableBarTests/*, docs/create-a-widget.md, docs/widgets.md
Metric display layouts now accept multiple sources. System metric choices include CPU, memory, and both orderings. Tests cover the display choices and layout matching.
CPU and memory history series
Sources/StableBar/NativeMetrics.swift, docs/providers.md, scenes/system-monitor-memory-bar.json
The system provider returns the latest 60 CPU and memory fractions as series. The documentation and bar scene include the series and sample displays.
Inspector metric controls
Sources/StableBar/BarInspector.swift, docs/settings.md, scenes/system-monitor-shows-settings.json
The inspector adds a Shows picker for system metrics and saves the selected layout. The settings scene and documentation show the controls.

Possibly related PRs

  • Seb-GRAF/StableBar#584: Adds GPU values to NativeMetrics.system(), which this change also updates to return system metric series.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 34b93

The System monitor can now show CPU, memory, or both in either order. No actionable merge-blocking risk was identified. The author reports that live memory sampling was not checked in the running app, which is normal validation uncertainty.

Security architecture risk: Minimal · up to 34b93

The change adds local CPU and memory presentation without expanding execution authority. Histories are bounded, owned by each running source and rendered through the existing graph path. No material security risk introduced or worsened by this change was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The incremental data exposure is bounded aggregate history for the local host, available through existing provider consumers. State is isolated per running source, not per widget; sharing among widgets using the same named provider is pre-existing.

Trust Boundaries and Controls

  • observed — The new picker maps fixed enum selections to CPU and memory layouts through the existing editor.set operation. Generated blocks are presentation blocks, and a graph source is used only to select numeric samples. This path does not invoke the renderer’s separate action capability.

Resilience and Maintainability Implications

  • observed — Sampler mutations are MainActor-isolated. PollingSource checks cancellation before emitting, and the runner checks cancellation before accepting updates. Read failures retain the last published output; source recreation gives recovery a new sampler rather than transferring mutable history from the canceled source.
Pre-merge checks: Passed 3

Check name Status Explanation
Linked Issues check Passed Issue #587 is the only active directly linked target. Its requirements are coding requirements. The PR meets each one, based on the whole-PR summary (mergeBase adcba36 to head 34b93d3) and the changed…
Out of Scope Changes check Passed Each changed area connects to #587 or supports it.

- BarInspector.swift: adds the Shows picker and derives the source list for system widgets. The picker is hidden for custom layouts.
- WidgetSetting…
Description check Passed The description follows the template well. It has Problem (with "Closes #587"), Changes (detailed bullets explaining Shows choice, the system provider series, design alternatives, memory value layout,…
Full details: Linked Issues check

Explanation

Issue #587 is the only active directly linked target. Its requirements are coding requirements. The PR meets each one, based on the whole-PR summary (mergeBase adcba36 to head 34b93d3) and the changed-file summaries.

(1) [#587] A Shows choice for System monitor appears in Settings → Bar → Content (BarInspector.swift). Its options are CPU (default), Memory, CPU and memory, and Memory and CPU (WidgetSettings.swift, WidgetSystemMetrics). This covers the requested choice and both orders.
(2) [#587] Each shown metric gets its own symbol (cpu, memorychip) and value. Memory's value uses a nested row with zero spacing, so it reads as a percent value without a new provider field.
(3) [#587] Display applies to every shown metric. WidgetMetricDisplay.layout(for:) and current(_:sources:) now take a source list.
(4) [#587] The choice writes the widget's layout, as Display does. The configuration format is unchanged. A layout-less widget keeps CPU with its graph. Battery and sound keep their layouts.
(5) [#587] docs/widgets.md describes the choice.

Tests cover the Shows × Display round-trips (WidgetSettingsTests, BatteryTests, DefaultLayoutTests). The series.memory addition in NativeMetrics.swift supports the memory graph. The issue does not require it, but the graph depends on it. Live sampling was not verified because the app was not launched. Scene rendering used sample data. This gap does not change the verdict, because the layout behavior is covered by unit tests and scene rendering.

Full details: Out of Scope Changes check

Explanation

Each changed area connects to #587 or supports it.

  • BarInspector.swift: adds the Shows picker and derives the source list for system widgets. The picker is hidden for custom layouts.
  • WidgetSettings.swift: holds the layout and source logic and the new system selections.
  • NativeMetrics.swift: adds the cpu and memory series that the memory graph uses.
  • Test edits: update call sites for the sources-array signature and cover the new choices.
  • Docs (create-a-widget.md, providers.md, settings.md, widgets.md): describe the new behavior.
  • Scene JSON files: render the new choices for verification.

Battery and sound change only their call signatures and keep their layouts. No unrelated change appears in the summaries.

Full details: Description check

Explanation

The description follows the template well. It has Problem (with "Closes #587"), Changes (detailed bullets explaining Shows choice, the system provider series, design alternatives, memory value layout, API signature changes, docs, and scenes), Testing (build, filtered tests, scene rendering, check scripts, and an explicit list of what was not checked), and Merging (a single feat commit, any merge method works). The last line names the model and harness ("Claude Opus 5.5 via Claude Code"), as the template requires. The description is specific and matches the raw summary and PR objectives. Minor gaps: the Changes section is dense, and the Merging section does not explicitly say whether a squash would need a particular message, though it does state that any method works.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 89612fb and 34b93d3.

Files selected for processing: 4

  • Sources/StableBar/BarInspector.swift
  • Sources/StableBar/NativeMetrics.swift
  • docs/providers.md
  • docs/settings.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Before and after

main at adcba36 → this pull request at 34b93d3 · 122 screens drawn in one CI job · 4 changed

Screen Change Where (image pixels)
docs/essentials-settings-dark 612,840 pixels 502,818 · 1584×624
docs/essentials-settings-light 619,435 pixels 502,818 · 1584×624
scenes/system-monitor-shows-settings-dark 613,327 pixels 502,818 · 1584×624
scenes/system-monitor-shows-settings-light 619,893 pixels 502,818 · 1584×624

docs/essentials-settings-dark

Before After
Before After

Difference, changed pixels in red:

Difference

docs/essentials-settings-light

Before After
Before After

Difference, changed pixels in red:

Difference

scenes/system-monitor-shows-settings-dark

Before After
Before After

Difference, changed pixels in red:

Difference

scenes/system-monitor-shows-settings-light

Before After
Before After

Difference, changed pixels in red:

Difference

118 unchanged screens

docs/essentials-clock-settings-dark, docs/essentials-clock-settings-light, docs/essentials-dark, docs/essentials-light, docs/hero-dark, docs/hero-light, docs/popups-dark, docs/popups-light, docs/settings-dark, docs/settings-light, docs/themes-dark, docs/themes-light, scenes/accessibility-guide-dark, scenes/accessibility-guide-light, scenes/app-menu-popup-dark, scenes/app-menu-popup-light, scenes/apple-menu-settings-dark, scenes/apple-menu-settings-light, scenes/bottom-bar-popup-dark, scenes/bottom-bar-popup-light, scenes/chat-popup-dark, scenes/chat-popup-light, scenes/crowded-edit-bar-dark, scenes/crowded-edit-bar-light, scenes/dock-badges-bar-dark, scenes/dock-badges-bar-light, scenes/edit-bar-wide-group-dark, scenes/edit-bar-wide-group-light, scenes/essentials-clock-popup-dark, scenes/essentials-clock-popup-light, scenes/gruvbox-bar-dark, scenes/gruvbox-bar-light, scenes/horizontal-list-popup-dark, scenes/horizontal-list-popup-light, scenes/increase-contrast-bar-dark, scenes/increase-contrast-bar-light, scenes/increase-contrast-popup-dark, scenes/increase-contrast-popup-light, scenes/notch-flare-bar-dark, scenes/notch-flare-bar-light, scenes/reduce-transparency-bar-dark, scenes/reduce-transparency-bar-light, scenes/reduce-transparency-glass-bar-dark, scenes/reduce-transparency-glass-bar-light, scenes/settings-bar-dark, scenes/settings-bar-light, scenes/settings-bar-placement-bottom-dark, scenes/settings-bar-placement-bottom-light, scenes/settings-bar-placement-dark, scenes/settings-bar-placement-light, scenes/settings-crashes-dark, scenes/settings-crashes-light, scenes/settings-feedback-dark, scenes/settings-feedback-light, scenes/settings-general-dark, scenes/settings-general-light, scenes/settings-general-macos15-dark, scenes/settings-general-macos15-light, scenes/settings-general-move-dark, scenes/settings-general-move-failed-dark, scenes/settings-general-move-failed-light, scenes/settings-general-move-light, scenes/settings-general-move-moving-dark, scenes/settings-general-move-moving-light, scenes/settings-general-move-replace-dark, scenes/settings-general-move-replace-light, scenes/settings-general-setup-open-dark, scenes/settings-general-setup-open-light, scenes/settings-general-spaces-dark, scenes/settings-general-spaces-light, scenes/settings-help-dark, scenes/settings-help-light, scenes/settings-help-starred-dark, scenes/settings-help-starred-light, scenes/settings-theme-dark, scenes/settings-theme-light, scenes/settings-uninstall-dark, scenes/settings-uninstall-failed-dark, scenes/settings-uninstall-failed-light, scenes/settings-uninstall-light, scenes/settings-widget-backgrounds-dark, scenes/settings-widget-backgrounds-light, scenes/settings-workspace-hidden-dark, scenes/settings-workspace-hidden-light, scenes/setup-look-below-menu-bar-dark, scenes/setup-look-dark, scenes/setup-look-no-notch-dark, scenes/setup-move-existing-dark, scenes/setup-move-failed-dark, scenes/setup-move-ready-dark, scenes/setup-move-replace-dark, scenes/setup-omniwm-connection-dark, scenes/setup-permissions-dark, scenes/setup-permissions-spaces-dark, scenes/setup-permissions-spaces-ready-dark, scenes/setup-placement-bottom-dark, scenes/setup-placement-dark, scenes/setup-touches-dark, scenes/setup-touches-macos15-dark, scenes/setup-touches-spaces-dark, scenes/setup-try-dark, scenes/setup-yabai-connection-dark, scenes/slider-end-stop-popup-dark, scenes/slider-end-stop-popup-light, scenes/starter-bar-dark, scenes/starter-bar-light, scenes/starter-edit-bar-dark, scenes/starter-edit-bar-light, scenes/system-monitor-memory-bar-dark, scenes/system-monitor-memory-bar-light, scenes/update-popup-dark, scenes/update-popup-light, scenes/update-popup-star-github-cli-dark, scenes/update-popup-star-github-cli-light, scenes/update-popup-star-thanks-dark, scenes/update-popup-star-thanks-light, scenes/workspace-hidden-apps-bar-dark, scenes/workspace-hidden-apps-bar-light

Visual review: 4 screens changed: a maintainer adds visual-ok after looking.

@Seb-GRAF
Seb-GRAF force-pushed the feat/system-monitor-memory branch from 89612fb to 34b93d3 Compare November 12, 2026 09:30
@Seb-GRAF Seb-GRAF added the visual-ok A maintainer looked at the changed screens and approves them label Nov 12, 2026
@Seb-GRAF
Seb-GRAF merged commit 51d9b67 into main Nov 12, 2026
48 of 52 checks passed
@Seb-GRAF
Seb-GRAF deleted the feat/system-monitor-memory branch November 12, 2026 11:12
stablebar-releases Bot pushed a commit that referenced this pull request Nov 12, 2026
## [0.14.0](v0.13.0...v0.14.0) (2026-11-12)

### Features

* add a StableBar widget that opens Settings in one click ([#599](#599)) ([c5db47a](c5db47a))
* add GPU usage to the system provider ([#584](#584)) ([afa382a](afa382a))
* build quick chats in popups with growing inputs, Markdown blocks, presets and resizing ([#573](#573)) ([fab85bd](fab85bd))
* choose CPU, memory or both in the System monitor widget ([#598](#598)) ([51d9b67](51d9b67))
* hide chosen apps and workspaces from the workspace widget ([#593](#593)) ([ce1d74b](ce1d74b))
* move StableBar to Applications from setup and pick up where setup was ([#555](#555)) ([6088f6d](6088f6d)), closes [#506](#506)
* open triage from Send feedback in the default terminal ([#568](#568)) ([71f2543](71f2543))
* place the bar at the bottom of the screen ([#594](#594)) ([e41e127](e41e127))
* show icons beside the commands in StableBar's menus ([098d61f](098d61f)), closes [#570](#570)
* show icons beside the commands in StableBar's menus ([#571](#571)) ([41b6ad0](41b6ad0)), closes [#570](#570)
* show the keyboard input source and switch it on click ([#585](#585)) ([285e3f3](285e3f3))
* show whether the microphone or camera is in use ([#592](#592)) ([3e2a1aa](3e2a1aa))
* star StableBar through a signed-in GitHub CLI from Help ([#569](#569)) ([2f09934](2f09934))

### Bug Fixes

* close Settings, setup and pinned popups with ⌘W ([#597](#597)) ([42da105](42da105))
* keep a widget's submenus open while editing the bar in place ([#583](#583)) ([d856942](d856942)), closes [#582](#582)
* leave launches dyld stopped out of Crashes and name development builds ([#577](#577)) ([09f1ab1](09f1ab1)), closes [#576](#576)
* let the Apple logo's whole tile take its click ([#575](#575)) ([913b920](913b920))
* list package settings in their manifest's order, each with a label ([#602](#602)) ([f210a21](f210a21))
* stop hover tooltips crashing StableBar after editing the bar in place ([#596](#596)) ([adcba36](adcba36))
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released visual-ok A maintainer looked at the changed screens and approves them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Choose CPU, memory or both in the System monitor widget

1 participant