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.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Corner island: no swing on open and close, seamless circles, swaps in two beats, the row's pills swap too
Claude95a0e7028dbd
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex 18358305..689c3736 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -361,6 +361,8 @@ final class AppState: ObservableObject {@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+ /// One of them clicked: once open, the island swaps it with Mochi (CornerArcView).+ @Published var cornerPendingSwap: String? = nil/// 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.swiftindex e2ff751d..76b5fecb 100644--- a/NotchBuddy/Sources/App/CornerIsland.swift+++ b/NotchBuddy/Sources/App/CornerIsland.swift@@ -18,6 +18,8 @@ struct CornerArcView: View {@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> = []+ /// Tapped, its circle drawing itself out before the flight.+ @State private var pendingTap: String? = nilprivate struct Swap: Equatable {let incoming: AgentTask@@ -32,7 +34,9 @@ struct CornerArcView: View {/// Mochi's size in the corner, and on the circle (the swap grows one and shrinks the other).static let bigBody: CGFloat = 58static let smallBody: CGFloat = 24- static let swapDuration: Double = 0.55+ static let swapDuration: Double = 0.5+ /// The tapped one's circle draws itself out first, this long, then the two fly.+ static let ringOutDuration: Double = 0.2private var arcTasks: [AgentTask] {let focus = state.focusTask?.id@@ -62,7 +66,7 @@ struct CornerArcView: View {ForEach(Array(tasks.enumerated()), id: \.element.id) { i, task inlet leaving = swap?.incoming.id == task.id- // Its Mochi on its way to the corner (drawn below): its circle draws itself out.+ // Its circle draws itself out, then its Mochi flies to the corner (drawn below).CornerMini(task: task, ring: ringOff.contains(task.id) ? 0 : 1, showBot: !leaving) {start(task, at: i, current: tasks)}@@ -92,19 +96,42 @@ struct CornerArcView: View {}.frame(width: islandW, height: islandH, alignment: .topLeading).animation(.spring(response: 0.42, dampingFraction: 0.8), value: tasks.map(\.id))- .onDisappear { if swap != nil { finish() } }+ .onAppear { swapPending(after: 0.42) }+ .onChange(of: state.cornerPendingSwap) { _, _ in swapPending(after: 0.1) }+ .onDisappear {+ pendingTap = nil+ if swap != nil { finish() }+ }+ }++ /// A pill clicked in the compact tile's row: the island has opened, now it swaps with Mochi.+ private func swapPending(after delay: Double) {+ guard let id = state.cornerPendingSwap else { return }+ state.cornerPendingSwap = nil+ DispatchQueue.main.asyncAfter(deadline: .now() + delay) {+ let tasks = arcTasks+ guard let i = tasks.firstIndex(where: { $0.id == id }) else { return }+ start(tasks[i], at: i, current: tasks)+ }}private func start(_ task: AgentTask, at index: Int, current: [AgentTask]) {- guard swap == nil, let focus = state.focusTask else { return }+ guard swap == nil, pendingTap == nil, let focus = state.focusTask else { return }var ids = current.map(\.id)if index < ids.count { ids[index] = focus.id }- swapStart = Date()- swap = Swap(incoming: task, outgoing: focus, slot: index, order: ids)+ // First its circle and its name go (from the top down both sides)…+ pendingTap = task.idringOff.insert(task.id)- state.cornerSwapping = trueSoundEngine.shared.play("blip")- DispatchQueue.main.asyncAfter(deadline: .now() + Self.swapDuration) { finish() }+ DispatchQueue.main.asyncAfter(deadline: .now() + Self.ringOutDuration) {+ guard pendingTap == task.id else { return }+ pendingTap = nil+ // …then both fly, crossing.+ swapStart = Date()+ swap = Swap(incoming: task, outgoing: focus, slot: index, order: ids)+ state.cornerSwapping = true+ DispatchQueue.main.asyncAfter(deadline: .now() + Self.swapDuration) { finish() }+ }}/// Both have arrived: the one in the corner is now the focus, the other is on the circle.@@ -166,12 +193,9 @@ private struct CornerMini: View {Circle().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))+ // Drawn in from the top, drawn out towards the bottom; whole, a plain circle.+ RingShape(progress: ring, fromBottom: ring < 0.5)+ .stroke(color.opacity(hover ? 0.6 : 0.3), lineWidth: 1.2)MiniBotCanvasView(task: task).frame(width: CornerArcView.smallBody / 0.6, height: CornerArcView.smallBody / 0.6).frame(width: CornerArcView.smallBody, height: CornerArcView.smallBody)@@ -192,8 +216,9 @@ private struct CornerMini: View {.foregroundColor(hover ? color.lighter(by: 0.3) : Color(hex: "#8E939C")).lineLimit(1).fixedSize()- .offset(y: 15 - 4 * (1 - ring))+ .offset(y: 15 - 5 * (1 - ring)).opacity(ring)+ .blur(radius: 2 * (1 - ring)).allowsHitTesting(false)}}@@ -205,15 +230,30 @@ private struct CornerMini: View {}}-/// 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+/// The circle around a Mochi on the arc, drawn in part: an arc spread evenly on both sides of+/// its top (`fromBottom` false: drawing itself in, down both sides) or of its bottom (true: the+/// gap opens at the top and runs down both sides as it goes). Whole, a plain circle: no seam.+private struct RingShape: Shape {+ var progress: CGFloat+ let fromBottom: Bool++ var animatableData: CGFloat {+ get { progress }+ set { progress = newValue }+ }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)+ let r = min(rect.width, rect.height) / 2+ let c = CGPoint(x: rect.midX, y: rect.midY)+ if progress >= 0.999 {+ p.addEllipse(in: CGRect(x: c.x - r, y: c.y - r, width: 2 * r, height: 2 * r))+ } else if progress > 0.001 {+ let mid: Double = fromBottom ? 90 : -90+ let half = 180 * Double(progress)+ p.addArc(center: c, radius: r, startAngle: .degrees(mid - half), endAngle: .degrees(mid + half),+ clockwise: false)+ }return p}}@@ -243,7 +283,8 @@ struct CornerBubbles: View {ForEach(Array(tasks.enumerated()), id: \.element.id) { i, task inlet out = i < shownlet from = i == 0 ? CGPoint(x: t / 2, y: t / 2) : centers[i - 1]- CornerBubble(task: task) { state.setFocus(task.id) }+ // The click opens the island; there it swaps places with Mochi.+ CornerBubble(task: task) { state.cornerPendingSwap = task.id }.scaleEffect(out ? 1 : 0.3).opacity(out ? 1 : 0).position(out ? centers[i] : from)diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swiftindex ea8625b7..bc74e81b 100644--- a/NotchBuddy/Sources/App/IslandRootView.swift+++ b/NotchBuddy/Sources/App/IslandRootView.swift@@ -472,7 +472,12 @@ func botPosition(mode: IslandMode, view: IslandView, islandW: CGFloat, islandH:switch mode {// The corner tile: Mochi alone, big, in its middle.case .hidden, .compact:- return (islandW / 2, islandH / 2 - 2, min(38, max(0, islandH - 22)), 1)+ // Measured from the island's corner, not its middle: right after a mode change the+ // size is still the open one, and the middle of that would send him across it.+ let t = IslandPlacement.tile+ return (placement.isRight ? islandW - t / 2 : t / 2,+ (placement.isBottom ? islandH - t / 2 : t / 2) - 2,+ min(38, max(0, t - 22)), 1)case .expanded where view == .overview:// Open: Mochi in the island's corner, the other pills around him (CornerArcView).let c = placement.cornerBotCenter(in: CGSize(width: islandW, height: islandH))diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swiftindex 44af5e05..11df9f45 100644--- a/NotchBuddy/Sources/App/IslandWindowController.swift+++ b/NotchBuddy/Sources/App/IslandWindowController.swift@@ -1123,7 +1123,9 @@ final class IslandWindowController: NSWindowController {let mouse = NSEvent.mouseLocationlet s = dragGhostSize- ghostCurrentOrigin = NSPoint(x: mouse.x - s/2, y: mouse.y - s/2)+ // He leaves from where he is, then glides to the pointer (updateDragGhost).+ let from = botScreenCenter() ?? mouse+ ghostCurrentOrigin = NSPoint(x: from.x - s/2, y: from.y - s/2)let panel = NSPanel(contentRect: NSRect(x: ghostCurrentOrigin.x, y: ghostCurrentOrigin.y, width: s, height: s),@@ -1185,11 +1187,26 @@ final class IslandWindowController: NSWindowController {}showSnapTarget(nil)#endif- // Direct follow — bot is "held", no trailing lag- ghostCurrentOrigin = NSPoint(x: mouse.x - s/2, y: mouse.y - s/2)+ // Held: he catches up with the pointer in a few frames (no jump when he leaves the+ // island or a corner's place), then follows it closely.+ let target = NSPoint(x: mouse.x - s/2, y: mouse.y - s/2)+ let k: CGFloat = 0.4+ ghostCurrentOrigin = NSPoint(x: ghostCurrentOrigin.x + (target.x - ghostCurrentOrigin.x) * k,+ y: ghostCurrentOrigin.y + (target.y - ghostCurrentOrigin.y) * k)panel.setFrameOrigin(ghostCurrentOrigin)}+ /// Mochi's centre on the screen, where the island draws him now.+ private func botScreenCenter() -> NSPoint? {+ let s = state+ let (w, h) = islandSize(mode: s.mode, view: s.view, progress: s.uploadProgress, nw: notchW, nh: notchH)+ let (cx, cy, _, _) = botPosition(mode: s.mode, view: s.view, islandW: w, islandH: h,+ uploadProgress: s.uploadProgress, hasNotch: s.hasNotch)+ let rect = Self.islandScreenRect(size: CGSize(width: w, height: h))+ guard rect.width > 0 else { return nil }+ return NSPoint(x: rect.minX + cx, y: rect.maxY - cy)+ }+/// The placement a drop at `mouse` would move the island to (not the one it has), and the/// tile it will take on the screen.private func snapTarget(at mouse: NSPoint) -> (IslandPlacement, CGRect)? {