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.

Corner island: Mochi nearer his circle, rounded tile, pills out of the tile on hover, circles drawn in and out

Claude448532dfefa1
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swift
index 8ab3dd07..18358305 100644
--- a/NotchBuddy/Sources/App/AppState.swift
+++ b/NotchBuddy/Sources/App/AppState.swift
@@ -359,6 +359,8 @@ final class AppState: ObservableObject {
/// Two Mochis swapping places in a corner (CornerArcView draws both): the main one hides.
@Published var cornerSwapping = false
+ /// The pointer on the compact tile in a corner: the other pills come out of it (CornerBubbles).
+ @Published var cornerPeek = false
/// Where the island lives on its screen: the notch, or a corner (IslandPlacement) — persisted.
@Published var islandPlacement: IslandPlacement = .notch {
diff --git a/NotchBuddy/Sources/App/CornerIsland.swift b/NotchBuddy/Sources/App/CornerIsland.swift
index d3513c08..e2ff751d 100644
--- a/NotchBuddy/Sources/App/CornerIsland.swift
+++ b/NotchBuddy/Sources/App/CornerIsland.swift
@@ -16,6 +16,8 @@ struct CornerArcView: View {
/// Two Mochis swapping places: the one arriving in the corner and the one leaving it.
@State private var swap: Swap? = nil
@State private var swapStart = Date.distantPast
+ /// Circles drawn out (ring off): the one a Mochi left, the one a Mochi just reached.
+ @State private var ringOff: Set<String> = []
private struct Swap: Equatable {
let incoming: AgentTask
@@ -60,11 +62,11 @@ struct CornerArcView: View {
ForEach(Array(tasks.enumerated()), id: \.element.id) { i, task in
let leaving = swap?.incoming.id == task.id
- CornerMini(task: task) { start(task, at: i, current: tasks) }
- // Its Mochi is on its way to the corner (drawn below): the button stays empty.
- .opacity(leaving ? 0 : 1)
- .position(i < points.count ? points[i] : home)
- .transition(.opacity)
+ // Its Mochi on its way to the corner (drawn below): its circle draws itself out.
+ CornerMini(task: task, ring: ringOff.contains(task.id) ? 0 : 1, showBot: !leaving) {
+ start(task, at: i, current: tasks)
+ }
+ .position(i < points.count ? points[i] : home)
}
// The swap: each one on its own curve, crossing the other halfway.
@@ -99,6 +101,7 @@ struct CornerArcView: View {
if index < ids.count { ids[index] = focus.id }
swapStart = Date()
swap = Swap(incoming: task, outgoing: focus, slot: index, order: ids)
+ ringOff.insert(task.id)
state.cornerSwapping = true
SoundEngine.shared.play("blip")
DispatchQueue.main.asyncAfter(deadline: .now() + Self.swapDuration) { finish() }
@@ -114,7 +117,11 @@ struct CornerArcView: View {
state.setFocus(s.incoming.id)
state.cornerSwapping = false
swap = nil
+ ringOff.remove(s.incoming.id)
+ ringOff.insert(s.outgoing.id)
}
+ // The one that left the corner has reached its place: its circle draws itself in.
+ DispatchQueue.main.async { ringOff.remove(s.outgoing.id) }
}
}
@@ -138,9 +145,12 @@ enum CornerCurve {
}
}
-/// One pill's Mochi on the circle: a round button in its colour, its name under it.
+/// One pill's Mochi on the circle: a round button in its colour, its name under it. Its circle
+/// draws itself in and out from the top, down both sides at once (`ring`, 0 to 1).
private struct CornerMini: View {
let task: AgentTask
+ let ring: CGFloat
+ let showBot: Bool
let onTap: () -> Void
@State private var hover = false
@@ -149,37 +159,141 @@ private struct CornerMini: View {
}
var body: some View {
+ let color = Color(hex: task.color)
Button(action: onTap) {
ZStack(alignment: .topTrailing) {
ZStack {
Circle()
- .fill(hover ? Color(hex: task.color).opacity(0.18) : Color(hex: "#0E0F11"))
- Circle()
- .stroke(Color(hex: task.color).opacity(hover ? 0.6 : 0.22), lineWidth: 1.2)
+ .fill(hover ? color.opacity(0.18) : Color(hex: "#0E0F11"))
+ .opacity(ring)
+ HalfRing(right: true)
+ .trim(from: 0, to: ring)
+ .stroke(color.opacity(hover ? 0.6 : 0.3), style: StrokeStyle(lineWidth: 1.2, lineCap: .round))
+ HalfRing(right: false)
+ .trim(from: 0, to: ring)
+ .stroke(color.opacity(hover ? 0.6 : 0.3), style: StrokeStyle(lineWidth: 1.2, lineCap: .round))
MiniBotCanvasView(task: task)
.frame(width: CornerArcView.smallBody / 0.6, height: CornerArcView.smallBody / 0.6)
.frame(width: CornerArcView.smallBody, height: CornerArcView.smallBody)
+ .opacity(showBot ? 1 : 0)
}
.frame(width: 40, height: 40)
- .shadow(color: Color(hex: task.color).opacity(hover ? 0.35 : 0), radius: 10)
+ .shadow(color: color.opacity(hover ? 0.35 : 0), radius: 10)
if let badge = task.pillBadge {
PillBadgeView(badge: badge, taskColor: task.color)
.offset(x: 2, y: -2)
+ .opacity(ring)
}
}
.overlay(alignment: .bottom) {
Text(verbatim: name)
.font(.system(size: 9.5, weight: .semibold))
- .foregroundColor(hover ? Color(hex: task.color).lighter(by: 0.3) : Color(hex: "#8E939C"))
+ .foregroundColor(hover ? color.lighter(by: 0.3) : Color(hex: "#8E939C"))
.lineLimit(1)
.fixedSize()
- .offset(y: 15)
+ .offset(y: 15 - 4 * (1 - ring))
+ .opacity(ring)
.allowsHitTesting(false)
}
}
.buttonStyle(.plain)
.scaleEffect(hover ? 1.1 : 1)
+ .animation(.easeInOut(duration: 0.32), value: ring)
+ .onHover { h in withAnimation(.spring(response: 0.2, dampingFraction: 0.7)) { hover = h } }
+ .help(name)
+ }
+}
+
+/// Half a circle, from its top down to its bottom, on the right side or the left one.
+private struct HalfRing: Shape {
+ let right: Bool
+
+ func path(in rect: CGRect) -> Path {
+ var p = Path()
+ // SwiftUI's y goes down: "not clockwise" here turns clockwise on screen (the right side).
+ p.addArc(center: CGPoint(x: rect.midX, y: rect.midY), radius: min(rect.width, rect.height) / 2,
+ startAngle: .degrees(-90), endAngle: .degrees(90), clockwise: !right)
+ return p
+ }
+}
+
+/// Compact in a corner, the pointer on the tile: the other pills come out of it one after the
+/// other, each small tile born from the one before, along the screen's edge. A click opens
+/// the island on that pill.
+struct CornerBubbles: View {
+ @ObservedObject var state: AppState
+ @State private var shown = 0
+
+ static let maxShown = 4
+
+ static func tasks(_ state: AppState) -> [AgentTask] {
+ let focus = state.focusTask?.id
+ return Array(state.tasks.filter { $0.id != focus }.prefix(maxShown))
+ }
+
+ static func count(_ state: AppState) -> Int { tasks(state).count }
+
+ var body: some View {
+ let placement = state.islandPlacement
+ let tasks = Self.tasks(state)
+ let centers = placement.bubbleCenters(count: tasks.count)
+ let t = IslandPlacement.tile
+ ZStack(alignment: .topLeading) {
+ ForEach(Array(tasks.enumerated()), id: \.element.id) { i, task in
+ let out = i < shown
+ let from = i == 0 ? CGPoint(x: t / 2, y: t / 2) : centers[i - 1]
+ CornerBubble(task: task) { state.setFocus(task.id) }
+ .scaleEffect(out ? 1 : 0.3)
+ .opacity(out ? 1 : 0)
+ .position(out ? centers[i] : from)
+ }
+ }
+ .frame(width: t, height: t, alignment: .topLeading)
+ .onAppear {
+ for i in 0..<tasks.count {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.06 * Double(i)) {
+ withAnimation(.spring(response: 0.32, dampingFraction: 0.68)) { shown = max(shown, i + 1) }
+ }
+ }
+ }
+ }
+}
+
+/// One of them: a small black tile with rounded corners, the pill's mini Mochi inside.
+private struct CornerBubble: View {
+ let task: AgentTask
+ let onTap: () -> Void
+ @State private var hover = false
+
+ private var name: String {
+ task.id == "integration_claude" ? ClaudeHost.pillName(hostApp: task.hostApp) : task.name
+ }
+
+ var body: some View {
+ let color = Color(hex: task.color)
+ Button(action: onTap) {
+ ZStack(alignment: .topTrailing) {
+ ZStack {
+ RoundedRectangle(cornerRadius: 12, style: .continuous)
+ .fill(Color.black)
+ RoundedRectangle(cornerRadius: 12, style: .continuous)
+ .strokeBorder(color.opacity(hover ? 0.6 : 0.25), lineWidth: 1)
+ MiniBotCanvasView(task: task)
+ .frame(width: 22 / 0.6, height: 22 / 0.6)
+ .frame(width: 22, height: 22)
+ }
+ .frame(width: IslandPlacement.bubble, height: IslandPlacement.bubble)
+ .shadow(color: .black.opacity(0.45), radius: 10, y: 4)
+
+ if let badge = task.pillBadge {
+ PillBadgeView(badge: badge, taskColor: task.color)
+ .offset(x: 3, y: -3)
+ }
+ }
+ }
+ .buttonStyle(.plain)
+ .scaleEffect(hover ? 1.08 : 1)
.onHover { h in withAnimation(.spring(response: 0.2, dampingFraction: 0.7)) { hover = h } }
.help(name)
}
diff --git a/NotchBuddy/Sources/App/IslandPlacement.swift b/NotchBuddy/Sources/App/IslandPlacement.swift
index 86db8323..77f8052f 100644
--- a/NotchBuddy/Sources/App/IslandPlacement.swift
+++ b/NotchBuddy/Sources/App/IslandPlacement.swift
@@ -23,10 +23,17 @@ enum IslandPlacement: String, CaseIterable, Sendable {
static let side: CGFloat = 40
/// A drop of Mochi this close to a corner of the screen moves the island there.
static let snapDistance: CGFloat = 180
- /// The resting island in a corner: a round tile with Mochi alone (no mini Mochis).
+ /// The resting island in a corner: a square tile with rounded corners, Mochi alone in it.
static let tile: CGFloat = 60
- /// Open in a corner, Mochi sits this far from the island's corner (his centre)…
+ static let tileCorner: CGFloat = 18
+ /// Hovering the tile: the other pills come out of it one after the other, as small tiles
+ /// along the screen's edge (the size of each, and the room between two).
+ static let bubble: CGFloat = 40
+ static let bubbleGap: CGFloat = 8
+ /// Open in a corner, the circle of Mochis is centred this far from the island's corner…
static let cornerInset: CGFloat = 50
+ /// …and Mochi sits nearer to them, this much further in on each side.
+ static let cornerPull: CGFloat = 30
/// …raised a little: his body is drawn a bit below the middle of his canvas, so the room
/// above him and beside him look the same.
static let lift: CGFloat = 4
@@ -42,19 +49,43 @@ enum IslandPlacement: String, CaseIterable, Sendable {
/// The placement the views read without reaching AppState (set by AppState.islandPlacement).
nonisolated(unsafe) static var current: IslandPlacement = .notch
- /// Mochi's centre in an open island of `size`, in the island's own coordinates (y down):
- /// in its corner.
- func cornerBotCenter(in size: CGSize) -> CGPoint {
+ /// The centre of the circle the other Mochis sit on, in an open island of `size`, in the
+ /// island's own coordinates (y down): near its corner.
+ func cornerArcCenter(in size: CGSize) -> CGPoint {
let i = Self.cornerInset
return CGPoint(x: isRight ? size.width - i : i,
y: (isBottom ? size.height - i : i) - Self.lift)
}
+ /// Mochi's centre in an open island (y down): in the corner, pulled towards his circle.
+ func cornerBotCenter(in size: CGSize) -> CGPoint {
+ let c = cornerArcCenter(in: size), d = Self.cornerPull
+ return CGPoint(x: c.x + (isRight ? -d : d), y: c.y + (isBottom ? -d : d))
+ }
+
+ /// Hovering the tile: where the other pills' small tiles go (centres, in the tile's own
+ /// coordinates, y down), one after the other along the screen's edge, inwards.
+ func bubbleCenters(count: Int, tile: CGFloat = IslandPlacement.tile) -> [CGPoint] {
+ guard isCorner else { return [] }
+ let step = Self.bubble + Self.bubbleGap
+ return (0..<count).map { i in
+ let d = Self.bubbleGap + Self.bubble / 2 + CGFloat(i) * step
+ return CGPoint(x: isRight ? -d : tile + d, y: tile / 2)
+ }
+ }
+
+ /// The tile and its small tiles together (tile coordinates, y down): the pointer may go
+ /// from one to the other without the island closing them.
+ func bubblesRect(count: Int, tile: CGFloat = IslandPlacement.tile) -> CGRect {
+ let w = CGFloat(count) * (Self.bubble + Self.bubbleGap)
+ return CGRect(x: isRight ? -w : 0, y: 0, width: tile + w, height: tile)
+ }
+
/// The other pills' Mochis around him (y down): `count` points on the quarter circle that
/// faces the inside of the screen, from the side along the edge to the side going inwards.
func arcPoints(count: Int, in size: CGSize) -> [CGPoint] {
guard count > 0, isCorner else { return [] }
- let c = cornerBotCenter(in: size), r = Self.arcRadius
+ let c = cornerArcCenter(in: size), r = Self.arcRadius
// Angles (degrees, y down): the quarter facing away from the corner.
let (from, to): (Double, Double) = switch self {
case .topRight: (180, 90)
diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swift
index d5c61df9..ea8625b7 100644
--- a/NotchBuddy/Sources/App/IslandRootView.swift
+++ b/NotchBuddy/Sources/App/IslandRootView.swift
@@ -125,6 +125,13 @@ struct IslandContainer: View {
}
}
+ // Compact in a corner, the pointer on it: the other pills come out of the tile.
+ if state.mode == .compact && state.islandPlacement.isCorner && state.cornerPeek {
+ CornerBubbles(state: state)
+ .frame(width: islandWidth, height: islandHeight)
+ .transition(.opacity)
+ }
+
// Open in a corner: the other pills' Mochis on a quarter circle around Mochi.
if state.mode == .expanded && state.view == .overview && state.islandPlacement.isCorner
&& !uploadActive && !greetingActive {
@@ -142,14 +149,12 @@ struct IslandContainer: View {
// Mochi only moves between his own places (the tile's middle, the open corner).
let p = state.islandPlacement
let box: CGFloat = 300
+ // No mask here: a mask growing with the island cut him while he moved.
BotPlacement(state: state, islandW: islandWidth, islandH: islandHeight,
shift: CGSize(width: p.isRight ? islandWidth - box : 0,
- height: p.isBottom ? islandHeight - box : 0))
+ height: p.isBottom ? islandHeight - box : 0),
+ damping: 0.92)
.frame(width: box, height: box)
- .mask(alignment: p.alignment) {
- Rectangle().frame(width: islandWidth,
- height: state.mode == .expanded ? 320 : islandHeight)
- }
.frame(width: islandWidth, height: islandHeight, alignment: p.alignment)
.opacity(uploadActive || greetingActive ? 0 : 1)
.animation(.easeInOut(duration: 0.25), value: uploadActive || greetingActive)
@@ -268,7 +273,7 @@ struct IslandContainer: View {
/// The island's corner radius: in a screen corner, resting or compact, a round tile.
private func islandCorner(_ mode: IslandMode) -> CGFloat {
if mode == .expanded { return IslandConst.expandedCorner }
- return state.islandPlacement.isCorner ? IslandPlacement.tile / 2 : IslandConst.roundedCorner
+ return state.islandPlacement.isCorner ? IslandPlacement.tileCorner : IslandConst.roundedCorner
}
private func modeOrder(_ m: IslandMode) -> Int {
@@ -365,6 +370,8 @@ struct BotPlacement: View {
/// Drawn in a box held by the island's corner (corner placements): the island's
/// coordinates minus this, so Mochi doesn't drift while the island grows from its corner.
var shift: CGSize = .zero
+ /// How he springs between his places (in a corner: no bounce, he goes straight there).
+ var damping: Double = 0.72
var body: some View {
let (rawCx, rawCy, diameter, rawOpacity) = botPosition(mode: state.mode, view: state.view, islandW: islandW, islandH: islandH, uploadProgress: state.uploadProgress, hasNotch: state.hasNotch)
@@ -422,9 +429,9 @@ struct BotPlacement: View {
.frame(width: canvasSize, height: canvasSize + overhang)
.opacity(state.isDraggingBot || state.mochiOnDesktop ? 0 : opacity)
.position(x: cx, y: cy - overhang / 2)
- .animation(.spring(response: 0.5, dampingFraction: 0.72), value: cx)
- .animation(.spring(response: 0.5, dampingFraction: 0.72), value: cy)
- .animation(.spring(response: 0.5, dampingFraction: 0.72), value: canvasSize)
+ .animation(.spring(response: 0.5, dampingFraction: damping), value: cx)
+ .animation(.spring(response: 0.5, dampingFraction: damping), value: cy)
+ .animation(.spring(response: 0.5, dampingFraction: damping), value: canvasSize)
.transition(.scale(scale: 0.01, anchor: .center).combined(with: .opacity))
}
}
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index b7a3a50a..44af5e05 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -470,9 +470,21 @@ final class IslandWindowController: NSWindowController {
let islandRect = panel.currentIslandFrame(nw: notchW, nh: notchH)
// On a screen without a notch, the resting bar must not intercept clicks
// in the app window immediately below the menu bar.
- let hoverRect = !hasNotch && state.mode != .expanded
+ var hoverRect = !hasNotch && state.mode != .expanded
? islandRect : islandRect.insetBy(dx: -6, dy: -6)
+ // Compact in a corner with the pills out of the tile: they count as the island.
+ let placement = state.islandPlacement
+ if placement.isCorner && state.mode == .compact && state.cornerPeek {
+ let n = CornerBubbles.count(state)
+ if n > 0 {
+ let b = placement.bubblesRect(count: n) // tile coordinates, y down
+ hoverRect = hoverRect.union(CGRect(x: islandRect.minX + b.minX, y: islandRect.maxY - b.maxY,
+ width: b.width, height: b.height))
+ }
+ }
let inIsland = hoverRect.contains(local)
+ let peek = placement.isCorner && state.mode == .compact && inIsland
+ if state.cornerPeek != peek { state.cornerPeek = peek }
// Toggle click-through
let shouldAcceptMouse = inIsland || inAttachDrag || attachDragStart != nil
diff --git a/tests/IslandPlacementTests.swift b/tests/IslandPlacementTests.swift
index c638dc67..2fa1aa3e 100644
--- a/tests/IslandPlacementTests.swift
+++ b/tests/IslandPlacementTests.swift
@@ -40,14 +40,18 @@ enum IslandPlacementTests {
// Open in a corner: Mochi in the corner, the others on a quarter circle facing inwards.
let home = IslandPlacement.homeSize
- precondition(IslandPlacement.topRight.cornerBotCenter(in: home) == CGPoint(x: 590, y: 46))
- precondition(IslandPlacement.bottomLeft.cornerBotCenter(in: home) == CGPoint(x: 50, y: 206))
+ precondition(IslandPlacement.topRight.cornerArcCenter(in: home) == CGPoint(x: 590, y: 46))
+ precondition(IslandPlacement.topRight.cornerBotCenter(in: home) == CGPoint(x: 560, y: 76), "nearer to his circle")
+ precondition(IslandPlacement.bottomLeft.cornerBotCenter(in: home) == CGPoint(x: 80, y: 176))
for p in IslandPlacement.allCases where p.isCorner {
- let c = p.cornerBotCenter(in: home)
+ let c = p.cornerArcCenter(in: home)
let pts = p.arcPoints(count: 4, in: home)
+ // Mochi closer to each of them than the circle's centre is, and never on one.
+ let b = p.cornerBotCenter(in: home)
precondition(pts.count == 4)
for q in pts {
precondition(abs(hypot(q.x - c.x, q.y - c.y) - IslandPlacement.arcRadius) < 0.01)
+ precondition(hypot(q.x - b.x, q.y - b.y) < IslandPlacement.arcRadius && hypot(q.x - b.x, q.y - b.y) > 80)
// Inside the island with room for the name under it, inside the corner column.
precondition(q.x > 20 && q.x < home.width - 20 && q.y > 20 && q.y + 20 + 16 < home.height, "\(p) \(q) inside the island")
precondition(abs(q.x - c.x) + 20 <= IslandPlacement.cornerColumn, "\(p) \(q) in the corner column")
@@ -60,6 +64,13 @@ enum IslandPlacementTests {
let four = IslandPlacement.topRight.arcPoints(count: 4, in: home)
for (a, b) in zip(four, four.dropFirst()) { precondition(hypot(a.x - b.x, a.y - b.y) > 70) }
precondition(IslandPlacement.notch.arcPoints(count: 3, in: home).isEmpty)
+ // Hovering the tile: the small tiles go along the edge, inwards, inside their hover area.
+ let bubbles = IslandPlacement.topRight.bubbleCenters(count: 4)
+ precondition(bubbles.count == 4 && bubbles.allSatisfy { $0.x < 0 && $0.y == 30 })
+ precondition(zip(bubbles, bubbles.dropFirst()).allSatisfy { $0.x - $1.x == 48 })
+ let area = IslandPlacement.topRight.bubblesRect(count: 4)
+ precondition(bubbles.allSatisfy { area.contains($0) } && area.contains(CGPoint(x: 30, y: 30)))
+ precondition(IslandPlacement.bottomLeft.bubbleCenters(count: 2).allSatisfy { $0.x > 60 })
let t = IslandPlacement.bottomRight.dropTarget(screen: screen, visible: visible, panelSize: panel)
precondition(t == CGRect(x: 1442, y: 80, width: 60, height: 60), "\(t)")
print("IslandPlacement tests: all passed")