Add a preference to hide the Dock icon - #93
Conversation
Settings > General gains a "Hide Dock icon" toggle: the app switches its activation policy to .accessory at runtime (no relaunch, unlike LSUIElement), staying reachable from the menu-bar extra. The preference persists in SettingsStore and is applied at launch before any window appears. The policy side effect deliberately lives outside the store so unit tests on ephemeral defaults can't flip the test runner's activation policy; restoring .regular re-activates the app explicitly to work around the AppKit quirk where the icon doesn't come back.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughOrchard adds a persistent Hide Dock icon preference. The setting appears in General settings, applies the activation policy immediately, and applies the hidden state before window creation on later launches. ChangesDock icon preference
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This adds a localized, persisted Dock-icon preference with runtime switching and no relaunch requirement; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant User
participant GeneralSettingsView
participant SettingsStore
participant DockIconPolicy
participant NSApplication
User->>GeneralSettingsView: Change Hide Dock icon
GeneralSettingsView->>SettingsStore: Save preference
GeneralSettingsView->>DockIconPolicy: Apply preference
DockIconPolicy->>NSApplication: Set activation policy
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
What
Settings > General gains a "Hide Dock icon" toggle. When enabled, Orchard switches its activation policy to
.accessoryat runtime: the Dock icon disappears, the app stays fully reachable from the menu-bar extra, and flipping the toggle back restores the icon immediately. No relaunch in either direction (runtime policy switching rather thanLSUIElement). The preference persists inSettingsStoreand is applied at launch inOrchardApp.init, before any window appears.The footer text warns about the one macOS side effect users don't expect: accessory apps are also removed from the Cmd-Tab switcher.
Design notes
DockIconPolicyhelper rather than theSettingsStoresetter: the store runs in unit tests on ephemeral defaults, and a store side effect would flip the test runner's activation policy.DockIconPolicyusesNSApplication.shared, not theNSAppglobal: at the launch call site AppKit hasn't created the application object yet, soNSApp(an implicitly-unwrapped optional) is still nil and crashes. Caught in real-launch testing..regularexplicitly re-activates the app, working around the AppKit quirk where the Dock icon doesn't reliably come back otherwise..regularanyway, and applying.regularwould trigger the restore-activation dance on every launch.Testing
SettingsStorepersistence round-trip for the preference.quitcan hang against an accessory-mode app, so the screenshot tour script should run with this preference off. Quit from the menu-bar extra is unaffected.