From 79c2a45977f7b2f7ec6cfa16a73c3215d3ca768a Mon Sep 17 00:00:00 2001 From: momenbasel Date: Wed, 12 Aug 2026 08:47:14 +0300 Subject: [PATCH] Show the Paste Bar when Pesty is reopened A normal reopen from Finder, Spotlight, or the Dock now surfaces the primary interface instead of Settings. The hidden-menu-bar escape hatch keeps its old behavior: restore the icon and show Settings, since that reopen is a recovery path rather than a request for the bar. Presentation is gated on the explicit BarWindowController.isPresented state rather than NSWindow.isVisible, per the #64 machinery, and duplicate reopen events coalesce because the phase flips as soon as the first show begins. Reopen half of #38; the launch-time auto-show was dropped per review. Co-authored-by: Alvie Stoddard Co-authored-by: Cursor --- Sources/Pesty/AppController.swift | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Sources/Pesty/AppController.swift b/Sources/Pesty/AppController.swift index b82830b..ffc89b5 100644 --- a/Sources/Pesty/AppController.swift +++ b/Sources/Pesty/AppController.swift @@ -77,19 +77,30 @@ final class AppController: NSObject, NSApplicationDelegate { store.saveNow() } - /// The escape hatch for a hidden menu bar icon. + /// Reopening from Finder, Spotlight, or the Dock surfaces the app. /// - /// Pesty is an accessory app, so with the status item hidden there is no Dock icon, - /// no window, and no menu - and if the global hotkey failed to register because - /// another app already owns the combination, there is no way back in at all short of - /// deleting the preference from Terminal. Opening Pesty again from Finder or - /// Spotlight brings the icon back and shows Settings. + /// The escape hatch comes first: Pesty is an accessory app, so with the status + /// item hidden there is no Dock icon, no window, and no menu - and if the global + /// hotkey failed to register because another app already owns the combination, + /// there is no way back in at all short of deleting the preference from Terminal. + /// Opening Pesty again brings the icon back and shows Settings so the user can + /// fix whatever forced the relaunch. + /// + /// A normal reopen shows the Paste Bar - the primary interface should be + /// discoverable without the keyboard shortcut. `hasVisibleWindows` cannot be + /// trusted for that decision because the bar is an NSPanel, so ask the explicit + /// presentation state instead; a duplicate reopen event coalesces naturally + /// because `isPresented` flips as soon as the first show begins. func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) -> Bool { if !Settings.shared.showMenuBarIcon { Settings.shared.showMenuBarIcon = true setMenuBarIconVisible(true) + showSettings() + return true + } + if barController?.isPresented != true { + showBar() } - showSettings() return true }