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.

Open on hover (opt-in)

Claude0ad1b1d4ebe7
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7ad724d2..256f2e95 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -33,6 +33,9 @@ jobs:
- name: Test auto-close timing
run: bash scripts/test-auto-close.sh
+ - name: Test open on hover
+ run: bash scripts/test-island-hover.sh
+
- name: Test link filter
run: bash scripts/test-safe-links.sh
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swift
index 128e3a61..ad88985a 100644
--- a/NotchBuddy/Sources/App/AppState.swift
+++ b/NotchBuddy/Sources/App/AppState.swift
@@ -243,6 +243,10 @@ final class AppState: ObservableObject {
@Published var noteMessage: String? = nil
// Auto-close delay — persisted
+ // Hovering the island opens it (folds shortly after the pointer leaves) — persisted, off by default
+ @Published var openOnHover: Bool = false {
+ didSet { UserDefaults.standard.set(openOnHover, forKey: "openOnHover") }
+ }
@Published var autoCloseInterval: TimeInterval = 15 {
didSet { UserDefaults.standard.set(autoCloseInterval, forKey: "autoCloseInterval") }
}
@@ -457,6 +461,7 @@ final class AppState: ObservableObject {
if let v = ud.string(forKey: "ollamaServerURL"), !v.isEmpty { ollamaServerURL = v }
if let v = ud.string(forKey: "lmstudioServerURL"), !v.isEmpty { lmstudioServerURL = v }
// Migrate old 60s default → 15s
+ if let v = ud.object(forKey: "openOnHover") as? Bool { openOnHover = v }
if let v = ud.object(forKey: "autoCloseInterval") as? Double {
autoCloseInterval = (v == 60) ? 15 : v
}
diff --git a/NotchBuddy/Sources/App/IslandStateMachine.swift b/NotchBuddy/Sources/App/IslandStateMachine.swift
index 178dcf04..dc4e4e6e 100644
--- a/NotchBuddy/Sources/App/IslandStateMachine.swift
+++ b/NotchBuddy/Sources/App/IslandStateMachine.swift
@@ -35,6 +35,14 @@ final class IslandStateMachine {
/// coucou → petit delay when mouse is hovering over the greeting.
var greetHoverCollapseDelay: TimeInterval = 10
+ /// Opt-in (Settings → General → Behavior): hovering the island opens it, and an island
+ /// opened that way folds shortly after the pointer leaves. Off: hover only peeks (petit).
+ var openOnHover = false
+ /// Grace period after the pointer leaves a hover-opened island (no flicker at the edge).
+ var hoverCloseDelay: TimeInterval = 0.6
+ /// True while the island is open because of a hover, until the user clicks inside it.
+ private(set) var openedByHover = false
+
private var petitHideWork: DispatchWorkItem?
private var homeCollapseWork: DispatchWorkItem?
private var greetCollapseWork: DispatchWorkItem?
@@ -49,6 +57,12 @@ final class IslandStateMachine {
/// Mouse entered the island notch area
func mouseEntered() {
+ if openOnHover, state == .hidden || state == .petit, isHeldOpen?() != true {
+ cancelTimers()
+ openedByHover = true
+ transition(to: .home)
+ return
+ }
switch state {
case .hidden:
if isHeldOpen?() == true {
@@ -92,6 +106,7 @@ final class IslandStateMachine {
/// 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() {
+ openedByHover = false
guard state == .petit || state == .hidden else { return }
cancelTimers()
transition(to: .home)
@@ -111,6 +126,7 @@ final class IslandStateMachine {
/// next hover/mouseLeft behave correctly instead of collapsing the island.
func openedExternally() {
cancelTimers()
+ openedByHover = false
guard state != .home && state != .coucou else { return }
state = .home
}
@@ -119,6 +135,7 @@ final class IslandStateMachine {
/// 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() {
+ openedByHover = false
guard state == .home || state == .coucou else { return }
cancelTimers()
transition(to: .petit)
@@ -168,10 +185,18 @@ final class IslandStateMachine {
homeCollapseWork?.cancel()
let item = DispatchWorkItem { [weak self] in
guard let self, self.state == .home, !(self.isHeldOpen?() ?? false) else { return }
+ self.openedByHover = false
self.transition(to: .petit)
}
homeCollapseWork = item
- DispatchQueue.main.asyncAfter(deadline: .now() + homeToPetitDelay, execute: item)
+ let delay = openedByHover ? hoverCloseDelay : homeToPetitDelay
+ DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: item)
+ }
+
+ /// The user clicked inside the island: a hover-opened island now stays like any open
+ /// island (normal auto-close) instead of folding as soon as the pointer leaves.
+ func userInteracted() {
+ openedByHover = false
}
func cancelTimers() {
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index 28d4c16d..669d4657 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -17,6 +17,7 @@ final class IslandWindowController: NSWindowController {
private var viewSubscription: AnyCancellable?
private var displaySubscription: AnyCancellable?
private var autoCloseSubscription: AnyCancellable?
+ private var openOnHoverSubscription: AnyCancellable?
// Confused recovery timer (set by handleDizzy)
private var confusedRecoveryTimer: DispatchWorkItem?
@@ -227,6 +228,9 @@ final class IslandWindowController: NSWindowController {
autoCloseSubscription = state.$autoCloseInterval.sink { [weak self] delay in
self?.fsm.homeToPetitDelay = delay
}
+ openOnHoverSubscription = state.$openOnHover.sink { [weak self] on in
+ self?.fsm.openOnHover = on
+ }
fsm.onTransition = { [weak self] from, to in
guard let self else { return }
@@ -342,18 +346,21 @@ final class IslandWindowController: NSWindowController {
if state.mode == .hidden && fsm.state == .petit { fsm.hiddenExternally() }
// Feed FSM hover enter/leave
- if inIsland && !wasInIsland {
- guard !inAttachDrag else { wasInIsland = inIsland; return }
+ // Update the hit test before feeding the FSM: its transitions read wasInIsland
+ // (a hover-opened island must not start its close timer while the pointer is on it).
+ let previouslyInIsland = wasInIsland
+ wasInIsland = inIsland
+ if inIsland && !previouslyInIsland {
+ guard !inAttachDrag else { return }
// If in coucou: tell greeting to stay open (tc → infinity)
if fsm.state == .coucou {
NotificationCenter.default.post(name: .greetingHover, object: nil)
}
fsm.mouseEntered()
}
- if !inIsland && wasInIsland {
+ if !inIsland && previouslyInIsland {
fsm.mouseLeft()
}
- wasInIsland = inIsland
// Bot-head hover (love emote)
let overBot = state.mode == .expanded && state.stateOverride == nil && isBotHit(local)
@@ -729,6 +736,7 @@ final class IslandWindowController: NSWindowController {
guard let self else { return event }
MainActor.assumeIsolated {
guard self.wasInIsland else { return }
+ self.fsm.userInteracted()
self.pendingIslandClick = true
self.hoverTimer?.cancel()
self.botHoverTimer?.cancel()
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index 00996739..695e768c 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -293,6 +293,8 @@ struct SettingsView: View {
GroupBox("Behavior") {
VStack(alignment: .leading, spacing: 10) {
+ Toggle("Open on hover", isOn: $state.openOnHover)
+ .help("Hovering the island opens it; it folds again shortly after the pointer leaves. Click inside to keep it open.")
HStack(spacing: 8) {
Text("Close after")
TextField("60", value: $state.autoCloseInterval, format: .number)
diff --git a/scripts/test-island-hover.sh b/scripts/test-island-hover.sh
new file mode 100755
index 00000000..562ebab6
--- /dev/null
+++ b/scripts/test-island-hover.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname "$0")/.."
+TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-island-hover.XXXXXX")"
+trap 'rm -rf "$TEST_DIR"' EXIT
+swiftc -swift-version 6 -strict-concurrency=complete \
+ NotchBuddy/Sources/App/IslandStateMachine.swift \
+ tests/IslandHoverTests.swift -o "$TEST_DIR/island-hover-tests"
+"$TEST_DIR/island-hover-tests"
diff --git a/tests/IslandHoverTests.swift b/tests/IslandHoverTests.swift
new file mode 100644
index 00000000..a234bc2e
--- /dev/null
+++ b/tests/IslandHoverTests.swift
@@ -0,0 +1,75 @@
+import Foundation
+
+@main
+enum IslandHoverTests {
+ @MainActor
+ static func main() async throws {
+ // Off (default): hovering only peeks, as before.
+ let off = IslandStateMachine()
+ off.mouseEntered()
+ precondition(off.state == .petit)
+
+ // On: hovering a hidden island opens it, leaving folds it after the short delay.
+ let on = machine()
+ on.mouseEntered()
+ precondition(on.state == .home && on.openedByHover)
+ on.mouseLeft()
+ try await Task.sleep(for: .milliseconds(20))
+ precondition(on.state == .home)
+ try await waitFor(.petit, on, timeout: 1)
+ precondition(!on.openedByHover)
+
+ // Coming back before the delay keeps it open.
+ let back = machine()
+ back.mouseEntered()
+ back.mouseLeft()
+ back.mouseEntered()
+ try await Task.sleep(for: .milliseconds(150))
+ precondition(back.state == .home)
+
+ // A click inside turns it into a normal open island: the auto-close delay applies.
+ let clicked = machine()
+ clicked.homeToPetitDelay = 0.4
+ clicked.mouseEntered()
+ clicked.userInteracted()
+ clicked.mouseLeft()
+ try await Task.sleep(for: .milliseconds(150))
+ precondition(clicked.state == .home)
+ try await waitFor(.petit, clicked, timeout: 1)
+
+ // A pending approval holds the island: hover never opens or folds it on its own.
+ let held = machine()
+ held.isHeldOpen = { true }
+ held.mouseEntered()
+ precondition(held.state == .home && !held.openedByHover)
+ held.mouseLeft()
+ try await Task.sleep(for: .milliseconds(150))
+ precondition(held.state == .home)
+
+ // An island opened by an alert keeps the normal delay even with hover on.
+ let alert = machine()
+ alert.homeToPetitDelay = 0.4
+ alert.openedExternally()
+ alert.mouseEntered()
+ alert.mouseLeft()
+ try await Task.sleep(for: .milliseconds(150))
+ precondition(alert.state == .home)
+
+ print("Island open on hover: 6 cases passed")
+ }
+
+ @MainActor
+ private static func machine() -> IslandStateMachine {
+ let m = IslandStateMachine()
+ m.openOnHover = true
+ m.hoverCloseDelay = 0.08
+ return m
+ }
+
+ @MainActor
+ private static func waitFor(_ s: IslandStateMachine.State, _ m: IslandStateMachine, timeout: TimeInterval) async throws {
+ let deadline = Date().addingTimeInterval(timeout)
+ while m.state != s && Date() < deadline { try await Task.sleep(for: .milliseconds(10)) }
+ precondition(m.state == s, "state \(m.state) after \(timeout) s, expected \(s)")
+ }
+}