From a92bf02477217d3495a879641e50d780d1fd431b Mon Sep 17 00:00:00 2001 From: maksarsanjeev Date: Wed, 7 Oct 2026 15:28:42 +0300 Subject: [PATCH] Up-arrow (and toggle hotkey) folds chat/terminal back into the notch even while held open Co-Authored-By: Claude Opus 5.5 --- NotchBuddy/Sources/App/IslandRootView.swift | 2 +- .../Sources/App/IslandWindowController.swift | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swift index 9601c73..0fa8703 100644 --- a/NotchBuddy/Sources/App/IslandRootView.swift +++ b/NotchBuddy/Sources/App/IslandRootView.swift @@ -563,7 +563,7 @@ struct IslandHeader: View { Button(action: { state.chatDragHeight = nil state.chatDetent = 0 - NotificationCenter.default.post(name: .islandCollapse, object: nil) + NotificationCenter.default.post(name: .islandCollapse, object: "user") }) { Image(systemName: "chevron.up") .font(.system(size: 13, weight: .semibold)) diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift index 077f992..08af2af 100644 --- a/NotchBuddy/Sources/App/IslandWindowController.swift +++ b/NotchBuddy/Sources/App/IslandWindowController.swift @@ -369,8 +369,14 @@ final class IslandWindowController: NSWindowController { state.lastActivity = .now } - func collapse() { - guard fsm.isHeldOpen?() != true else { return } + /// `byUser`: the ⌃ button or the toggle hotkey — folds a chat/terminal tab away too; + /// only a pending approval still keeps the island open. + func collapse(byUser: Bool = false) { + if byUser { + guard state.pendingApproval == nil else { return } + } else { + guard fsm.isHeldOpen?() != true else { return } + } state.isPinned = false finishedPinTimer?.cancel() // Keep the FSM in step with what is on screen (home/coucou → petit now). @@ -391,7 +397,7 @@ final class IslandWindowController: NSWindowController { switch action { case .toggleIsland: if state.mode == .expanded { - collapse() + collapse(byUser: true) } else { islandPanel.makeKey() expand(to: defaultView()) @@ -617,8 +623,9 @@ final class IslandWindowController: NSWindowController { } // Collapse requests from views (OK button, etc.) - NotificationCenter.default.addObserver(forName: .islandCollapse, object: nil, queue: .main) { [weak self] _ in - self?.collapse() + NotificationCenter.default.addObserver(forName: .islandCollapse, object: nil, queue: .main) { [weak self] note in + let byUser = (note.object as? String) == "user" + MainActor.assumeIsolated { self?.collapse(byUser: byUser) } } // Wardrobe open/close from desktop Mochi right-click (does NOT post .hookExpand)