Skip to content

fix: keep menu bar spacing global#552

Closed
CamilleGuillory wants to merge 2 commits intostonerl:developmentfrom
CamilleGuillory:fix/global-menu-bar-spacing
Closed

fix: keep menu bar spacing global#552
CamilleGuillory wants to merge 2 commits intostonerl:developmentfrom
CamilleGuillory:fix/global-menu-bar-spacing

Conversation

@CamilleGuillory
Copy link
Copy Markdown
Contributor

@CamilleGuillory CamilleGuillory commented May 8, 2026

Summary

  • Moves menu bar item spacing back to General settings, matching macOS' host-wide NSStatusItemSpacing / NSStatusItemSelectionPadding behavior.
  • Removes spacing from per-display configuration/UI and stops display configuration changes from triggering spacing relaunch waves.
  • Keeps profile snapshot support for global spacing and updates tests for the General-settings model.

Fixes #551

Test plan

  • ReadLints on touched Swift files
  • git diff --check
  • Not run: swiftformat (not installed in this environment)
  • Not run: xcodebuild test -project Thaw.xcodeproj -scheme Thaw -derivedDataPath Build/ -destination 'platform=macOS' -enableCodeCoverage YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO because the active developer directory is Command Line Tools, not full Xcode

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Global "Item Spacing Offset" added to General Settings with a new "Spacing Options" slider, plus Apply and Reset actions.
    • Resetting settings now restores the global spacing offset to its default.
  • Removed Features

    • Per-display item spacing controls removed from Display Settings.
  • Tests

    • Updated and added tests to cover the new global spacing field, decoding/clamping, and legacy compatibility.

Restore menu bar item spacing to General settings because macOS applies NSStatusItemSpacing as a single host-wide preference, not as a per-display value.

Co-authored-by: Cursor <[email protected]>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5bd26a36-1d73-48f1-8a34-8f1880abe6a6

📥 Commits

Reviewing files that changed from the base of the PR and between fff2ed7 and 04b4547.

📒 Files selected for processing (2)
  • Thaw/Settings/Models/GeneralSettings.swift
  • Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift
🚧 Files skipped from review as they are similar to previous changes (2)
  • Thaw/Settings/Models/GeneralSettings.swift
  • Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift

📝 Walkthrough

Walkthrough

This PR relocates menu bar item spacing from per-display DisplayIceBarConfiguration to global GeneralSettings. The change removes display-specific configuration, adds new UI controls in General settings, simplifies DisplaySettingsManager by removing AppState coupling and spacing reapplication logic, and updates profile snapshots and tests accordingly.

Changes

Global Menu Bar Item Spacing

Layer / File(s) Summary
Defaults & Data Model Foundation
Thaw/Utilities/Defaults.swift, Thaw/Settings/Models/DisplayIceBarConfiguration.swift
Added itemSpacingOffset default value (0) and UserDefaults key. Removed itemSpacingOffset property, withItemSpacingOffset(_:) method, and all references from DisplayIceBarConfiguration initialization, copy methods, and Codable decoding.
General Settings Persistence
Thaw/Settings/Models/GeneralSettings.swift, Thaw/Settings/Models/SettingsResetter.swift
Added @Published itemSpacingOffset property to GeneralSettings. Implemented persistence observer that deduplicates updates, clamps to [-16, 16], logs clamping warnings, writes to Defaults, and applies rounded value to spacingManager.offset. Extended resetGeneral() to include itemSpacingOffset reset.
Profile Snapshot Support
Thaw/Settings/Models/Profile.swift
Extended GeneralSettingsSnapshot with itemSpacingOffset property. Updated initializer with parameter (defaulted), capture/restore methods, clamping helper, and Codable encoding/decoding with backward-compatibility fallback to Defaults.DefaultValue.itemSpacingOffset for missing fields.
Display Settings Cleanup
Thaw/Settings/Models/DisplaySettingsManager.swift, Thaw/Settings/SettingsPanes/DisplaySettingsPane.swift
Removed AppState reference from DisplaySettingsManager.performSetup(). Removed didChangeScreenParametersNotification spacing reapplication, $configurations change sink, and applyActiveDisplaySpacing(reason:) method. Removed per-display spacing UI (@State draft values and spacingRow(for:) view) from DisplaySettingsPane.
General Settings UI
Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift
Added "Spacing Options" section with item spacing slider, temporary state tracking, Apply/Reset controls, and lifecycle bindings. Apply action updates settings.itemSpacingOffset and asynchronously calls spacingManager.applyOffset() with NSAlert error handling.
Layout Rendering
Thaw/MenuBar/IceBar/IceBar.swift
Switched IceBarContentView.itemSpacing offset source from per-display displaySettings.configuration(for:).itemSpacingOffset to global appState.settings.general.itemSpacingOffset.
Documentation Updates
Thaw/MenuBar/MenuBarItems/MenuBarItemManager.swift, Thaw/MenuBar/Spacing/MenuBarItemSpacingManager.swift, Thaw/Settings/Models/ProfileManager.swift
Updated comments to reflect removal of applyActiveDisplaySpacing path, clarify spacing caller settling period, and describe global menu bar spacing offset restoration from profile snapshots.
Test Updates
ThawTests/DisplayIceBarConfigurationTests.swift, ThawTests/GeneralSettingsSnapshotTests.swift
Removed itemSpacingOffset assertions and initialization from DisplayIceBarConfigurationTests. Added itemSpacingOffset coverage to GeneralSettingsSnapshotTests including default/custom values, encode/decode round-trips, missing-field fallback, and clamping validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • stonerl/Thaw#529: The two PRs touch the same spacing feature but with opposite design directions (this PR centralizes itemSpacingOffset into GeneralSettings; that PR moves it to per-display configuration).
  • stonerl/Thaw#331: Overlaps on profile/snapshot handling for itemSpacingOffset within GeneralSettingsSnapshot.

Suggested labels

refactor, breaking-change, test

Suggested reviewers

  • diazdesandi
  • nightah

Poem

🐰 Spacing takes flight, no longer confined,
From displays to global—one offset to find,
Per-display complexity melts away,
General settings now have their say.
The menu bar hops, fresh and aligned! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.98% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the main change: relocating menu bar spacing to a global setting instead of per-display.
Description check ✅ Passed The description covers the key points: summary of changes, test plan, linked issue, and commit messages. It follows the repository template structure with provided sections.
Linked Issues check ✅ Passed The PR fully implements all coding requirements from issue #551: moving itemSpacingOffset to General settings, removing it from DisplayIceBarConfiguration, updating UI/tests, and ensuring display changes no longer trigger spacing relaunch waves.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the #551 objectives: relocating spacing to global settings, updating associated UI/models/tests, and removing per-display spacing logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@stonerl stonerl requested a review from nightah May 8, 2026 19:15
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
Thaw/Settings/Models/ProfileManager.swift (1)

236-236: ⚡ Quick win

Align direct spacingManager.offset assignment with the clamping applied by the $itemSpacingOffset sink.

The $itemSpacingOffset Combine sink in GeneralSettings guards with max(-16, min(16, offset)) before assigning spacingManager.offset. Line 236 sets spacingManager.offset directly without applying the same guard. While GeneralSettingsSnapshot clamps during decoding, the two code paths are now inconsistent — if an unclamped value ever reaches this point, applyOffset() would propagate the out-of-range integer to the system.

🛡️ Proposed fix
-        appState.spacingManager.offset = Int(profile.generalSettings.itemSpacingOffset.rounded())
+        appState.spacingManager.offset = Int(max(-16, min(16, profile.generalSettings.itemSpacingOffset)).rounded())
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Thaw/Settings/Models/ProfileManager.swift` at line 236, The assignment to
appState.spacingManager.offset uses profile.generalSettings.itemSpacingOffset
directly and can bypass the clamping logic used by the $itemSpacingOffset sink;
change this to clamp the value the same way (e.g., compute let clamped =
max(-16, min(16, profile.generalSettings.itemSpacingOffset)) and assign
appState.spacingManager.offset = Int(clamped.rounded())) or call the existing
applyOffset() path that enforces the clamp so spacingManager.offset cannot
receive out-of-range values; update references to spacingManager.offset,
profile.generalSettings.itemSpacingOffset, $itemSpacingOffset sink,
applyOffset(), and GeneralSettingsSnapshot accordingly.
Thaw/Settings/Models/Profile.swift (1)

41-80: GeneralSettingsSnapshot changes are well-structured.

The clamping-at-init approach correctly covers both the construct-from-settings path (capture(from:)) and the decode path (init(from:)self.init(...)), while decodeIfPresent + ?? Defaults.DefaultValue.itemSpacingOffset provides clean backward-compatible deserialization for profiles that predate this field.

One low-priority note: the clamp bounds (-16, 16) on line 127 are duplicated in the IceSlider range in: -16 ... 16 in GeneralSettingsPane.swift. Extracting them into a shared constant in Defaults would prevent silent drift if either is changed independently.

Also applies to: 126-170

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Thaw/Settings/Models/Profile.swift` around lines 41 - 80, The -16/16 bounds
for item spacing are duplicated between the clampItemSpacingOffset logic (used
in Profile.init / clampItemSpacingOffset) and the IceSlider range (in: -16 ...
16) in GeneralSettingsPane.swift; extract them into a single shared constant on
Defaults (for example Defaults.DefaultValue.itemSpacingOffsetMin and
itemSpacingOffsetMax or a Range/ClosedRange like
Defaults.DefaultValue.itemSpacingOffsetRange) and replace the hardcoded -16/16
uses in clampItemSpacingOffset and the IceSlider range with that constant to
keep the bounds consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Thaw/Settings/Models/GeneralSettings.swift`:
- Line 117: When loading itemSpacingOffset in loadInitialState via
Defaults.ifPresent(key: .itemSpacingOffset, assign: &itemSpacingOffset), clamp
the value to the allowed range before assigning so in-memory state matches the
persisted/effective value (use the same clamp logic used in the
$itemSpacingOffset sink and spacingManager.offset); additionally, for robustness
consider writing the clamped value back to Defaults inside the
$itemSpacingOffset sink (or keep removeDuplicates() to avoid feedback storms) so
programmatic mid-session sets are normalized — apply the same change to the
other similar load sites noted (lines ~181-192).

In `@Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift`:
- Around line 286-298: The commit to the model (settings.itemSpacingOffset) is
done before the async apply and on error leaves the model equal to
tempItemSpacingOffset so Apply/Reset become disabled; in
applyTempItemSpacingOffset() call appState.spacingManager.applyOffset() first
(or if you must set the model prior, then on catch reset
settings.itemSpacingOffset back to the previous value stored before assignment)
and only clear isApplyingItemSpacingOffset after success/rollback so the
Apply/Reset buttons remain enabled after a failed apply; reference
settings.itemSpacingOffset, tempItemSpacingOffset, applyTempItemSpacingOffset(),
appState.spacingManager.applyOffset(), and isApplyingItemSpacingOffset when
making the change.

---

Nitpick comments:
In `@Thaw/Settings/Models/Profile.swift`:
- Around line 41-80: The -16/16 bounds for item spacing are duplicated between
the clampItemSpacingOffset logic (used in Profile.init / clampItemSpacingOffset)
and the IceSlider range (in: -16 ... 16) in GeneralSettingsPane.swift; extract
them into a single shared constant on Defaults (for example
Defaults.DefaultValue.itemSpacingOffsetMin and itemSpacingOffsetMax or a
Range/ClosedRange like Defaults.DefaultValue.itemSpacingOffsetRange) and replace
the hardcoded -16/16 uses in clampItemSpacingOffset and the IceSlider range with
that constant to keep the bounds consistent.

In `@Thaw/Settings/Models/ProfileManager.swift`:
- Line 236: The assignment to appState.spacingManager.offset uses
profile.generalSettings.itemSpacingOffset directly and can bypass the clamping
logic used by the $itemSpacingOffset sink; change this to clamp the value the
same way (e.g., compute let clamped = max(-16, min(16,
profile.generalSettings.itemSpacingOffset)) and assign
appState.spacingManager.offset = Int(clamped.rounded())) or call the existing
applyOffset() path that enforces the clamp so spacingManager.offset cannot
receive out-of-range values; update references to spacingManager.offset,
profile.generalSettings.itemSpacingOffset, $itemSpacingOffset sink,
applyOffset(), and GeneralSettingsSnapshot accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7f5666f-ba9b-45da-90a6-e37b55b29178

📥 Commits

Reviewing files that changed from the base of the PR and between a078c0b and fff2ed7.

📒 Files selected for processing (14)
  • Thaw/MenuBar/IceBar/IceBar.swift
  • Thaw/MenuBar/MenuBarItems/MenuBarItemManager.swift
  • Thaw/MenuBar/Spacing/MenuBarItemSpacingManager.swift
  • Thaw/Settings/Models/DisplayIceBarConfiguration.swift
  • Thaw/Settings/Models/DisplaySettingsManager.swift
  • Thaw/Settings/Models/GeneralSettings.swift
  • Thaw/Settings/Models/Profile.swift
  • Thaw/Settings/Models/ProfileManager.swift
  • Thaw/Settings/Models/SettingsResetter.swift
  • Thaw/Settings/SettingsPanes/DisplaySettingsPane.swift
  • Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift
  • Thaw/Utilities/Defaults.swift
  • ThawTests/DisplayIceBarConfigurationTests.swift
  • ThawTests/GeneralSettingsSnapshotTests.swift
💤 Files with no reviewable changes (1)
  • Thaw/Settings/SettingsPanes/DisplaySettingsPane.swift

Comment thread Thaw/Settings/Models/GeneralSettings.swift Outdated
Comment thread Thaw/Settings/SettingsPanes/GeneralSettingsPane.swift
Clamp restored spacing values and roll back the draft when applying spacing fails so users can retry without extra slider changes.

Co-authored-by: Cursor <[email protected]>
@stonerl
Copy link
Copy Markdown
Owner

stonerl commented May 9, 2026

Closing this one for now, since it is not what we want as discussed in #551

@stonerl stonerl closed this May 9, 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.

Menu bar item spacing is modeled as per-display despite being global

2 participants