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.

feat/smooth-animations: display-rate Mochi + desktop dt fix

Louis Raille661829d68ccb
diff --git a/NotchBuddy/Sources/App/BotCanvasView.swift b/NotchBuddy/Sources/App/BotCanvasView.swift
index 054b489a..e719878b 100644
--- a/NotchBuddy/Sources/App/BotCanvasView.swift
+++ b/NotchBuddy/Sources/App/BotCanvasView.swift
@@ -16,11 +16,9 @@ struct BotCanvasView: View {
@StateObject private var engine = BotEngine()
var body: some View {
- // 60 fps, open or resting (30 looked choppy): every frame on a 60 Hz screen, one
- // in two on ProMotion. The engine still moves one 0.05 step per display frame
- // (MochiFrameClock), so the motion is the same at any drawing rate.
- TimelineView(.animation(minimumInterval: MochiFrameClock.interval(fps: 60),
- paused: state.mode == .hidden || paused)) { timeline in
+ // Display refresh rate — every frame on a 60 Hz screen, every frame on ProMotion.
+ // MochiFrameClock.advance accumulates the step debt so Mochi's speed never changes.
+ TimelineView(.animation(paused: state.mode == .hidden || paused)) { timeline in
// The Canvas must capture the frame's date: a closure that doesn't change from
// one tick to the next is not redrawn, and Mochi froze.
let frame = timeline.date
@@ -240,9 +238,8 @@ struct MiniBotCanvasView: View {
var body: some View {
- // A 12–20 pt Mochi: 30 fps looks the same as the display rate and costs a quarter
- // on ProMotion. Paused in island views that are not shown.
- TimelineView(.animation(minimumInterval: MochiFrameClock.interval(fps: 30), paused: !viewActive)) { timeline in
+ // Display refresh rate. Paused in island views that are not shown.
+ TimelineView(.animation(paused: !viewActive)) { timeline in
let frame = timeline.date // see BotCanvasView: redraw on every tick
Canvas { context, size in
_ = frame
diff --git a/NotchBuddy/Sources/App/DesktopMochi.swift b/NotchBuddy/Sources/App/DesktopMochi.swift
index f9e66fc4..71cbe8f9 100644
--- a/NotchBuddy/Sources/App/DesktopMochi.swift
+++ b/NotchBuddy/Sources/App/DesktopMochi.swift
@@ -27,13 +27,9 @@ struct DesktopBotView: View {
@ObservedObject var viewState: DesktopBotViewState
var body: some View {
- TimelineView(.animation(
- minimumInterval: viewState.isSleeping ? 0.9 / 10.0 : 0.9 / 30.0, // 10 % short: see MochiFrameClock.interval
- paused: viewState.paused
- )) { timeline in
+ TimelineView(.animation(paused: viewState.paused)) { timeline in
Canvas { ctx, size in
- let now = timeline.date.timeIntervalSinceReferenceDate
- let dt = min(0.05, now - engine.lastTime)
+ _ = timeline.date // force redraw every tick (see BotCanvasView)
// Eye tracking based on the panel's own screen position
engine.lookX = tanh((appState.mousePosition.x - viewState.lookOrigin.x) / 260)
@@ -56,7 +52,7 @@ struct DesktopBotView: View {
#endif
}()
engine.setDancing(dancing)
- engine.update(dt: dt)
+ MochiFrameClock.advance(engine)
var c = ctx
engine.applyDance(&c, size: size)
diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swift
index b5049600..83153473 100644
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@ -3858,8 +3858,8 @@ struct TickerShimmerText: View {
@Environment(\.islandViewActive) private var viewActive
var body: some View {
- // A 2.2 s sweep: 60 fps is as smooth as the display rate, and it stops when hidden.
- TimelineView(.animation(minimumInterval: 0.9 / 60.0, paused: paused || !viewActive)) { tl in
+ // A 2.2 s sweep at display refresh rate. Paused when hidden.
+ TimelineView(.animation(paused: paused || !viewActive)) { tl in
let t = tl.date.timeIntervalSinceReferenceDate
let p = CGFloat(t.truncatingRemainder(dividingBy: 2.2) / 2.2)
// phase sweeps -0.1 → 1.1 so white peak enters from left and exits right