Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Keep the island state machine in step so the island always reopens

rouderz593eda381077
diff --git a/NotchBuddy/Sources/App/IslandStateMachine.swift b/NotchBuddy/Sources/App/IslandStateMachine.swift
index fa937e69..4c309bed 100644
--- a/NotchBuddy/Sources/App/IslandStateMachine.swift
+++ b/NotchBuddy/Sources/App/IslandStateMachine.swift
@@ -72,13 +72,33 @@ final class IslandStateMachine {
}
}
- /// Compact island clicked
+ /// Compact island clicked.
+ /// Also accepts `.hidden`: after an alert the island can be on screen while the
+ /// FSM never saw the mouse enter (it was already there), and the click must still open it.
func click() {
- guard state == .petit else { return }
+ guard state == .petit || state == .hidden else { return }
cancelTimers()
transition(to: .home)
}
+ /// The app hid the island on its own (e.g. `AppState.syncMode()` when the last
+ /// task ends). Mirror it without side effects, so the next hover peeks again
+ /// instead of being swallowed by a FSM that still thinks the island is `.petit`.
+ func hiddenExternally() {
+ guard state == .petit else { return }
+ cancelTimers()
+ state = .hidden
+ }
+
+ /// The app folded the island itself (Escape, Settings, OK button, auto-close).
+ /// Move to `.petit` right away so hover and click keep working; waiting for the
+ /// 15 s home timer left the island compact on screen while the FSM still said `.home`.
+ func collapse() {
+ guard state == .home || state == .coucou else { return }
+ cancelTimers()
+ transition(to: .petit)
+ }
+
/// Greeting animation finished (called at T.end ≈ 4.60 s).
/// Schedules auto-collapse. Does not override a longer hover timer already running.
func greetComplete() {
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index d01c5e61..d506297c 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -237,6 +237,9 @@ final class IslandWindowController: NSWindowController {
AppState.shared.mousePosition = newPos
}
+ // AppState can hide the island by itself (last task ended): keep the FSM in step.
+ if state.mode == .hidden && fsm.state == .petit { fsm.hiddenExternally() }
+
// Feed FSM hover enter/leave
if inIsland && !wasInIsland {
guard !inAttachDrag else { wasInIsland = inIsland; return }
@@ -343,8 +346,8 @@ final class IslandWindowController: NSWindowController {
func collapse() {
state.isPinned = false
finishedPinTimer?.cancel()
- // Tell FSM we're going to compact (from home)
- if fsm.state == .home { fsm.mouseLeft() }
+ // Keep the FSM in step with what is on screen (home/coucou → petit now).
+ fsm.collapse()
setMode(.compact)
window?.resignKey()
}
@@ -448,7 +451,12 @@ final class IslandWindowController: NSWindowController {
} else {
self.attachDragStart = nil
if hadPendingClick && self.state.mode != .expanded {
- self.fsm.click() // FSM petit→home; onTransition calls expand(to:)
+ if self.fsm.state == .home {
+ // FSM already thinks it's open (e.g. the view folded it): just reopen.
+ self.expand(to: self.defaultView())
+ } else {
+ self.fsm.click() // FSM petit/hidden→home; onTransition calls expand(to:)
+ }
}
}
}