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.

perf: review fixes — App Store build guard, 20 Hz middle band for hover, shimmer fade, mini Mochi rate from the island screen, VAD retune hysteresis, deaf rebuild after 6 windows with music

Clauded6399ab3914b
diff --git a/NotchBuddy/Sources/App/BotCanvasView.swift b/NotchBuddy/Sources/App/BotCanvasView.swift
index 5e862989..cbdc81ef 100644
--- a/NotchBuddy/Sources/App/BotCanvasView.swift
+++ b/NotchBuddy/Sources/App/BotCanvasView.swift
@@ -231,9 +231,17 @@ struct MiniBotCanvasView: View {
@Environment(\.islandViewActive) private var viewActive
- /// The rate the mini Mochis used to be drawn at (the built-in display's).
- private static let displayFPS: Double =
- Double(min(120, max(60, NSScreen.screens.first?.maximumFramesPerSecond ?? 60)))
+ /// The rate the mini Mochis used to be drawn at: the island screen's refresh rate,
+ /// looked up at most every 2 s (the island can move to another display).
+ @MainActor private static var fpsCache: (value: Double, at: CFTimeInterval) = (60, -10)
+ @MainActor private static var displayFPS: Double {
+ let now = CACurrentMediaTime()
+ if now - fpsCache.at > 2 {
+ let fps = IslandWindowController.islandScreen().maximumFramesPerSecond
+ fpsCache = (Double(min(120, max(30, fps))), now)
+ }
+ return fpsCache.value
+ }
var body: some View {
// A 12–20 pt Mochi: 30 fps looks the same as the display rate and costs a quarter
diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swift
index 1235b498..ccf7f32a 100644
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@ -3675,7 +3675,8 @@ struct TickerView: View {
Color.clear
// Row A: completed row — always rendered at phase=1 + completedScale
- TickerRowView(text: rowA, phase: 1.0, isActive: isActive, onDiffTap: rowADiffTap)
+ // Row A never shows its shimmer (phase 1): it doesn't animate one either.
+ TickerRowView(text: rowA, phase: 1.0, isActive: isActive, shimmerPaused: true, onDiffTap: rowADiffTap)
.scaleEffect(completedScale, anchor: .leading)
.offset(x: -10, y: rowAOffset)
.opacity(rowAOpacity)
@@ -3766,6 +3767,7 @@ struct TickerRowView: View {
let text: String
let phase: Double // 0 = current (shimmer, large), 1 = completed (dim, scaled down by caller)
var isActive: Bool = true
+ var shimmerPaused: Bool = false
var onDiffTap: (() -> Void)? = nil
var body: some View {
@@ -3791,7 +3793,7 @@ struct TickerRowView: View {
// Filename + counts
HStack(spacing: 0) {
ZStack(alignment: .leading) {
- TickerShimmerText(text: dp.filename, paused: !isActive || phase >= 1)
+ TickerShimmerText(text: dp.filename, paused: shimmerPaused || !isActive)
.opacity(shimmerOpacity)
Text(dp.filename)
.font(.system(size: 13, weight: .medium))
@@ -3834,8 +3836,8 @@ struct TickerRowView: View {
// Text: shimmer fades out, dim completed text fades in (overlapping cross-fade)
ZStack(alignment: .leading) {
- // A completed row (phase 1) or an idle task never shows the shimmer.
- TickerShimmerText(text: text, paused: !isActive || phase >= 1)
+ // An idle task never shows the shimmer (nor row A, see shimmerPaused).
+ TickerShimmerText(text: text, paused: shimmerPaused || !isActive)
.opacity(shimmerOpacity)
Text(text)
.font(.system(size: 13, weight: .medium))
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index 96730fe0..5a0e288b 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -378,6 +378,7 @@ final class IslandWindowController: NSWindowController {
// is elsewhere, so a hidden island costs next to nothing (CLAUDE.md: 0 % CPU when hidden).
private static let fastPoll: TimeInterval = 1.0 / 60.0
+ private static let nearPoll: TimeInterval = 1.0 / 20.0
private static let idlePoll: TimeInterval = 1.0 / 8.0
private var pollInterval: TimeInterval = 0
@@ -394,21 +395,23 @@ final class IslandWindowController: NSWindowController {
MainActor.assumeIsolated { self?.pollFrame() }
}
// A few ms of slack lets macOS group our wakeups with others; hover is unaffected.
- timer.tolerance = interval == Self.idlePoll ? 0.04 : 0.004
+ timer.tolerance = interval == Self.idlePoll ? 0.04 : interval == Self.nearPoll ? 0.01 : 0.004
RunLoop.main.add(timer, forMode: .common)
frameTimer = timer
}
/// Picks the polling rate for the next ticks (see startPolling).
- /// "Near" is measured from the island itself, not from the big transparent panel
- /// (720×560): with the panel, most of the top of the screen counted as near and a
- /// hidden island polled at 60 Hz nearly all the time. Desktop Mochi has its own poll.
+ /// Three rates for a hidden island: 60 Hz close to the island itself, 20 Hz in the
+ /// wide band around the panel (a pointer flicked up still reaches the close zone
+ /// within one tick), 8 Hz elsewhere. Before, the whole band ran at 60 Hz, so a hidden
+ /// island polled at 60 Hz most of the time. Desktop Mochi has its own poll.
private func adjustPollRate(mouse: NSPoint, panelFrame: NSRect, islandRect: NSRect) {
let island = islandRect.offsetBy(dx: panelFrame.minX, dy: panelFrame.minY)
let nearIsland = island.insetBy(dx: -200, dy: -160).contains(mouse)
+ let inBand = panelFrame.insetBy(dx: -120, dy: -120).contains(mouse)
let busy = state.mode != .hidden || inAttachDrag || attachDragStart != nil
|| fsm.state != .hidden || nearIsland
- let wanted = busy ? Self.fastPoll : Self.idlePoll
+ let wanted = busy ? Self.fastPoll : inBand ? Self.nearPoll : Self.idlePoll
if wanted != pollInterval { startPolling(interval: wanted) }
}
diff --git a/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift b/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift
index eb174cce..13ca3429 100644
--- a/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift
+++ b/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift
@@ -186,8 +186,10 @@ final class CloudProbe {
lastPushAt = Date()
// A request from the iPhone (a service to read, an action) may be waiting.
Task { await ServiceDetailRunner.shared.checkNow() }
+ #if !APPSTORE
// An instruction from the iPhone may be waiting too: no need to wait for the poll.
Task { await InstructionRunner.shared.checkNow() }
+ #endif
guard pingTask != nil else { return } // the Pong fetch is only for the ping test
log("push received")
Task { await fetchChanges(source: "push") }
diff --git a/NotchBuddy/Sources/App/Voice/VoiceAudio.swift b/NotchBuddy/Sources/App/Voice/VoiceAudio.swift
index 909e244e..4777215a 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceAudio.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceAudio.swift
@@ -138,7 +138,9 @@ final class VoiceAudio: @unchecked Sendable {
lastBufferTime = Date()
// Tune durations to the real buffer length (often 100 ms on macOS, not 1024 frames).
- if buf.frameLength > 0, buf.frameLength != tunedFrameLength {
+ // Retuned only when the length moves by more than 5 % (some devices jitter a frame).
+ if buf.frameLength > 0,
+ abs(Double(buf.frameLength) - Double(tunedFrameLength)) > Double(tunedFrameLength) * 0.05 {
tunedFrameLength = buf.frameLength
let fps = buf.format.sampleRate / Double(buf.frameLength)
vad.setFrameRate(fps)
diff --git a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
index 9df24a32..4a11aeb7 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
@@ -468,13 +468,13 @@ final class VoiceEngine: ObservableObject {
// A short noise (cough, click) legitimately gives no text: only count windows
// where speech went on for a while.
guard elapsed >= 3 else { return }
- // Music without words gives no text either: not a stuck recognizer. Rebuilding
- // for it cost a restart and half a second of deafness each time.
- if AppState.shared.musicPlaying || SpotifyController.shared.isPlaying { return }
+ // Music without words gives no text either: while music plays it takes 6 silent
+ // windows, not 2, before a rebuild (each costs a restart and ~0.5 s of deafness).
+ let music = AppState.shared.musicPlaying || SpotifyController.shared.isPlaying
deafWindows += 1
- if deafWindows >= 2 {
+ if deafWindows >= (music ? 6 : 2) {
deafWindows = 0
- appendAppLog("nb.log", "[Voice] recognizer returned nothing for 2 windows, rebuilding")
+ appendAppLog("nb.log", "[Voice] recognizer returned nothing for \(music ? 6 : 2) windows, rebuilding")
triggerPipelineRebuild(reason: "recognizer deaf")
}
}