Skip to content

fix: keep window open when pinned#62

Merged
Gabko14 merged 1 commit intomainfrom
fix/window-stays-open-when-pinned
Feb 28, 2026
Merged

fix: keep window open when pinned#62
Gabko14 merged 1 commit intomainfrom
fix/window-stays-open-when-pinned

Conversation

@Gabko14
Copy link
Copy Markdown
Owner

@Gabko14 Gabko14 commented Feb 28, 2026

Summary

Fixes Ghostly-9k3 — the window was dismissing when switching to a clipboard manager (or any other app) because MenuBarExtraAccess closes the window whenever it loses key status.

  • Forked MenuBarExtraAccess locally (LocalPackages/MenuBarExtraAccess) and added a staysOpen: Binding<Bool> parameter to menuBarExtraAccess(). When staysOpen is true, the didResignKey handler skips window.close() so the window stays visible. Explicit dismissal (clicking the status item icon, Escape key) still works correctly.
  • Added isPinned: Bool to AppState (stored property, persisted to UserDefaults).
  • Wired staysOpen: $appState.isPinned in GhostlyApp.
  • Added a pin button (pin icon) to the header, to the left of the menu button. Toggling it pins/unpins the window. State is remembered across launches.

Test plan

  • Open Ghostly, click pin icon — it turns lavender/filled
  • While pinned, switch to another app (e.g. Finder, clipboard manager) — Ghostly window stays open
  • Click pin icon again to unpin — switching apps now closes the window as before
  • Escape key and clicking the menu bar icon still close the window even when pinned
  • Pin state persists after quitting and relaunching
  • All unit tests pass

Fork MenuBarExtraAccess locally and add staysOpen support — when true,
the window no longer auto-closes on didResignKey (e.g. switching to a
clipboard manager). Adds an isPinned toggle to AppState persisted via
UserDefaults, wired to the new staysOpen binding. Adds a pin button (📌)
to the header that lets users toggle this behaviour.
@Gabko14 Gabko14 merged commit fb2cb72 into main Feb 28, 2026
2 checks passed
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

PR Review: fix: keep window open when pinned

Overview

This PR solves a usability problem where the Ghostly window dismisses when switching to another app (e.g., clipboard manager). The approach of forking MenuBarExtraAccess and adding a staysOpen binding is reasonable since the upstream library doesn't support this behavior.

Issues to Address

1. Missing Unit Tests

Per CLAUDE.md: "Nothing ships without automated tests. Write unit tests for all logic/model changes."

The isPinned property in AppState needs tests similar to the existing isMenuPresented tests. At minimum:

  • Initial state test (reads from UserDefaults)
  • Toggle test
  • UserDefaults persistence test (verify didSet writes to UserDefaults)

2. Remove Unused Code File

LocalPackages/MenuBarExtraAccess/Sources/MenuBarExtraAccess/Unused/Unused Code.swift contains 54 lines of entirely commented-out code. This should be deleted — per CLAUDE.md, avoid backwards-compatibility hacks like keeping removed code as comments.

Looks Good

  • The staysOpen logic in didResignKey is well-implemented — correctly checks window.isVisible to distinguish between "lost focus" vs "explicitly closed"
  • Pin button UI uses Catppuccin tokens (Color.catLavender, Color.catOverlay) consistently
  • HeaderView signature change is backwards-compatible via the computed settingsManager property
  • License attribution to original author (Steffan Andrews, MIT) is preserved

Minor Note

Consider documenting in the PR body (or a code comment) that this is a fork of orchetect/MenuBarExtraAccess v1.2.2 for future maintainability context.

Gabko14 added a commit that referenced this pull request Feb 28, 2026
…n-pinned"

This reverts commit fb2cb72, reversing
changes made to d2fefbe.
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