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
Mochi panics under load, sheds his outfit for Focus, nicer headphones
Claudebc4b75287f03
diff --git a/NotchBuddy/Sources/App/BotCanvasView.swift b/NotchBuddy/Sources/App/BotCanvasView.swiftindex 0cc9a59f..60821465 100644--- a/NotchBuddy/Sources/App/BotCanvasView.swift+++ b/NotchBuddy/Sources/App/BotCanvasView.swift@@ -30,7 +30,8 @@ struct BotCanvasView: View {engine.particleOverhang = particleOverhang// How the Mac feels, and the Focus headphones (MochiMood.swift).engine.moodTarget = MachineVitals.shared.mood- engine.headphonesTarget = FocusSession.shared.phase == .focus ? 1 : 0+ engine.headphonesTarget = FocusSession.shared.phase == .focus+ && !(state.mode == .expanded && state.view == .wardrobe) ? 1 : 0// Widen slot when file is hovering over the mailbox (morph > 0.5)// Open mouth (hover=0.20R) when file dragged over box; close when notif engine.morph > 0.3 {@@ -78,7 +79,9 @@ struct BotCanvasView: View {engine.setDancing(dancing)let isWardrobe = state.mode == .expanded && state.view == .wardrobelet isFocusMain = state.focusId == state.mainPillId || state.focusId == nil- let showOutfit = isFocusMain || state.mode != .expanded || isWardrobe+ // A Focus session: headphones only, the outfit comes off (the wardrobe still shows it).+ let showOutfit = (isFocusMain || state.mode != .expanded || isWardrobe)+ && (FocusSession.shared.phase != .focus || isWardrobe)engine.setOutfit(showOutfit ? state.resolvedOutfit : .none,animated: state.view != .wardrobe)@@ -189,7 +192,8 @@ struct BotCanvasView: View {engine.setState(state.effectiveState, force: true)let isWardrobe = state.mode == .expanded && state.view == .wardrobelet isFocusMain = state.focusId == state.mainPillId || state.focusId == nil- let showOutfit = isFocusMain || state.mode != .expanded || isWardrobe+ let showOutfit = (isFocusMain || state.mode != .expanded || isWardrobe)+ && (FocusSession.shared.phase != .focus || isWardrobe)engine.setOutfit(showOutfit ? state.resolvedOutfit : .none, animated: false)}}diff --git a/NotchBuddy/Sources/App/DesktopMochi.swift b/NotchBuddy/Sources/App/DesktopMochi.swiftindex e795dcbc..60f29680 100644--- a/NotchBuddy/Sources/App/DesktopMochi.swift+++ b/NotchBuddy/Sources/App/DesktopMochi.swift@@ -40,7 +40,7 @@ struct DesktopBotView: View {engine.headphonesTarget = FocusSession.shared.phase == .focus ? 1 : 0// Desktop Mochi is always the "main" Mochi — always dressed- engine.setOutfit(appState.resolvedOutfit, animated: true)+ engine.setOutfit(FocusSession.shared.wear(appState.resolvedOutfit), animated: true)// Dance when music plays (same rules as compact mode)let dancing: Bool = {@@ -88,7 +88,7 @@ struct DesktopBotView: View {}.onAppear {engine.setState(appState.effectiveState, force: true)- engine.setOutfit(appState.resolvedOutfit, animated: false)+ engine.setOutfit(FocusSession.shared.wear(appState.resolvedOutfit), animated: false)}}}@@ -186,7 +186,7 @@ final class DesktopMochiController {// Build engine + hosting view (autoresizingMask lets it grow with the panel animation)let eng = BotEngine()eng.setState(AppState.shared.effectiveState, force: true)- eng.setOutfit(AppState.shared.resolvedOutfit, animated: false)+ eng.setOutfit(FocusSession.shared.wear(AppState.shared.resolvedOutfit), animated: false)self.engine = englet vs = DesktopBotViewState()@@ -270,7 +270,7 @@ final class DesktopMochiController {let eng = BotEngine()eng.setState(AppState.shared.effectiveState, force: true)- eng.setOutfit(AppState.shared.resolvedOutfit, animated: false)+ eng.setOutfit(FocusSession.shared.wear(AppState.shared.resolvedOutfit), animated: false)self.engine = englet vs = DesktopBotViewState()diff --git a/NotchBuddy/Sources/App/FocusSession.swift b/NotchBuddy/Sources/App/FocusSession.swiftindex a08beed9..029d7759 100644--- a/NotchBuddy/Sources/App/FocusSession.swift+++ b/NotchBuddy/Sources/App/FocusSession.swift@@ -56,6 +56,9 @@ final class FocusSession: ObservableObject {/// Coucou keeps quiet: no sounds, the island no longer opens by itself.var isQuiet: Bool { phase == .focus }+ /// What Mochi wears: nothing but his headphones during a session.+ func wear(_ outfit: Outfit) -> Outfit { phase == .focus ? .none : outfit }+// MARK: - Starting and stoppingfunc start(minutes requested: Int? = nil) {diff --git a/NotchBuddy/Sources/CoucouKit/BotEngine.swift b/NotchBuddy/Sources/CoucouKit/BotEngine.swiftindex a69e36ce..296b05af 100644--- a/NotchBuddy/Sources/CoucouKit/BotEngine.swift+++ b/NotchBuddy/Sources/CoucouKit/BotEngine.swift@@ -283,7 +283,11 @@ final class BotEngine: ObservableObject {var moodHot: CGFloat = 0var moodFull: CGFloat = 0var moodTired: CGFloat = 0- var nextMoodSweat: Double = 0+ var nextMoodDrop: Double = 0+ var moodDrops: [MoodDrop] = []+ var hop = MoodHop()+ var moodShiftApplied: CGFloat = 0+ var moodLiftApplied: CGFloat = 0var nextMoodYawn: Double = 0// Focus headphones: 1 while a Focus session runs.var headphonesTarget: CGFloat = 0@@ -868,6 +872,8 @@ final class BotEngine: ObservableObject {func update(dt: Double) {let now = CACurrentMediaTime()let dtCG = CGFloat(dt)+ // The stressed hop of the last frame comes off first (MochiMood.swift).+ undoMoodOffsets()// Process tweensfor key in tweens.keys {diff --git a/NotchBuddy/Sources/CoucouKit/MochiMood.swift b/NotchBuddy/Sources/CoucouKit/MochiMood.swiftindex 80615391..d5fff20d 100644--- a/NotchBuddy/Sources/CoucouKit/MochiMood.swift+++ b/NotchBuddy/Sources/CoucouKit/MochiMood.swift@@ -18,6 +18,28 @@ struct MochiMood: Equatable, Sendable {static let calm = MochiMood()}+/// A drop of sweat thrown from Mochi's side: it rises, then falls to the floor in an arc.+/// In Mochi's units (R), from his resting centre; the time is real time.+struct MoodDrop {+ var x: CGFloat+ var y: CGFloat+ var vx: CGFloat+ var vy: CGFloat+ var born: Double+ var size: CGFloat+}++/// One of Mochi's stressed hops, from side to side.+struct MoodHop {+ var from: CGFloat = 0+ var to: CGFloat = 0+ var start: Double = 0+ var duration: Double = 0.2+ var height: CGFloat = 0+ var rest: Double = 0+ var landed = true+}+// MARK: - Mochi's moods and the Focus headphonesextension BotEngine {@@ -29,7 +51,16 @@ extension BotEngine {}}- /// Eases the mood levels towards `moodTarget` and plays their small animations.+ /// Gravity of the sweat drops, in R per second².+ private static let dropGravity: CGFloat = 5.5++ /// Takes back last frame's hop offset before anything else moves Mochi.+ func undoMoodOffsets() {+ if moodShiftApplied != 0 { ox -= moodShiftApplied; moodShiftApplied = 0 }+ if moodLiftApplied != 0 { oy -= moodLiftApplied; moodLiftApplied = 0 }+ }++ /// Eases the mood levels towards `moodTarget` and plays their animations./// Called from `update` before the look and the body scale are smoothed.func updateMood(dt: Double, now: Double, t: CGFloat) {guard !isMini else { return }@@ -44,28 +75,35 @@ extension BotEngine {let sleeping = calmState && target.asleepheadphones += (headphonesTarget - headphones) * CGFloat(1 - pow(0.02, dt))- // Busy: quick, short breaths and a drop of sweat every second or so.- if moodBusy > 0.02, !locks.contains("sy"), !locks.contains("sx") {- let pant = sin(t * 7.5) * 0.028 * moodBusy- tgSy += pant- tgSx -= pant * 0.6- }+ updateStress(now: now)+// Full memory: puffed up.if moodFull > 0.02 {tgSx *= 1 + 0.07 * moodFulltgSy *= 1 - 0.035 * moodFull}- if now > nextMoodSweat {- if moodBusy > 0.5 || moodHot > 0.6 {- emit(.sweat, count: 1)- nextMoodSweat = now + (moodBusy > 0.5 ? 0.9 : 1.6) + Double.random(in: 0...0.5)++ // Sweat: drops thrown from his sides, in bursts while the processor is at full load,+ // now and then when the Mac is only warm.+ if now > nextMoodDrop {+ if moodBusy > 0.4 {+ throwDrop(now: now)+ if Double.random(in: 0...1) < 0.35 { throwDrop(now: now) }+ nextMoodDrop = now + Double.random(in: 0.14...0.32)+ } else if moodHot > 0.6 {+ throwDrop(now: now)+ nextMoodDrop = now + Double.random(in: 0.6...1.1)} else {- nextMoodSweat = now + 0.5+ nextMoodDrop = now + 0.3}}+ moodDrops.removeAll { drop in+ let a = CGFloat(now - drop.born)+ return a > 1.6 || drop.y + drop.vy * a + Self.dropGravity * a * a / 2 > 1.05+ }// Low battery: heavy eyes, the odd yawn; nearly empty: asleep with his z's.- let ownEye = eyeOverride == nil || eyeOverride == .tired || eyeOverride == .closed+ let ownEye = eyeOverride == nil || eyeOverride == .tired || eyeOverride == .closed || eyeOverride == .wideif sleeping {if ownEye { eyeOverride = .closed; eyeOverrideUntil = now + 0.4 }tgYaw = 0@@ -81,9 +119,73 @@ extension BotEngine {if nextMoodYawn > 0 { triggerEmote(.yawn, silent: true) }nextMoodYawn = now + 24 + Double.random(in: 0...12)}+ } else if moodBusy > 0.4, ownEye {+ // Stressed: wide eyes.+ eyeOverride = .wide+ eyeOverrideUntil = now + 0.3+ }+ }++ /// The processor at full load: Mochi panics, hopping from side to side at random, quick and+ /// short, leaning into each hop, squashing when he lands, eyes darting where he jumps.+ private func updateStress(now: Double) {+ let level = moodBusy+ guard level > 0.02 || abs(hop.to) > 0.005 || !hop.landed else { return }+ let p = hop.duration > 0 ? min(1, (now - hop.start) / hop.duration) : 1+ if p >= 1 {+ if !hop.landed {+ hop.landed = true+ // The landing squash.+ anim("sy", keys: [TweenKey(target: 0.86, duration: 60, ease: Ease.out),+ TweenKey(target: 1.0, duration: 140, ease: Ease.out)])+ anim("sx", keys: [TweenKey(target: 1.1, duration: 60, ease: Ease.out),+ TweenKey(target: 1.0, duration: 140, ease: Ease.out)])+ }+ if now > hop.start + hop.duration + hop.rest {+ // Next hop: somewhere else on the floor, never twice the same.+ var next: CGFloat = 0+ if level > 0.3 {+ repeat { next = CGFloat.random(in: -0.34...0.34) } while abs(next - hop.to) < 0.14+ }+ hop = MoodHop(from: hop.to, to: next, start: now,+ duration: Double.random(in: 0.15...0.3),+ height: level > 0.3 ? CGFloat.random(in: 0.08...0.22) : 0.05,+ rest: Double.random(in: 0.02...0.38), landed: false)+ }+ }+ let q = CGFloat(min(1, hop.duration > 0 ? (now - hop.start) / hop.duration : 1))+ let eased = q < 0.5 ? 2 * q * q : 1 - pow(-2 * q + 2, 2) / 2+ let x = hop.from + (hop.to - hop.from) * eased+ let lift = sin(.pi * q) * hop.height * (hop.landed ? 0 : 1)+ let dir: CGFloat = hop.to >= hop.from ? 1 : -1+ let amount = min(1, level * 1.4)+ if !locks.contains("ox") {+ moodShiftApplied = x * amount+ ox += moodShiftApplied+ }+ if !locks.contains("oy") {+ moodLiftApplied = -lift * amount+ oy += moodLiftApplied+ }+ if !hop.landed {+ tgTilt += dir * 0.12 * sin(.pi * q) * amount+ tgYaw = dir * 0.7+ tgPitch -= 0.1}}+ private func throwDrop(now: Double) {+ let side: CGFloat = Bool.random() ? 1 : -1+ let drop = MoodDrop(+ x: side * 1.0 + ox, y: -0.3 + oy,+ vx: side * CGFloat.random(in: 0.45...0.75),+ vy: -CGFloat.random(in: 1.4...2.0),+ born: now,+ size: CGFloat.random(in: 0.11...0.15))+ moodDrops.append(drop)+ if moodDrops.count > 24 { moodDrops.removeFirst() }+ }+/// Red cheeks and a flushed body while the Mac is warm (inside the body's transform).func drawMoodTint(ctx: inout GraphicsContext, path: Path, rx: CGFloat, ry: CGFloat) {guard moodHot > 0.01, morph < 0.5, !isMini else { return }@@ -98,10 +200,35 @@ extension BotEngine {))}- /// What goes over Mochi in world space: heat waves, and the Focus headphones.+ /// What goes over Mochi in world space: sweat drops, heat waves, and the Focus headphones.func drawMoodExtras(context: GraphicsContext, R: CGFloat, rx: CGFloat, ry: CGFloat, cx: CGFloat, cy: CGFloat) {guard !isMini, morph < 0.3 else { return }- let now = CGFloat(CACurrentMediaTime() - t0)+ let real = CACurrentMediaTime()+ let now = CGFloat(real - t0)++ // Sweat: each drop follows its arc from where it left Mochi's side.+ if !moodDrops.isEmpty {+ let baseX = cx - ox * R, baseY = cy - oy * R+ for drop in moodDrops {+ let a = CGFloat(real - drop.born)+ guard a >= 0 else { continue }+ let x = drop.x + drop.vx * a+ let y = drop.y + drop.vy * a + Self.dropGravity * a * a / 2+ let vy = drop.vy + Self.dropGravity * a+ var c = context+ c.opacity = Double(min(1, a / 0.06) * min(1, max(0, (1.05 - y) / 0.25)))+ c.translateBy(x: baseX + x * R, y: baseY + y * R)+ c.rotate(by: .radians(atan2(vy, drop.vx) - .pi / 2))+ let s = R * drop.size+ var tear = Path()+ tear.move(to: CGPoint(x: 0, y: -s * 1.15))+ tear.addQuadCurve(to: CGPoint(x: 0, y: s * 0.7), control: CGPoint(x: s * 0.85, y: s * 0.2))+ tear.addQuadCurve(to: CGPoint(x: 0, y: -s * 1.15), control: CGPoint(x: -s * 0.85, y: s * 0.2))+ c.fill(tear, with: .color(Color(red: 0.486, green: 0.78, blue: 1)))+ c.fill(Path(ellipseIn: CGRect(x: -s * 0.32, y: -s * 0.05, width: s * 0.22, height: s * 0.3)),+ with: .color(.white.opacity(0.7)))+ }+ }// Heat waves: three wavy lines rising above the head.if moodHot > 0.5 {@@ -125,30 +252,40 @@ extension BotEngine {}}- // Focus headphones: a band over the head and a cup on each side.+ // Focus headphones: a padded band hugging the head, a cup on each side.guard headphones > 0.01 else { return }var c = contextc.opacity = Double(min(1, headphones * 1.4))c.translateBy(x: cx, y: cy - (1 - headphones) * R * 0.8)if tilt != 0 { c.rotate(by: .radians(tilt)) }c.scaleBy(x: sx, y: sy)- let shift = sin(yaw) * rx * 0.12- let dark = Color(red: 0.16, green: 0.17, blue: 0.21)- let accent = Color(red: 0.655, green: 0.545, blue: 0.98) // #A78BFA+ let shift = sin(yaw) * rx * 0.1+ let dark = Color(red: 0.133, green: 0.145, blue: 0.172) // #22252Cvar band = Path()- band.move(to: CGPoint(x: -rx * 0.97 + shift, y: -ry * 0.12))- band.addQuadCurve(to: CGPoint(x: rx * 0.97 + shift, y: -ry * 0.12),- control: CGPoint(x: shift, y: -ry * 1.95))- c.stroke(band, with: .color(dark), style: StrokeStyle(lineWidth: R * 0.14, lineCap: .round))- c.stroke(band, with: .color(Color.white.opacity(0.18)), style: StrokeStyle(lineWidth: R * 0.04, lineCap: .round))+ band.move(to: CGPoint(x: -rx * 0.97 + shift, y: -ry * 0.18))+ band.addCurve(to: CGPoint(x: rx * 0.97 + shift, y: -ry * 0.18),+ control1: CGPoint(x: -rx * 0.98 + shift, y: -ry * 1.52),+ control2: CGPoint(x: rx * 0.98 + shift, y: -ry * 1.52))+ c.stroke(band, with: .color(dark), style: StrokeStyle(lineWidth: R * 0.15, lineCap: .round))+ c.stroke(band, with: .color(Color(red: 0.227, green: 0.243, blue: 0.282)),+ style: StrokeStyle(lineWidth: R * 0.06, lineCap: .round))for side in [-1.0, 1.0] as [CGFloat] {- let w = R * 0.32, h = R * 0.62- let x = side * rx * 0.99 + shift - w / 2- let rect = CGRect(x: x, y: -ry * 0.12 - h * 0.28, width: w, height: h)- let cup = Path(roundedRect: rect, cornerRadius: w * 0.45)- c.fill(cup, with: .color(dark))- let pad = Path(roundedRect: rect.insetBy(dx: w * 0.22, dy: h * 0.16), cornerRadius: w * 0.3)- c.fill(pad, with: .color(accent.opacity(0.9)))+ let w = R * 0.44, h = R * 0.74+ let ccx = side * rx * 0.97 + shift, ccy = ry * 0.04+ var yoke = Path()+ yoke.move(to: CGPoint(x: side * rx * 0.97 + shift, y: -ry * 0.2))+ yoke.addLine(to: CGPoint(x: ccx, y: ccy - h * 0.3))+ c.stroke(yoke, with: .color(dark), style: StrokeStyle(lineWidth: R * 0.1, lineCap: .round))+ let shell = CGRect(x: ccx - w / 2, y: ccy - h / 2, width: w, height: h)+ c.fill(Path(roundedRect: shell, cornerRadius: w / 2), with: .linearGradient(+ Gradient(colors: [Color(red: 0.227, green: 0.243, blue: 0.278), Color(red: 0.11, green: 0.118, blue: 0.137)]),+ startPoint: CGPoint(x: ccx, y: shell.minY), endPoint: CGPoint(x: ccx, y: shell.maxY)))+ let face = CGRect(x: ccx - w * 0.3, y: ccy - h * 0.33, width: w * 0.6, height: h * 0.66)+ c.fill(Path(roundedRect: face, cornerRadius: w * 0.3), with: .linearGradient(+ Gradient(colors: [Color(red: 0.769, green: 0.71, blue: 0.992), Color(red: 0.545, green: 0.361, blue: 0.965)]),+ startPoint: CGPoint(x: ccx, y: face.minY), endPoint: CGPoint(x: ccx, y: face.maxY)))+ c.fill(Path(roundedRect: CGRect(x: ccx - w * 0.2, y: ccy - h * 0.27, width: w * 0.14, height: h * 0.24),+ cornerRadius: w * 0.07), with: .color(.white.opacity(0.35)))}}}