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: Mochi alone in a tile, the pills on a quarter circle, a magnetic drop
Claude220ae8b99529
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex 91a59a10..95c20b67 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -359,7 +359,10 @@ final class AppState: ObservableObject {/// Where the island lives on its screen: the notch, or a corner (IslandPlacement) — persisted.@Published var islandPlacement: IslandPlacement = .notch {- didSet { UserDefaults.standard.set(islandPlacement.rawValue, forKey: "islandPlacement") }+ didSet {+ IslandPlacement.current = islandPlacement+ UserDefaults.standard.set(islandPlacement.rawValue, forKey: "islandPlacement")+ }}// Screen hosting the island (notch screen by default) — persisted@@ -588,7 +591,10 @@ final class AppState: ObservableObject {if let v = ud.object(forKey: "hotkeyFlags") as? Int { hotkeyFlags = UInt(v) }if let v = ud.object(forKey: "hotkeyCode") as? Int { hotkeyCode = UInt16(v) }if let v = ud.string(forKey: "islandDisplay") { islandDisplay = IslandDisplayChoice(storageValue: v) }- if let v = ud.string(forKey: "islandPlacement"), let p = IslandPlacement(rawValue: v) { islandPlacement = p }+ if let v = ud.string(forKey: "islandPlacement"), let p = IslandPlacement(rawValue: v) {+ islandPlacement = p+ IslandPlacement.current = p // didSet doesn't run from init+ }if let d = ud.data(forKey: "vercelProjectFilter"),let a = try? JSONDecoder().decode([String].self, from: d) { vercelProjectFilter = Set(a) }if let d = ud.data(forKey: "n8nWorkflowFilter"),diff --git a/NotchBuddy/Sources/App/CornerIsland.swift b/NotchBuddy/Sources/App/CornerIsland.swiftnew file mode 100644index 00000000..5b431776--- /dev/null+++ b/NotchBuddy/Sources/App/CornerIsland.swift@@ -0,0 +1,144 @@+import SwiftUI++// The island open in a corner of the screen (IslandPlacement): Mochi sits in the island's+// corner, the other pills' Mochis on a quarter circle around him, and the focused pill's card+// fills the rest. A tap on one of them swaps it with Mochi: it flies to the corner and becomes+// the one in focus, and the one that was in focus takes its place on the circle.++struct CornerArcView: View {+ @ObservedObject var state: AppState+ let islandW: CGFloat+ let islandH: CGFloat++ /// 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++ /// Room for five around Mochi; the others are a tap on the circle away once one leaves it.+ static let maxShown = 5++ private var arcTasks: [AgentTask] {+ let focus = state.focusTask?.id+ let others = state.tasks.filter { $0.id != focus }+ let known = order.compactMap { id in others.first { $0.id == id } }+ let rest = others.filter { t in !order.contains(t.id) }+ return Array((known + rest).prefix(Self.maxShown))+ }++ var body: some View {+ let placement = state.islandPlacement+ let size = CGSize(width: islandW, height: islandH)+ let tasks = arcTasks+ let points = placement.arcPoints(count: tasks.count, in: size)+ let home = placement.cornerBotCenter(in: size)++ ZStack(alignment: .topLeading) {+ // A faint quarter of the circle the Mochis sit on.+ Path { p in+ let pts = placement.arcPoints(count: 9, in: size)+ guard let first = pts.first else { return }+ p.move(to: first)+ for q in pts.dropFirst() { p.addLine(to: q) }+ }+ .stroke(Color.white.opacity(0.06), style: StrokeStyle(lineWidth: 1, lineCap: .round, dash: [2, 5]))+ .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))+ }+ }+ .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)+ }++ private func swap(to task: AgentTask, at index: Int, current: [AgentTask]) {+ guard flying == nil else { return }+ var ids = current.map(\.id)+ if let focus = state.focusTask?.id, index < ids.count { ids[index] = focus }+ flying = task.id+ SoundEngine.shared.play("blip")+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {+ order = ids+ state.setFocus(task.id)+ flying = nil+ }+ }+}++/// One pill's Mochi on the circle: a round button in its colour, its name on hover.+private struct CornerMini: 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 {+ 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)+ MiniBotCanvasView(task: task)+ .frame(width: 24 / 0.6, height: 24 / 0.6)+ .frame(width: 24, height: 24)+ }+ .frame(width: 40, height: 40)+ .shadow(color: Color(hex: task.color).opacity(hover ? 0.35 : 0), radius: 10)++ if let badge = task.pillBadge {+ PillBadgeView(badge: badge, taskColor: task.color)+ .offset(x: 2, y: -2)+ }+ }+ .overlay(alignment: .bottom) {+ Text(verbatim: name)+ .font(.system(size: 9.5, weight: .semibold))+ .foregroundColor(Color(hex: task.color).lighter(by: 0.3))+ .lineLimit(1)+ .fixedSize()+ .padding(.horizontal, 6).padding(.vertical, 2)+ .background(Capsule().fill(Color.black.opacity(0.85)))+ .offset(y: 18)+ .opacity(hover ? 1 : 0)+ .allowsHitTesting(false)+ }+ }+ .buttonStyle(.plain)+ .scaleEffect(hover ? 1.1 : 1)+ .onHover { h in withAnimation(.spring(response: 0.2, dampingFraction: 0.7)) { hover = h } }+ .help(name)+ }+}++/// While Mochi is dragged near a corner (or back to the top centre): the place he will take,+/// shown before he is let go.+struct SnapTargetView: View {+ let corner: Bool+ @State private var shown = false++ var body: some View {+ RoundedRectangle(cornerRadius: corner ? 18 : 17, style: .continuous)+ .fill(Color.black.opacity(0.55))+ .overlay(+ RoundedRectangle(cornerRadius: corner ? 18 : 17, style: .continuous)+ .strokeBorder(Color.white.opacity(0.55), style: StrokeStyle(lineWidth: 1.5, dash: [5, 4]))+ )+ .scaleEffect(shown ? 1 : 0.7)+ .opacity(shown ? 1 : 0)+ .onAppear { withAnimation(.spring(response: 0.3, dampingFraction: 0.7)) { shown = true } }+ }+}diff --git a/NotchBuddy/Sources/App/IslandPlacement.swift b/NotchBuddy/Sources/App/IslandPlacement.swiftindex c1855c58..437fac18 100644--- a/NotchBuddy/Sources/App/IslandPlacement.swift+++ b/NotchBuddy/Sources/App/IslandPlacement.swift@@ -23,6 +23,58 @@ 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).+ 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+ /// 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)++ /// 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 {+ let i = Self.cornerInset+ return CGPoint(x: isRight ? size.width - i : i, y: isBottom ? size.height - i : i)+ }++ /// 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+ // Angles (degrees, y down): the quarter facing away from the corner.+ let (from, to): (Double, Double) = switch self {+ case .topRight: (180, 90)+ case .topLeft: (0, 90)+ case .bottomRight: (180, 270)+ case .bottomLeft: (0, -90)+ case .notch: (0, 0)+ }+ let pad = 10.0+ let a0 = from + (to > from ? pad : -pad), a1 = to - (to > from ? pad : -pad)+ return (0..<count).map { i in+ let t = count == 1 ? 0.5 : Double(i) / Double(count - 1)+ let a = (a0 + (a1 - a0) * t) * .pi / 180+ return CGPoint(x: c.x + r * CGFloat(cos(a)), y: c.y + r * CGFloat(sin(a)))+ }+ }++ /// The tile a drop at this placement shows (screen coordinates, y up): the corner's resting+ /// island, or a notch-sized bar at the top centre.+ func dropTarget(screen: CGRect, visible: CGRect, panelSize: CGSize) -> CGRect {+ guard isCorner else {+ return CGRect(x: screen.midX - 100, y: screen.maxY - 34, width: 200, height: 34)+ }+ let o = panelOrigin(screen: screen, visible: visible, panelSize: panelSize)+ return islandRect(panelSize: panelSize, size: CGSize(width: Self.tile, height: Self.tile))+ .offsetBy(dx: o.x, dy: o.y)+ }/// The panel's origin on the screen. `screen` is the screen's frame, `visible` its visible/// frame (without the menu bar and the Dock).diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swiftindex 032c42eb..db55ac9d 100644--- a/NotchBuddy/Sources/App/IslandRootView.swift+++ b/NotchBuddy/Sources/App/IslandRootView.swift@@ -122,6 +122,13 @@ struct IslandContainer: View {}}+ // 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 {+ CornerArcView(state: state, islandW: islandWidth, islandH: islandHeight)+ .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).@@ -154,7 +161,8 @@ struct IslandContainer: View {}Group {- if state.mode == .compact {+ // In a corner the tile holds Mochi alone: no room for the mini Mochis.+ if state.mode == .compact && !state.islandPlacement.isCorner {CompactMiniGrid(state: state).scaleEffect(IslandRestingLayout(width: islandWidth, height: islandHeight).miniGridScale).position(x: islandWidth - 40, y: islandHeight / 2)@@ -416,6 +424,19 @@ struct BotPlacement: View {func botPosition(mode: IslandMode, view: IslandView, islandW: CGFloat, islandH: CGFloat, uploadProgress: Double, hasNotch: Bool = true) -> (CGFloat, CGFloat, CGFloat, Double) {let resting = IslandRestingLayout(width: islandW, height: islandH)+ let placement = IslandPlacement.current+ if placement.isCorner {+ 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)+ 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))+ return (c.x, c.y, 58, 1)+ default: break+ }+ }switch mode {case .hidden:return hasNotch ? (46, 16, 6, 0)@@ -529,9 +550,15 @@ struct IslandContentView: View {@State private var mailExtra: CGFloat = 0var body: some 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 : 0VStack(spacing: 0) {IslandHeader(state: state).frame(height: 34)+ .padding(.leading, placement.isLeft ? headerGap : 0)+ .padding(.trailing, placement.isRight ? headerGap : 0).opacity(state.view == .confused ? 0 : 1).animation(.easeInOut(duration: 0.2), value: state.view == .confused)@@ -542,6 +569,7 @@ struct IslandContentView: View {// chat (prompt) is always flexible; mail is flexible only when active so// it doesn't push the ZStack taller when inactive.let isTall = v == .prompt || ((v == .mail || v == .whatsNew) && active)+ || (v == .overview && active && cornerHome)let anim: Animation = active? .spring(response: 0.4, dampingFraction: 0.8).delay(0.16): .easeIn(duration: 0.16)@@ -550,7 +578,7 @@ struct IslandContentView: View {// but stop their endless animations: nobody sees them..environment(\.islandViewActive, active).frame(maxWidth: .infinity)- .frame(height: isTall ? nil : (v == .overview ? 98 + mailExtra : 98),+ .frame(height: isTall ? nil : (v == .overview ? 98 + (placement.isCorner ? 0 : mailExtra) : 98),alignment: v == .overview ? .top : .center).frame(minHeight: (isTall && !active) ? 0 : nil, maxHeight: isTall ? .infinity : nil).opacity(active ? 1 : 0)diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swiftindex 5bef94a1..6c0e715c 100644--- a/NotchBuddy/Sources/App/IslandViewContent.swift+++ b/NotchBuddy/Sources/App/IslandViewContent.swift@@ -70,139 +70,169 @@ struct OverviewView: View {var agent: AgentTask? { state.focusTask }- var body: some View {- // Top-aligned: a mail open in the Mail card makes the left card taller, downwards- // only; the pills on the right keep their place and their height (98 pt).- HStack(alignment: .top, spacing: 10) {- // Left card: title row + ticker below + ↗ button overlay- ZStack(alignment: .topLeading) {- CardBackground(wash: nil)+ /// The focused pill's card (the left card at the notch).+ @ViewBuilder private var leftCard: some View {+ ZStack(alignment: .topLeading) {+ CardBackground(wash: nil)- // Title row + ticker stacked (or integration card)- if let agent = agent {- if agent.isIntegration {- IntegrationCardView(task: agent, showingDetail: $showingN8nDetail, onDiffTap: { diffIdx in- withAnimation(.easeIn(duration: 0.16)) { activeDiffId = diffIdx }- })- } else {- VStack(alignment: .leading, spacing: 0) {- HStack(spacing: 6) {- Circle()- .fill(Color(hex: agent.color))- .frame(width: 7, height: 7)- Text(agent.name)- .font(.system(size: 12, weight: .semibold))- .foregroundColor(Color(hex: "#F5F6F8"))- .lineLimit(1)- .truncationMode(.tail)- .layoutPriority(1)- Text({ () -> String in- switch agent.source {- case .claudeCode: return "Claude Code"- case .agent: return "Agent"- case .n8n: return "n8n"- }- }())- .font(.system(size: 11))- .foregroundColor(Color(hex: "#8E939C"))- .lineLimit(1)- .truncationMode(.tail)- Spacer(minLength: 2)- if agent.steps.count > 1 && agent.sessionLines.isEmpty {- Text("\(min(agent.stepIndex + 1, agent.steps.count))/\(agent.steps.count)")- .font(.system(size: 11))- .foregroundColor(Color(hex: "#6B7079"))- .fixedSize()+ // Title row + ticker stacked (or integration card)+ if let agent = agent {+ if agent.isIntegration {+ IntegrationCardView(task: agent, showingDetail: $showingN8nDetail, onDiffTap: { diffIdx in+ withAnimation(.easeIn(duration: 0.16)) { activeDiffId = diffIdx }+ })+ } else {+ VStack(alignment: .leading, spacing: 0) {+ HStack(spacing: 6) {+ Circle()+ .fill(Color(hex: agent.color))+ .frame(width: 7, height: 7)+ Text(agent.name)+ .font(.system(size: 12, weight: .semibold))+ .foregroundColor(Color(hex: "#F5F6F8"))+ .lineLimit(1)+ .truncationMode(.tail)+ .layoutPriority(1)+ Text({ () -> String in+ switch agent.source {+ case .claudeCode: return "Claude Code"+ case .agent: return "Agent"+ case .n8n: return "n8n"}+ }())+ .font(.system(size: 11))+ .foregroundColor(Color(hex: "#8E939C"))+ .lineLimit(1)+ .truncationMode(.tail)+ Spacer(minLength: 2)+ if agent.steps.count > 1 && agent.sessionLines.isEmpty {+ Text("\(min(agent.stepIndex + 1, agent.steps.count))/\(agent.steps.count)")+ .font(.system(size: 11))+ .foregroundColor(Color(hex: "#6B7079"))+ .fixedSize()}- .padding(.top, 6)- .padding(.leading, 108)- .padding(.trailing, 36)-- // Several sessions share the pill: one line each, instead of the steps.- Group {- if agent.sessionLines.isEmpty {- TickerView(task: agent, onDiffTap: { diffIdx in- withAnimation(.easeIn(duration: 0.16)) { activeDiffId = diffIdx }- })- } else {- SessionLinesView(lines: agent.sessionLines)- }+ }+ .padding(.top, 6)+ .padding(.leading, 108)+ .padding(.trailing, 36)++ // Several sessions share the pill: one line each, instead of the steps.+ Group {+ if agent.sessionLines.isEmpty {+ TickerView(task: agent, onDiffTap: { diffIdx in+ withAnimation(.easeIn(duration: 0.16)) { activeDiffId = diffIdx }+ })+ } else {+ SessionLinesView(lines: agent.sessionLines)}- .frame(height: 44)- .padding(.top, 6)- .padding(.leading, 108)- .padding(.trailing, 12)}- .frame(maxWidth: .infinity, alignment: .topLeading)- .padding(.top, 4)+ .frame(height: 44)+ .padding(.top, 6)+ .padding(.leading, 108)+ .padding(.trailing, 12)}+ .frame(maxWidth: .infinity, alignment: .topLeading)+ .padding(.top, 4)}+ }- // Plan detail overlays on top of normal content (GitHub build, home view only)- #if !APPSTORE- if state.showingPlanDetail {- CardBackground(wash: nil)- Group {- if state.planDetailIsCodex {- CodexPlanCardView(usage: state.codexPlanUsage)- } else {- // Claude and Codex both on: the header shows only the Claude pill,- // Codex is a third row here that opens its own card.- let bothPlans = state.showPlanInNotch && state.planRelayInstalled- && state.showCodexPlanInNotch- ClaudePlanCardView(usage: state.claudePlanUsage,- codexRow: bothPlans,- codexUsage: state.codexPlanUsage,- onCodex: {- withAnimation(.spring(response: 0.28, dampingFraction: 0.82)) {- state.planDetailIsCodex = true- }- state.refreshCodexPlanUsage()- })- }+ // Plan detail overlays on top of normal content (GitHub build, home view only)+ #if !APPSTORE+ if state.showingPlanDetail {+ CardBackground(wash: nil)+ Group {+ if state.planDetailIsCodex {+ CodexPlanCardView(usage: state.codexPlanUsage)+ } else {+ // Claude and Codex both on: the header shows only the Claude pill,+ // Codex is a third row here that opens its own card.+ let bothPlans = state.showPlanInNotch && state.planRelayInstalled+ && state.showCodexPlanInNotch+ ClaudePlanCardView(usage: state.claudePlanUsage,+ codexRow: bothPlans,+ codexUsage: state.codexPlanUsage,+ onCodex: {+ withAnimation(.spring(response: 0.28, dampingFraction: 0.82)) {+ state.planDetailIsCodex = true+ }+ state.refreshCodexPlanUsage()+ })}- .transition(.opacity)}- #endif+ .transition(.opacity)+ }+ #endif- // Diff overlay — replaces ticker when a diff step is tapped- if let diffId = activeDiffId,- let task = agent,- let diff = state.sessionDiffs[task.pill]?.first(where: { $0.id == diffId }) {- CardBackground(wash: nil)- DiffCardView(diff: diff, onDismiss: { activeDiffId = nil })- .transition(.opacity)- }+ // Diff overlay — replaces ticker when a diff step is tapped+ if let diffId = activeDiffId,+ let task = agent,+ let diff = state.sessionDiffs[task.pill]?.first(where: { $0.id == diffId }) {+ CardBackground(wash: nil)+ DiffCardView(diff: diff, onDismiss: { activeDiffId = nil })+ .transition(.opacity)+ }- // ↗ jump button — last in ZStack so it renders on top; hidden while any detail is open- #if !APPSTORE- let hideJumpButton = showingN8nDetail || state.showingPlanDetail || activeDiffId != nil- #else- let hideJumpButton = showingN8nDetail || activeDiffId != nil- #endif- if !hideJumpButton {- Button(action: { openAgentTarget(agent) }) {- Image(systemName: "arrow.up.right")- .font(.system(size: 8, weight: .medium))- .foregroundColor(Color(hex: "#5F646D"))- .frame(width: 16, height: 16)- .background(Color.white.opacity(0.07))- .clipShape(Circle())- }- .buttonStyle(.plain)- .padding(.top, 8)- .padding(.trailing, 10)- .frame(maxWidth: .infinity, alignment: .trailing)+ // ↗ jump button — last in ZStack so it renders on top; hidden while any detail is open+ #if !APPSTORE+ let hideJumpButton = showingN8nDetail || state.showingPlanDetail || activeDiffId != nil+ #else+ let hideJumpButton = showingN8nDetail || activeDiffId != nil+ #endif+ if !hideJumpButton {+ Button(action: { openAgentTarget(agent) }) {+ Image(systemName: "arrow.up.right")+ .font(.system(size: 8, weight: .medium))+ .foregroundColor(Color(hex: "#5F646D"))+ .frame(width: 16, height: 16)+ .background(Color.white.opacity(0.07))+ .clipShape(Circle())}+ .buttonStyle(.plain)+ .padding(.top, 8)+ .padding(.trailing, 10)+ .frame(maxWidth: .infinity, alignment: .trailing)}- .frame(width: 322)+ }+ }++ /// Open in a corner: the card beside Mochi and his circle (CornerArcView, drawn over the+ /// island), full height. The cards keep room on their left for Mochi at the notch; here it+ /// is cut off, so they start at the card's edge.+ private var cornerBody: some View {+ let placement = state.islandPlacement+ let shift: CGFloat = 96+ return GeometryReader { geo in+ let cardW = max(200, geo.size.width - 180)+ leftCard+ .frame(width: cardW + shift, height: geo.size.height)+ .offset(x: -shift)+ .frame(width: cardW, height: geo.size.height, alignment: .leading)+ .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))+ .contentShape(Rectangle())+ .frame(maxWidth: .infinity, maxHeight: .infinity,+ alignment: placement.isLeft ? .trailing : .leading)+ }+ }- // Right card: agent pills- CardBackground(wash: nil) {- AgentPillsView(state: state)+ var body: some View {+ Group {+ if state.islandPlacement.isCorner {+ cornerBody+ } else {+ // Top-aligned: a mail open in the Mail card makes the left card taller, downwards+ // only; the pills on the right keep their place and their height (98 pt).+ HStack(alignment: .top, spacing: 10) {+ // Left card: title row + ticker below + ↗ button overlay+ leftCard+ .frame(width: 322)++ // Right card: agent pills+ CardBackground(wash: nil) {+ AgentPillsView(state: state)+ }+ .frame(height: 98)+ }}- .frame(height: 98)}.onChange(of: state.focusId) { _, new inshowingN8nDetail = falsediff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swiftindex 779895d7..b7a3a50a 100644--- a/NotchBuddy/Sources/App/IslandWindowController.swift+++ b/NotchBuddy/Sources/App/IslandWindowController.swift@@ -58,6 +58,9 @@ final class IslandWindowController: NSWindowController {private var dragGhostSize: CGFloat = 0private var ghostCurrentOrigin: NSPoint = .zeroprivate var highlightPanel: NSPanel? = nil+ /// While Mochi is dragged near a corner (or the top centre): the place he will take.+ private var snapPanel: NSPanel? = nil+ private var snapShown: IslandPlacement? = nilprivate var highlightWindowPid: pid_t = 0// Notch real dimensions (set on init)@@ -1145,6 +1148,7 @@ final class IslandWindowController: NSWindowController {private func hideDragGhost() {dragGhostPanel?.close()dragGhostPanel = nil+ showSnapTarget(nil)highlightPanel?.close()highlightPanel = nilhighlightWindowPid = 0@@ -1155,14 +1159,72 @@ final class IslandWindowController: NSWindowController {guard let panel = dragGhostPanel else { return }let s = dragGhostSizelet mouse = NSEvent.mouseLocation+ #if !APPSTORE+ // Near a corner (or the top centre): the place shows, and Mochi is pulled into it.+ if let snap = snapTarget(at: mouse) {+ let rect = snap.1+ showSnapTarget(snap.0, rect: rect)+ let c = NSPoint(x: rect.midX - s/2, y: rect.midY - s/2)+ let k: CGFloat = 0.35+ ghostCurrentOrigin = NSPoint(x: ghostCurrentOrigin.x + (c.x - ghostCurrentOrigin.x) * k,+ y: ghostCurrentOrigin.y + (c.y - ghostCurrentOrigin.y) * k)+ panel.setFrameOrigin(ghostCurrentOrigin)+ return+ }+ showSnapTarget(nil)+ #endif// Direct follow — bot is "held", no trailing lagghostCurrentOrigin = NSPoint(x: mouse.x - s/2, y: mouse.y - s/2)panel.setFrameOrigin(ghostCurrentOrigin)}+ /// 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)? {+ guard let here = NSScreen.screens.first(where: { $0.frame.contains(mouse) }),+ here == Self.islandScreen(),+ let target = IslandPlacement.snap(mouse, screen: here.frame),+ target != state.islandPlacement else { return nil }+ return (target, target.dropTarget(screen: here.frame, visible: here.visibleFrame,+ panelSize: Self.panelFrame.size))+ }++ private func showSnapTarget(_ target: IslandPlacement?, rect: CGRect = .zero) {+ guard let target else {+ snapPanel?.close()+ snapPanel = nil+ snapShown = nil+ return+ }+ if snapShown == target, snapPanel != nil { return }+ snapPanel?.close()+ let p = NSPanel(contentRect: rect, styleMask: [.borderless, .nonactivatingPanel],+ backing: .buffered, defer: false)+ p.backgroundColor = .clear+ p.isOpaque = false+ p.hasShadow = false+ p.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.mainMenuWindow)) + 3)+ p.collectionBehavior = [.canJoinAllSpaces, .stationary, .ignoresCycle, .fullScreenAuxiliary]+ p.ignoresMouseEvents = true+ let host = NSHostingView(rootView: SnapTargetView(corner: target.isCorner))+ host.frame = NSRect(origin: .zero, size: rect.size)+ p.contentView = host+ p.orderFront(nil)+ snapPanel = p+ snapShown = target+ SoundEngine.shared.play("tick")+ }+// MARK: - Window highlight overlay (white border on target window during drag)private func updateWindowHighlight() {+ // Over a corner's place: no window to attach to.+ if snapShown != nil {+ highlightPanel?.close()+ highlightPanel = nil+ highlightWindowPid = 0+ return+ }let mouse = NSEvent.mouseLocation// Listing every window is costly: skip while the pointer stays put (a window// moving under a still pointer is caught within a quarter second).@@ -1426,8 +1488,8 @@ final class IslandWindowController: NSWindowController {let f = islandScreen().framereturn NSPoint(x: f.midX - s / 2, y: f.maxY - s)}- let r = islandScreenRect(size: CGSize(width: app.notchWidth, height: app.notchHeight))- return NSPoint(x: r.minX + 40 - s / 2, y: r.midY - s / 2)+ let r = islandScreenRect(size: CGSize(width: IslandPlacement.tile, height: IslandPlacement.tile))+ return NSPoint(x: r.midX - s / 2, y: r.midY - s / 2)}/// The resting island for `screen`: the notch's size at the notch, or the small bar of a@@ -2120,10 +2182,16 @@ func islandSize(mode: IslandMode, view: IslandView,progress: Double = 0,nw: CGFloat = IslandConst.notchWidth,nh: CGFloat = IslandConst.notchHeight) -> (CGFloat, CGFloat) {+ let corner = IslandPlacement.current.isCornerswitch mode {- case .hidden: return (nw, nh)- case .compact: return (nw + 160, nh)+ // In a corner, resting or compact: a square tile with Mochi alone.+ case .hidden: return corner ? (IslandPlacement.tile, IslandPlacement.tile) : (nw, nh)+ case .compact: return corner ? (IslandPlacement.tile, IslandPlacement.tile) : (nw + 160, nh)case .expanded:+ if corner && view == .overview {+ let s = MailLayout.detailHeight != nil ? IslandPlacement.homeReadingSize : IslandPlacement.homeSize+ return (s.width, s.height)+ }let layout = IslandConst.viewLayouts[view]!if view == .question, let h = QuestionLayout.height {return (IslandConst.expandedWidth, h)diff --git a/tests/IslandPlacementTests.swift b/tests/IslandPlacementTests.swiftindex e57b03fc..4c8c3f4e 100644--- a/tests/IslandPlacementTests.swift+++ b/tests/IslandPlacementTests.swift@@ -37,6 +37,26 @@ enum IslandPlacementTests {precondition(IslandPlacement.snap(CGPoint(x: 760, y: 500), screen: screen) == nil)precondition(IslandPlacement.snap(CGPoint(x: 400, y: 960), screen: screen) == nil, "top, but not near the notch nor a corner")precondition(IslandPlacement(rawValue: "bottomRight") == .bottomRight)++ // 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))+ 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")+ // 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)")+ }+ }+ 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)")print("IslandPlacement tests: all passed")}}