Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(audio): align config-layer AVX2 rules with the runtime gate; review fixes

Ezra Ellette550d3ba3a260
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/health.rs b/apps/screenpipe-app-tauri/src-tauri/src/health.rs
index ddf3e1ec3..92d6fe003 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/health.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/health.rs
@@ -1407,6 +1407,13 @@ mod tests {
#[test]
fn cpu_compat_mode_round_trips_through_snapshot() {
+ // Serialize with every other test that mutates the process-wide
+ // BOOT_PHASE singleton (see the boot-readiness section for the
+ // convention) — an unguarded set_boot_phase here would race the
+ // wait_for_boot_ready tests and flap them.
+ let _guard = BOOT_PHASE_TEST_LOCK
+ .lock()
+ .unwrap_or_else(|e| e.into_inner());
// Default off.
assert!(!get_boot_phase_snapshot().cpu_compat_mode);
set_cpu_compat_mode(true);
@@ -1416,6 +1423,8 @@ mod tests {
assert!(get_boot_phase_snapshot().cpu_compat_mode);
set_cpu_compat_mode(false);
assert!(!get_boot_phase_snapshot().cpu_compat_mode);
+ // Reset so other tests see a known-pending baseline.
+ set_boot_phase("idle", None);
}
fn make_healthy_response() -> Result<HealthCheckResponse> {
diff --git a/crates/screenpipe-audio/src/transcription/engine.rs b/crates/screenpipe-audio/src/transcription/engine.rs
index eba8a1dc6..06122de15 100644
--- a/crates/screenpipe-audio/src/transcription/engine.rs
+++ b/crates/screenpipe-audio/src/transcription/engine.rs
@@ -160,11 +160,22 @@ impl TranscriptionEngine {
// model-not-downloaded path; the onboarding compat notice and the
// engine-safety check in screenpipe-config explain the limitation.
if !screenpipe_core::cpu_features::has_avx2() && config.requires_avx2() {
- warn!(
+ // Warn once per process: the audio manager re-runs engine
+ // creation on every device/model refresh tick, and repeating the
+ // same warning forever buries real errors in the logs.
+ static AVX2_GATE_WARNED: std::sync::Once = std::sync::Once::new();
+ let mut first_time = false;
+ AVX2_GATE_WARNED.call_once(|| first_time = true);
+ let msg = format!(
"transcription engine {:?} requires AVX2 but this CPU has none ({}); disabling local STT — parakeet/cloud engines remain available",
*config,
screenpipe_core::cpu_features::snapshot().as_log_string()
);
+ if first_time {
+ warn!("{msg}");
+ } else {
+ tracing::debug!("{msg}");
+ }
return Ok(Self::Disabled);
}
diff --git a/crates/screenpipe-config/src/defaults.rs b/crates/screenpipe-config/src/defaults.rs
index 848379bbd..b9c44f366 100644
--- a/crates/screenpipe-config/src/defaults.rs
+++ b/crates/screenpipe-config/src/defaults.rs
@@ -275,11 +275,22 @@ pub fn best_engine_for_platform(tier: DeviceTier) -> &'static str {
/// CPU-explicit core of [`best_engine_for_platform`], testable without the
/// host CPU's actual feature set.
pub fn best_engine_for_platform_for_cpu(tier: DeviceTier, has_avx2: bool) -> &'static str {
- // ggml/whisper is compiled with AVX2 on Windows/Linux x64; on CPUs without
- // AVX2 (pre-2013 Intel, Atom-line Celeron/Pentium) whisper would die with
- // an illegal instruction. Parakeet runs on ONNX Runtime, which does
- // runtime CPU dispatch — safe everywhere, but too heavy for Low tier.
- if cfg!(all(target_arch = "x86_64", not(target_os = "macos"))) && !has_avx2 {
+ // ggml/whisper is compiled with AVX2 on x86-64 release builds; on CPUs
+ // without AVX2 (pre-2013 Intel, Atom-line Celeron/Pentium) whisper would
+ // die with an illegal instruction, and the runtime gate in
+ // screenpipe-audio disables it on EVERY x86-64 target — this picker must
+ // stay consistent with that gate or settings show an engine that
+ // silently never runs.
+ if cfg!(target_arch = "x86_64") && !has_avx2 {
+ // macOS: the only local alternative is parakeet, which auto-upgrades
+ // to MLX and needs macOS 26 — a non-AVX2 Intel Mac (Mac Pro 2013 is
+ // the only such supported model) can't run it either. Disable local
+ // STT outright; cloud engines remain selectable.
+ if cfg!(target_os = "macos") {
+ return "disabled";
+ }
+ // Windows/Linux: parakeet runs on ONNX Runtime, which does runtime
+ // CPU dispatch — safe everywhere, but too heavy for Low tier.
return if tier == DeviceTier::Low {
"disabled"
} else {
@@ -330,7 +341,10 @@ pub fn is_engine_unsafe(engine: &str, tier: DeviceTier) -> bool {
/// CPU's actual feature set.
pub fn is_engine_unsafe_for_cpu(engine: &str, tier: DeviceTier, has_avx2: bool) -> bool {
// AVX2-compiled static kernels: whisper* (ggml) and qwen3* (antirez C).
- let non_avx2_x86 = cfg!(all(target_arch = "x86_64", not(target_os = "macos"))) && !has_avx2;
+ // Applies on every x86-64 target (macOS included) — mirrors the runtime
+ // gate in screenpipe-audio's TranscriptionEngine::new exactly, so the
+ // store migration moves users off an engine that could never load.
+ let non_avx2_x86 = cfg!(target_arch = "x86_64") && !has_avx2;
if non_avx2_x86 && (engine.starts_with("whisper") || engine.starts_with("qwen3")) {
return true;
}
@@ -345,10 +359,11 @@ pub fn is_engine_unsafe_for_cpu(engine: &str, tier: DeviceTier, has_avx2: bool)
}
if tier == DeviceTier::Mid {
// Parakeet (~2GB) is normally too heavy for Mid, but on a non-AVX2
- // x86-64 CPU plain parakeet is the only local engine that can run
+ // x86-64 CPU (off-macOS: on macOS parakeet needs MLX/macOS 26
+ // regardless) plain parakeet is the only local engine that can run
// (whisper/qwen3 are AVX2-compiled) and Mid (≥12GB) holds it — it is
// also exactly what best_engine_for_platform_for_cpu picks there.
- return !(non_avx2_x86 && engine == "parakeet");
+ return !(non_avx2_x86 && cfg!(not(target_os = "macos")) && engine == "parakeet");
}
// High tier from here.