Skip to content

Add a preference to hide the Dock icon - #93

Merged
andrew-waters merged 1 commit into
mainfrom
prd-dock-icon
Aug 20, 2026
Merged

Add a preference to hide the Dock icon#93
andrew-waters merged 1 commit into
mainfrom
prd-dock-icon

Conversation

@andrew-waters

Copy link
Copy Markdown
Owner

What

Settings > General gains a "Hide Dock icon" toggle. When enabled, Orchard switches its activation policy to .accessory at 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 than LSUIElement). The preference persists in SettingsStore and is applied at launch in OrchardApp.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

  • The activation-policy side effect lives in a small DockIconPolicy helper rather than the SettingsStore setter: the store runs in unit tests on ephemeral defaults, and a store side effect would flip the test runner's activation policy.
  • DockIconPolicy uses NSApplication.shared, not the NSApp global: at the launch call site AppKit hasn't created the application object yet, so NSApp (an implicitly-unwrapped optional) is still nil and crashes. Caught in real-launch testing.
  • Restoring .regular explicitly re-activates the app, working around the AppKit quirk where the Dock icon doesn't reliably come back otherwise.
  • Launch only applies the hidden case: the app starts .regular anyway, and applying .regular would trigger the restore-activation dance on every launch.

Testing

  • 261 unit tests green, including a new SettingsStore persistence round-trip for the preference.
  • Verified live: launched with the preference pre-set in defaults (starts as an accessory, no crash), and toggled both directions at runtime.
  • One operational note: AppleScript quit can 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.

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.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 15fb9255-8524-48e1-9981-6273b2a9b917

📥 Commits

Reviewing files that changed from the base of the PR and between d83e0a0 and 9440526.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • Orchard/OrchardApp.swift
  • Orchard/Services/DockIconPolicy.swift
  • Orchard/Services/SettingsStore.swift
  • Orchard/Views/Features/Settings/SettingsView.swift
  • OrchardTests/SettingsStoreTests.swift

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added a General settings option to hide Orchard’s Dock icon.
    • When enabled, Orchard remains accessible from the menu bar and is removed from the Cmd-Tab app switcher.
    • The preference is applied immediately and retained between launches.
    • The main window can be reopened from the menu bar.
  • Documentation
    • Added a changelog entry describing the Dock icon visibility option.
  • Tests
    • Added coverage for saving, restoring, and resetting the preference.

Walkthrough

Orchard 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.

Changes

Dock icon preference

Layer / File(s) Summary
Persist Dock icon preference
Orchard/Services/SettingsStore.swift, OrchardTests/SettingsStoreTests.swift
SettingsStore loads and saves hideDockIcon through UserDefaults. Tests cover default, persistence, reload, and reset behaviour.
Apply activation policy
Orchard/Services/DockIconPolicy.swift, Orchard/OrchardApp.swift
DockIconPolicy switches between accessory and regular activation policies. OrchardApp applies the persisted hidden state before window creation.
Expose Dock icon setting
Orchard/Views/Features/Settings/SettingsView.swift, CHANGELOG.md
General settings adds the Hide Dock icon toggle and applies the policy after saving. The settings footer and changelog describe menu-bar access and Cmd-Tab behaviour.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 94405

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
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, rationale, design, and testing, but omits the required Related issues, Screenshots / recording, and Checklist sections. Add the missing template sections, including UI screenshots or a recording, related issue details, and completed checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. (1 skipped: 1 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a preference to hide the Dock icon.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch prd-dock-icon

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.

@andrew-waters
andrew-waters merged commit 867ae00 into main Aug 20, 2026
4 checks passed
@andrew-waters
andrew-waters deleted the prd-dock-icon branch August 20, 2026 21:16
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