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: a round tile, Mochi held by the corner, a crossing swap, room for names
Claude351156411229
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex 95c20b67..8ab3dd07 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -357,6 +357,9 @@ final class AppState: ObservableObject {didSet { UserDefaults.standard.set(Int(hotkeyCode), forKey: "hotkeyCode") }}+ /// Two Mochis swapping places in a corner (CornerArcView draws both): the main one hides.+ @Published var cornerSwapping = false+/// Where the island lives on its screen: the notch, or a corner (IslandPlacement) — persisted.@Published var islandPlacement: IslandPlacement = .notch {didSet {diff --git a/NotchBuddy/Sources/App/CornerIsland.swift b/NotchBuddy/Sources/App/CornerIsland.swiftindex 5b431776..166b6f4d 100644--- a/NotchBuddy/Sources/App/CornerIsland.swift+++ b/NotchBuddy/Sources/App/CornerIsland.swift@@ -13,11 +13,24 @@ struct CornerArcView: View {/// The circle's order, kept across swaps (the one leaving the corner takes the place of the/// one arriving), new pills added at the end.@State private var order: [String] = []- /// The Mochi flying to the corner, during the swap.- @State private var flying: String? = nil+ /// Two Mochis swapping places: the one arriving in the corner and the one leaving it.+ @State private var swap: Swap? = nil+ @State private var swapT: CGFloat = 0++ private struct Swap: Equatable {+ let incoming: AgentTask+ let outgoing: AgentTask+ let slot: Int+ let order: [String]+ static func == (a: Swap, b: Swap) -> Bool { a.incoming.id == b.incoming.id && a.slot == b.slot }+ }/// Room for five around Mochi; the others are a tap on the circle away once one leaves it.static let maxShown = 5+ /// Mochi's size in the corner, and on the circle (the swap grows one and shrinks the other).+ static let bigBody: CGFloat = 58+ static let smallBody: CGFloat = 24+ static let swapDuration: Double = 0.55private var arcTasks: [AgentTask] {let focus = state.focusTask?.id@@ -46,35 +59,92 @@ struct CornerArcView: View {.allowsHitTesting(false)ForEach(Array(tasks.enumerated()), id: \.element.id) { i, task in- let isFlying = flying == task.id- CornerMini(task: task) { swap(to: task, at: i, current: tasks) }- .scaleEffect(isFlying ? 1.45 : 1)- .opacity(isFlying ? 0 : 1)- .position(isFlying ? home : (i < points.count ? points[i] : home))- .transition(.scale(scale: 0.4).combined(with: .opacity))+ 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)+ }++ // The swap: each one on its own curve, crossing the other halfway.+ if let s = swap, s.slot < points.count {+ let slot = points[s.slot]+ let small = Self.smallBody / Self.bigBody+ MiniBotCanvasView(task: s.outgoing)+ .frame(width: Self.bigBody / 0.6, height: Self.bigBody / 0.6)+ .modifier(CurveMove(t: swapT, from: home, to: slot, bulge: 46,+ fromScale: 1, toScale: small))+ .allowsHitTesting(false)+ MiniBotCanvasView(task: s.incoming)+ .frame(width: Self.bigBody / 0.6, height: Self.bigBody / 0.6)+ .modifier(CurveMove(t: swapT, from: slot, to: home, bulge: 46,+ fromScale: small, toScale: 1))+ .allowsHitTesting(false)}}.frame(width: islandW, height: islandH, alignment: .topLeading)- .clipped()- .animation(.spring(response: 0.42, dampingFraction: 0.78), value: tasks.map(\.id))- .animation(.spring(response: 0.26, dampingFraction: 0.85), value: flying)+ .animation(.spring(response: 0.42, dampingFraction: 0.8), value: tasks.map(\.id))+ .onDisappear { if swap != nil { finish() } }}- private func swap(to task: AgentTask, at index: Int, current: [AgentTask]) {- guard flying == nil else { return }+ private func start(_ task: AgentTask, at index: Int, current: [AgentTask]) {+ guard swap == nil, let focus = state.focusTask else { return }var ids = current.map(\.id)- if let focus = state.focusTask?.id, index < ids.count { ids[index] = focus }- flying = task.id+ if index < ids.count { ids[index] = focus.id }+ swap = Swap(incoming: task, outgoing: focus, slot: index, order: ids)+ swapT = 0+ state.cornerSwapping = trueSoundEngine.shared.play("blip")- DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {- order = ids- state.setFocus(task.id)- flying = nil+ withAnimation(.timingCurve(0.5, 0, 0.25, 1, duration: Self.swapDuration)) { swapT = 1 }+ 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.+ private func finish() {+ guard let s = swap else { return }+ var tr = Transaction()+ tr.disablesAnimations = true+ withTransaction(tr) {+ order = s.order+ state.setFocus(s.incoming.id)+ state.cornerSwapping = false+ swap = nil+ swapT = 0}}}-/// One pill's Mochi on the circle: a round button in its colour, its name on hover.+/// Moves a view along a curve from `from` to `to` (a quadratic curve bowed `bulge` points to the+/// side), resizing it on the way. Two of them with the same bulge, in opposite directions, cross.+private struct CurveMove: ViewModifier, Animatable {+ var t: CGFloat+ let from: CGPoint+ let to: CGPoint+ let bulge: CGFloat+ let fromScale: CGFloat+ let toScale: CGFloat++ var animatableData: CGFloat {+ get { t }+ set { t = newValue }+ }++ func body(content: Content) -> some View {+ let dx = to.x - from.x, dy = to.y - from.y+ let len = max(1, hypot(dx, dy))+ let mid = CGPoint(x: (from.x + to.x) / 2, y: (from.y + to.y) / 2)+ let ctrl = CGPoint(x: mid.x - dy / len * bulge, y: mid.y + dx / len * bulge)+ let u = 1 - t+ let p = CGPoint(x: u * u * from.x + 2 * u * t * ctrl.x + t * t * to.x,+ y: u * u * from.y + 2 * u * t * ctrl.y + t * t * to.y)+ return content+ .scaleEffect(fromScale + (toScale - fromScale) * t)+ .position(p)+ }+}++/// One pill's Mochi on the circle: a round button in its colour, its name under it.private struct CornerMini: View {let task: AgentTasklet onTap: () -> Void@@ -93,8 +163,8 @@ private struct CornerMini: View {Circle().stroke(Color(hex: task.color).opacity(hover ? 0.6 : 0.22), lineWidth: 1.2)MiniBotCanvasView(task: task)- .frame(width: 24 / 0.6, height: 24 / 0.6)- .frame(width: 24, height: 24)+ .frame(width: CornerArcView.smallBody / 0.6, height: CornerArcView.smallBody / 0.6)+ .frame(width: CornerArcView.smallBody, height: CornerArcView.smallBody)}.frame(width: 40, height: 40).shadow(color: Color(hex: task.color).opacity(hover ? 0.35 : 0), radius: 10)@@ -107,13 +177,10 @@ private struct CornerMini: View {.overlay(alignment: .bottom) {Text(verbatim: name).font(.system(size: 9.5, weight: .semibold))- .foregroundColor(Color(hex: task.color).lighter(by: 0.3))+ .foregroundColor(hover ? Color(hex: task.color).lighter(by: 0.3) : Color(hex: "#8E939C")).lineLimit(1).fixedSize()- .padding(.horizontal, 6).padding(.vertical, 2)- .background(Capsule().fill(Color.black.opacity(0.85)))- .offset(y: 18)- .opacity(hover ? 1 : 0)+ .offset(y: 15).allowsHitTesting(false)}}diff --git a/NotchBuddy/Sources/App/IslandPlacement.swift b/NotchBuddy/Sources/App/IslandPlacement.swiftindex 437fac18..86db8323 100644--- a/NotchBuddy/Sources/App/IslandPlacement.swift+++ b/NotchBuddy/Sources/App/IslandPlacement.swift@@ -23,15 +23,21 @@ 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 square tile with Mochi alone (no mini Mochis).+ /// The resting island in a corner: a round tile with Mochi alone (no mini Mochis).static let tile: CGFloat = 60- /// Open in a corner, Mochi sits this far from the island's corner (its centre)…- static let cornerInset: CGFloat = 56- /// …and the other pills' Mochis sit on a quarter circle of this radius around him.- static let arcRadius: CGFloat = 104+ /// Open in a corner, Mochi sits this far from the island's corner (his centre)…+ static let cornerInset: CGFloat = 50+ /// …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+ /// The other pills' Mochis sit on a quarter circle of this radius around him, far enough+ /// apart for their names and for two of them to cross when they swap.+ static let arcRadius: CGFloat = 150+ /// The room Mochi and his circle take in the corner of the open island (the card has the rest).+ static let cornerColumn: CGFloat = 230/// The home view open in a corner (the Mail card reading a message: `homeReadingSize`).- static let homeSize = CGSize(width: 640, height: 230)- static let homeReadingSize = CGSize(width: 640, height: 290)+ static let homeSize = CGSize(width: 640, height: 260)+ static let homeReadingSize = CGSize(width: 640, height: 320)/// The placement the views read without reaching AppState (set by AppState.islandPlacement).nonisolated(unsafe) static var current: IslandPlacement = .notch@@ -40,7 +46,8 @@ enum IslandPlacement: String, CaseIterable, Sendable {/// in its corner.func cornerBotCenter(in size: CGSize) -> CGPoint {let i = Self.cornerInset- return CGPoint(x: isRight ? size.width - i : i, y: isBottom ? size.height - i : i)+ return CGPoint(x: isRight ? size.width - i : i,+ y: (isBottom ? size.height - i : i) - Self.lift)}/// The other pills' Mochis around him (y down): `count` points on the quarter circle that@@ -56,7 +63,7 @@ enum IslandPlacement: String, CaseIterable, Sendable {case .bottomLeft: (0, -90)case .notch: (0, 0)}- let pad = 10.0+ let pad = 4.0let a0 = from + (to > from ? pad : -pad), a1 = to - (to > from ? pad : -pad)return (0..<count).map { i inlet t = count == 1 ? 0.5 : Double(i) / Double(count - 1)diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swiftindex db55ac9d..d5c61df9 100644--- a/NotchBuddy/Sources/App/IslandRootView.swift+++ b/NotchBuddy/Sources/App/IslandRootView.swift@@ -118,6 +118,9 @@ struct IslandContainer: View {.offset(y: earOffset).clipShape(IslandShape(width: islandWidth, height: islandHeight,cornerRadius: cornerRadius, topRadius: islandTopRadius))+ // In a corner, held by it while the island grows (no slide).+ .frame(maxWidth: .infinity, maxHeight: .infinity,+ alignment: state.islandPlacement.isCorner ? state.islandPlacement.alignment : .topLeading).transition(.opacity)}}@@ -126,12 +129,31 @@ struct IslandContainer: View {if state.mode == .expanded && state.view == .overview && state.islandPlacement.isCorner&& !uploadActive && !greetingActive {CornerArcView(state: state, islandW: islandWidth, islandH: islandHeight)+ // Held by the island's corner while it grows.+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: state.islandPlacement.alignment).transition(.opacity)}// Single BotPlacement — always alive in the view tree so spring animations// fire from the current position (e.g. choose at 60,101) when canvas deactivates.// Hidden during upload canvas or greeting (both draw their own Mochi).+ if state.islandPlacement.isCorner {+ // Held by the island's corner, which stays put while the island grows from it:+ // Mochi only moves between his own places (the tile's middle, the open corner).+ let p = state.islandPlacement+ let box: CGFloat = 300+ BotPlacement(state: state, islandW: islandWidth, islandH: islandHeight,+ shift: CGSize(width: p.isRight ? islandWidth - box : 0,+ height: p.isBottom ? islandHeight - box : 0))+ .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)+ } else {BotPlacement(state: state, islandW: islandWidth, islandH: islandHeight)// Keep idle animations inside the resting strip. Expanded views// retain the panel's full height for particles and hands.@@ -141,6 +163,7 @@ struct IslandContainer: View {}.opacity(uploadActive || greetingActive ? 0 : 1).animation(.easeInOut(duration: 0.25), value: uploadActive || greetingActive)+ }CountdownBar(state: state, islandW: islandWidth)@@ -178,7 +201,7 @@ struct IslandContainer: View {let (w, h) = islandSize(mode: newMode, view: state.view,progress: state.uploadProgress,nw: state.notchWidth, nh: state.notchHeight)- let cr = newMode == .expanded ? IslandConst.expandedCorner : IslandConst.roundedCorner+ let cr = islandCorner(newMode)// In a corner the island floats: its top corners are rounded too.let tr: CGFloat = state.islandPlacement.isCorner ? cr : 0withAnimation(anim) {@@ -213,7 +236,7 @@ struct IslandContainer: View {nw: state.notchWidth, nh: state.notchHeight)islandWidth = wislandHeight = state.view == .prompt ? chatPromptHeight : h- cornerRadius = state.mode == .expanded ? IslandConst.expandedCorner : IslandConst.roundedCorner+ cornerRadius = islandCorner(state.mode)islandTopRadius = state.islandPlacement.isCorner ? cornerRadius : 0}.onReceive(NotificationCenter.default.publisher(for: .islandResize)) { _ in@@ -236,11 +259,18 @@ struct IslandContainer: View {nw: state.notchWidth, nh: state.notchHeight)islandWidth = wislandHeight = (state.mode == .expanded && state.view == .prompt) ? chatPromptHeight : h- // The notch ↔ a corner: flat or rounded top.+ // The notch ↔ a corner: flat or rounded top, a round tile at rest.+ cornerRadius = islandCorner(state.mode)islandTopRadius = state.islandPlacement.isCorner ? cornerRadius : 0}}+ /// 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+ }+private func modeOrder(_ m: IslandMode) -> Int {switch m { case .hidden: return 0; case .compact: return 1; case .expanded: return 2 }}@@ -332,9 +362,15 @@ struct BotPlacement: View {@ObservedObject var state: AppStatelet islandW: CGFloatlet islandH: CGFloat+ /// 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 = .zerovar body: some View {- let (cx, cy, diameter, opacity) = botPosition(mode: state.mode, view: state.view, islandW: islandW, islandH: islandH, uploadProgress: state.uploadProgress, hasNotch: state.hasNotch)+ let (rawCx, rawCy, diameter, rawOpacity) = botPosition(mode: state.mode, view: state.view, islandW: islandW, islandH: islandH, uploadProgress: state.uploadProgress, hasNotch: state.hasNotch)+ let cx = rawCx - shift.width, cy = rawCy - shift.height+ // Swapping places in a corner: CornerArcView draws him on his way.+ let opacity = state.cornerSwapping ? 0 : rawOpacitylet canvasSize = diameter / 0.6let overhang: CGFloat = 40let isUploading = state.view == .uploading@@ -429,7 +465,7 @@ 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, min(38, max(0, islandH - 22)), 1)+ return (islandW / 2, islandH / 2 - 2, min(38, max(0, islandH - 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))@@ -553,7 +589,7 @@ struct IslandContentView: View {let placement = state.islandPlacement// Home open in a top corner: Mochi and his circle take the corner, the header the rest.let cornerHome = placement.isCorner && state.view == .overview- let headerGap: CGFloat = cornerHome && !placement.isBottom ? 180 : 0+ let headerGap: CGFloat = cornerHome ? IslandPlacement.cornerColumn : 0VStack(spacing: 0) {IslandHeader(state: state).frame(height: 34)diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swiftindex 6c0e715c..2f25cdb6 100644--- a/NotchBuddy/Sources/App/IslandViewContent.swift+++ b/NotchBuddy/Sources/App/IslandViewContent.swift@@ -202,7 +202,7 @@ struct OverviewView: View {let placement = state.islandPlacementlet shift: CGFloat = 96return GeometryReader { geo in- let cardW = max(200, geo.size.width - 180)+ let cardW = max(200, geo.size.width - IslandPlacement.cornerColumn)leftCard.frame(width: cardW + shift, height: geo.size.height).offset(x: -shift)diff --git a/tests/IslandPlacementTests.swift b/tests/IslandPlacementTests.swiftindex 4c8c3f4e..c638dc67 100644--- a/tests/IslandPlacementTests.swift+++ b/tests/IslandPlacementTests.swift@@ -40,20 +40,25 @@ 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: 584, y: 56))- precondition(IslandPlacement.bottomLeft.cornerBotCenter(in: home) == CGPoint(x: 56, y: 174))+ precondition(IslandPlacement.topRight.cornerBotCenter(in: home) == CGPoint(x: 590, y: 46))+ precondition(IslandPlacement.bottomLeft.cornerBotCenter(in: home) == CGPoint(x: 50, y: 206))for p in IslandPlacement.allCases where p.isCorner {let c = p.cornerBotCenter(in: home)let pts = p.arcPoints(count: 4, 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(q.x > 18 && q.x < home.width - 18 && q.y > 18 && q.y < home.height - 18, "\(p) \(q) inside the island")+ // 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")// Towards the inside: away from the corner's two edges.precondition(p.isRight ? q.x <= c.x + 0.01 : q.x >= c.x - 0.01, "\(p) \(q)")precondition(p.isBottom ? q.y <= c.y + 0.01 : q.y >= c.y - 0.01, "\(p) \(q)")}}+ // Four on the circle: room between two for a line of text and their crossing.+ 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)let t = IslandPlacement.bottomRight.dropTarget(screen: screen, visible: visible, panelSize: panel)precondition(t == CGRect(x: 1442, y: 80, width: 60, height: 60), "\(t)")