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(metrics): tick last_db_write_ts on dedup-skip — kill vision-stall false alarms

Louis Beaumontb035b8ebce08
diff --git a/TESTING.md b/TESTING.md
index 36477c819..d45219572 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -200,6 +200,7 @@ commits: `6dd5d98e`, `831ad258`
- [ ] **Accessibility automation properties** — Verify automation properties (labels, roles, automation IDs) are correctly captured in the accessibility tree across Windows, macOS, and Linux. (`1b7d0db5b`)
- [ ] **Apple Vision per-word OCR fast path** — Browse an app with lots of text (e.g., Wikipedia article with 500+ words). Verify OCR database inserts are fast (bulk VALUES insert, not 500 individual RETURNING queries). Check logs for no "Slow DB batch insert" warnings. Regression: `6f3f80dd3` (Apple per-word records now use level="0" for bulk-insert fast path, not level="5" which hit expensive per-row insert).
- [ ] **DB write coalesce queue** — Under heavy load (e.g. many pipes + high FPS), verify no "database is locked" errors and no vision stalls due to write contention. (`39c016cb3`, `d119d060d`, `231521192`)
+- [ ] **static-screen does not trigger vision-stall WARN** — Sit on a Zoom call / slide deck / IDE waiting screen for >2 minutes (no UI activity). Verify the engine does NOT log `health_check: no unique vision frame in Ns` warnings, and the Tauri app's `consecutive_vision_stall` counter stays at 0 (no `vision capture recovered after N stale checks` info line). Dedup-skipped captures must tick `last_db_write_ts` so the health check distinguishes "static screen, dedup working" from "pipeline stuck". Pre-fix: 8–14 false alarms/day with single stretches up to 28 minutes. (`a08ec9140`, +follow-up commit)
- [ ] **Windows idle CPU reduction** — Verify low CPU usage on Windows when screen is idle, using event-driven hooks and caching. (`d2c9d1fb8`)
- [ ] **reduced CPU spikes in vision/capture pipeline** — Actively browse and use applications, verifying that CPU spikes in the vision/capture pipeline are significantly reduced. (`8f7294e6`)
- [ ] **OCR bounding boxes normalized on Windows/Linux** — On Windows and Linux, verify that OCR bounding boxes are correctly normalized to the 0-1 range, ensuring consistent text overlay and interaction. (`aba74513`)
diff --git a/crates/screenpipe-engine/src/event_driven_capture.rs b/crates/screenpipe-engine/src/event_driven_capture.rs
index b240724ec..2406bab19 100644
--- a/crates/screenpipe-engine/src/event_driven_capture.rs
+++ b/crates/screenpipe-engine/src/event_driven_capture.rs
@@ -341,6 +341,12 @@ pub async fn event_driven_capture_loop(
"startup capture for monitor {}: frame_id={}, dur={}ms",
monitor_id, result.frame_id, result.duration_ms
);
+ } else {
+ // Symmetry with the live loop — startup capture rarely
+ // hits dedup (no prior hash on first frame) but if it
+ // does, treat it the same way: pipeline cycled fine,
+ // nothing new to write.
+ vision_metrics.record_dedup_skip();
}
}
Err(e) => {
@@ -743,7 +749,17 @@ pub async fn event_driven_capture_loop(
monitor_id
);
} else {
- // Content dedup or window filter — capture skipped
+ // Content dedup or window filter — capture skipped.
+ // Tick last_db_write_ts anyway so the health check
+ // doesn't flag a stall just because the screen is
+ // static. The pipeline IS healthy; there's just
+ // nothing new worth writing. Without this, sitting
+ // on a Zoom call / slide deck / IDE waiting for
+ // 60+ seconds emits a false-alarm "vision DB
+ // writes stalled" WARN and (if the user has
+ // showRestartNotifications enabled) a Tauri
+ // notification claiming screen capture is broken.
+ vision_metrics.record_dedup_skip();
debug!(
"capture skipped DB write for monitor {} (trigger={})",
monitor_id,
diff --git a/crates/screenpipe-screen/src/metrics.rs b/crates/screenpipe-screen/src/metrics.rs
index f40f8fe5c..af2b91b10 100644
--- a/crates/screenpipe-screen/src/metrics.rs
+++ b/crates/screenpipe-screen/src/metrics.rs
@@ -162,6 +162,26 @@ impl PipelineMetrics {
self.frames_video_written.fetch_add(1, Ordering::Relaxed);
}
+ /// Record that the capture pipeline cycled successfully but content
+ /// dedup decided no DB write was needed (frame hash matched the
+ /// previous one — typical for a static screen, video call, slide
+ /// deck). Advances `last_db_write_ts` so the health-check stall
+ /// detector treats "nothing new to write" as healthy. Does NOT bump
+ /// the `frames_db_written` counter or record latency — those still
+ /// reflect actual writes.
+ ///
+ /// Without this, a static screen for >60s causes the health check
+ /// to log "vision DB writes stalled" even though the pipeline is
+ /// running fine; on Louis's machine that produced 8–14 false
+ /// alarms/day with single stretches of up to 28 minutes.
+ pub fn record_dedup_skip(&self) {
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs();
+ self.last_db_write_ts.store(now, Ordering::Relaxed);
+ }
+
/// Record a frame inserted into DB.
pub fn record_db_write(&self, latency: std::time::Duration) {
let count = self.frames_db_written.fetch_add(1, Ordering::Relaxed);