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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(timeline): load text-heavy days after Parquet migration (#7065)
Ezra Ellette1a4871663018
diff --git a/COVERAGE.md b/COVERAGE.mdindex a955e061e..810612878 100644--- a/COVERAGE.md+++ b/COVERAGE.md@@ -35,16 +35,16 @@ results and `cargo llvm-cov` data on top when judging release confidence.### Core Engine- Mapped suites: 33-- Mapped Rust files: 356-- Active test blocks: 3503+- Mapped Rust files: 357+- Active test blocks: 3504- Ignored/manual test blocks: 144-- Weighted coverage points: 2889.4+- Weighted coverage points: 2890.4| Platform | Suites | Active tests | Ignored tests | Weighted points | Layers | Flows | Critical score || --- | --- | --- | --- | --- | --- | --- | --- |-| windows | 30 | 3360 | 138 | 2824.3 | 21 | 11 | 100% |-| macos | 30 | 3422 | 119 | 2838.3 | 22 | 11 | 100% |-| linux | 26 | 2990 | 111 | 2483.6 | 20 | 11 | 100% |+| windows | 30 | 3361 | 138 | 2825.3 | 21 | 11 | 100% |+| macos | 30 | 3423 | 119 | 2839.3 | 22 | 11 | 100% |+| linux | 26 | 2991 | 111 | 2484.6 | 20 | 11 | 100% |## Refreshdiff --git a/crates/screenpipe-db/src/db/frames.rs b/crates/screenpipe-db/src/db/frames.rsindex 678ed0085..29d614280 100644--- a/crates/screenpipe-db/src/db/frames.rs+++ b/crates/screenpipe-db/src/db/frames.rs@@ -1065,6 +1065,7 @@ impl DatabaseManager {}const DEFAULT_TIMELINE_CHUNK_LIMIT: usize = 10_000;+ const TIMELINE_PREVIEW_CHARS: usize = 200;fn bounded_timeline_limit(limit: usize) -> i64 {limit.clamp(1, Self::DEFAULT_TIMELINE_CHUNK_LIMIT) as i64@@ -1124,8 +1125,8 @@ impl DatabaseManager {f.timestamp,f.offset_index,COALESCE(- SUBSTR(f.full_text, 1, 200),- SUBSTR(f.accessibility_text, 1, 200)+ SUBSTR(f.full_text, 1, {preview_chars}),+ SUBSTR(f.accessibility_text, 1, {preview_chars})) as text,f.app_name as app_name,f.window_name as window_name,@@ -1140,7 +1141,8 @@ impl DatabaseManager {AND COALESCE(vc.file_path, f.snapshot_path, '') NOT LIKE 'cloud://%'ORDER BY f.timestamp {order_sql}, f.offset_index {order_sql}LIMIT ?3- "#+ "#,+ preview_chars = Self::TIMELINE_PREVIEW_CHARS,);// Get audio data with proper time windows for synchronization@@ -1235,7 +1237,7 @@ impl DatabaseManager {let payloads = if self.storage.is_some() {let ids: Vec<i64> = frame_rows.iter().map(|r| r.get("id")).collect();- self.frame_payloads(&ids, crate::storage::Projection::Search)+ self.frame_payload_previews(&ids, Self::TIMELINE_PREVIEW_CHARS).await?} else {Default::default()@@ -1259,7 +1261,7 @@ impl DatabaseManager {});let text: String = if let Some(payload) = payloads.get(&row.get::<i64, _>("id")) {- payload.text().chars().take(200).collect()+ payload.text().to_owned()} else {row.try_get::<String, _>("text").unwrap_or_default()};diff --git a/crates/screenpipe-db/src/storage/reader.rs b/crates/screenpipe-db/src/storage/reader.rsindex 70603015f..9936e30fa 100644--- a/crates/screenpipe-db/src/storage/reader.rs+++ b/crates/screenpipe-db/src/storage/reader.rs@@ -173,6 +173,23 @@ impl DatabaseManager {}}+ /// Read only the text retained by a timeline response. Full payload reads+ /// keep their existing admission limits; previews never accumulate a day's+ /// untruncated text before applying that limit.+ pub(crate) async fn frame_payload_previews(+ &self,+ ids: &[i64],+ chars: usize,+ ) -> Result<BTreeMap<i64, FramePayload>, sqlx::Error> {+ let Some(storage) = &self.storage else {+ return Ok(BTreeMap::new());+ };+ self.consistent_read(|| {+ storage.read_with_preview(&self.pool, ids, Projection::Search, Some(chars))+ })+ .await+ }+pub(crate) async fn hydrate_ocr_rows(&self,rows: &mut [crate::OCRResultRaw],@@ -292,17 +309,38 @@ impl HybridStorage {pool: &SqlitePool,ids: &[i64],projection: Projection,+ ) -> Result<BTreeMap<i64, FramePayload>, sqlx::Error> {+ self.read_with_preview(pool, ids, projection, None).await+ }++ async fn read_with_preview(+ self: &Arc<Self>,+ pool: &SqlitePool,+ ids: &[i64],+ projection: Projection,+ preview_chars: Option<usize>,) -> Result<BTreeMap<i64, FramePayload>, sqlx::Error> {if ids.is_empty() {return Ok(BTreeMap::new());}let token = self.read_token(pool).await?;let mut snapshot = super::snapshot::frame_snapshot(pool).await?;- let columns = projection.sqlite_columns();+ debug_assert!(preview_chars.is_none() || projection == Projection::Search);+ let columns = match preview_chars {+ // Legacy records retained in SQLite can exceed even the response+ // budget. Truncate in SQL so those blobs never enter the response.+ Some(chars) => format!("SUBSTR(COALESCE(f.full_text,f.accessibility_text),1,{chars}) AS full_text,NULL AS accessibility_text,NULL AS accessibility_tree_json,NULL AS text_json"),+ None => projection.sqlite_columns().to_owned(),+ };let ids_json = serde_json::to_string(ids).map_err(storage_error)?;- let size = match projection {- Projection::Search => "CASE WHEN p.state='staged' THEN COALESCE(length(CAST(f.full_text AS BLOB)),0)+COALESCE(length(CAST(f.accessibility_text AS BLOB)),0) ELSE MIN(p.bytes,4*(f.payload_full_text_length+f.payload_accessibility_length)) END",- Projection::Detail | Projection::All => "p.bytes",+ let size = match preview_chars {+ // A Unicode character needs at most four UTF-8 bytes. Admission+ // accounts for retained previews, not the source document sizes.+ Some(chars) => format!("MIN(p.bytes,{})", chars.saturating_mul(4)),+ None => match projection {+ Projection::Search => "CASE WHEN p.state='staged' THEN COALESCE(length(CAST(f.full_text AS BLOB)),0)+COALESCE(length(CAST(f.accessibility_text AS BLOB)),0) ELSE MIN(p.bytes,4*(f.payload_full_text_length+f.payload_accessibility_length)) END",+ Projection::Detail | Projection::All => "p.bytes",+ }.to_owned(),};let preflight=format!("SELECT COALESCE(SUM({size}),0) FROM frames f JOIN frame_payloads p ON p.frame_id=f.id WHERE f.id IN (SELECT value FROM json_each(?))");let total: i64 = sqlx::query_scalar(sqlx::AssertSqlSafe(preflight))@@ -396,12 +434,26 @@ impl HybridStorage {requested.into_iter().map(|(id, generation)| {- let record = records+ let mut record = records.remove(&id).ok_or_else(|| storage_error("Parquet locator missing"))?;if record.generation != generation {return Err(storage_error("Parquet locator generation mismatch"));}+ if let Some(chars) = preview_chars {+ // Decode/check one immutable file at a time, then+ // drop full text before accumulating the next file.+ // Match SQLite SUBSTR's embedded-NUL termination.+ record.full_text = Some(+ record+ .text()+ .chars()+ .take(chars)+ .take_while(|ch| *ch != '\0')+ .collect(),+ );+ record.accessibility_text = None;+ }Ok((id, record))}).collect::<Result<BTreeMap<_, _>, sqlx::Error>>()diff --git a/crates/screenpipe-db/tests/timeline_parquet_test.rs b/crates/screenpipe-db/tests/timeline_parquet_test.rsnew file mode 100644index 000000000..41ca05d56--- /dev/null+++ b/crates/screenpipe-db/tests/timeline_parquet_test.rs@@ -0,0 +1,108 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++use chrono::{DateTime, Duration, Utc};+use screenpipe_db::{+ storage::{migrate, MigrationOptions, Projection},+ DatabaseManager,+};++async fn timeline(db: &DatabaseManager, day: &str) -> Vec<(i64, String, String)> {+ let start: DateTime<Utc> = format!("{day}T00:00:00Z").parse().unwrap();+ db.find_video_chunks(start, start + Duration::days(1))+ .await+ .unwrap_or_else(|error| panic!("timeline for {day}: {error}"))+ .frames+ .into_iter()+ .map(|frame| {+ assert_eq!(frame.ocr_entries.len(), 1);+ let entry = frame.ocr_entries.into_iter().next().unwrap();+ (frame.frame_id, entry.text, entry.video_file_path)+ })+ .collect()+}++#[tokio::test]+async fn migrated_timeline_previews_do_not_load_a_days_full_text() {+ let root = tempfile::tempdir().unwrap();+ let path = root.path().join("db.sqlite");+ let db = DatabaseManager::new(path.to_str().unwrap(), Default::default())+ .await+ .unwrap();+ let text = "東京🙂".repeat(300);+ let oversized = text.repeat(8);+ let mut tx = db.begin_immediate_with_retry().await.unwrap();+ for id in 1..=12 {+ let day = match id {+ 1 => "2026-09-01",+ 12 => "2026-09-10",+ _ => "2026-09-09",+ };+ let (full_text, accessibility) = match id {+ 1 => (Some("light day"), None),+ 2 => (Some("café\0hidden after SQLite text terminator"), None),+ 3..=5 => (Some(text.as_str()), None),+ 6..=9 => (None, Some(text.as_str())),+ 10 => (Some(""), Some(text.as_str())),+ 11 => (None, None),+ _ => (Some(oversized.as_str()), None),+ };+ sqlx::query("INSERT INTO frames(id,timestamp,full_text,accessibility_text,snapshot_path,device_name) VALUES(?,?,?,?,?,'display')")+ .bind(id)+ .bind(format!("{day}T12:00:{id:02}Z"))+ .bind(full_text)+ .bind(accessibility)+ .bind(format!("frame-{id}.jpg"))+ .execute(&mut **tx.conn())+ .await+ .unwrap();+ }+ tx.commit().await.unwrap();+ let days = ["2026-09-01", "2026-09-09", "2026-09-10"];+ let mut before = Vec::new();+ for day in days {+ before.push(timeline(&db, day).await);+ }+ db.close().await;++ // Scale down the production budget to reproduce the same failure cheaply:+ // ordinary rows fit individually, their full text exceeds the response cap,+ // and the timeline's 200-character previews fit comfortably.+ let mut options = MigrationOptions::default();+ options.budget.record_bytes = 4096;+ options.budget.file_bytes = 8192;+ options.budget.response_bytes = 16 * 1024;+ migrate(root.path(), Default::default(), options)+ .await+ .unwrap();++ // Reopen twice to cover the user's persistent failure after restarting.+ for reopen in 0..2 {+ let db = DatabaseManager::new(path.to_str().unwrap(), Default::default())+ .await+ .unwrap();+ db.verify_storage().await.unwrap();+ for ids in [(2..=11).collect::<Vec<_>>(), vec![12]] {+ let error = db+ .frame_payloads(&ids, Projection::Search)+ .await+ .unwrap_err();+ assert!(error+ .to_string()+ .contains("response payload budget exceeded"));+ }+ for (day, expected) in days.into_iter().zip(&before) {+ assert_eq!(timeline(&db, day).await, *expected, "{day}");+ }+ if reopen == 0 {+ db.execute_raw_sql_write("INSERT INTO frames(id,timestamp,full_text,snapshot_path) VALUES(13,'2026-09-17T12:00:00Z','new recording','new.jpg')")+ .await+ .unwrap();+ }+ assert_eq!(+ timeline(&db, "2026-09-17").await,+ vec![(13, "new recording".into(), "new.jpg".into())]+ );+ db.close().await;+ }+}diff --git a/docs/coverage/CORE.md b/docs/coverage/CORE.mdindex 95689beb0..54d3eddf8 100644--- a/docs/coverage/CORE.md+++ b/docs/coverage/CORE.md@@ -8,11 +8,11 @@ confidence, and criticality.- Manifest: `docs/coverage/core-engine-map.json`- Tracked crates: screenpipe-engine, screenpipe-db, screenpipe-sqlite-coordinator, screenpipe-audio, screenpipe-screen, screenpipe-a11y- Mapped suites: 33-- Mapped Rust files: 356-- Active test blocks: 3503+- Mapped Rust files: 357+- Active test blocks: 3504- Ignored/manual test blocks: 144-- Declared test blocks: 3647-- Weighted coverage points: 2889.4+- Declared test blocks: 3648+- Weighted coverage points: 2890.4Confidence weights: strong=1.0, partial=0.7, conditional=0.4, smoke=0.3.Criticality weights: high=1.0, medium=0.7, low=0.4.@@ -23,16 +23,16 @@ are explicitly enabled in a runtime lane.| Platform | Suites | Active tests | Ignored tests | Weighted points | Layers | Flows | Critical score || --- | --- | --- | --- | --- | --- | --- | --- |-| windows | 30 | 3360 | 138 | 2824.3 | 21 | 11 | 100% |-| macos | 30 | 3422 | 119 | 2838.3 | 22 | 11 | 100% |-| linux | 26 | 2990 | 111 | 2483.6 | 20 | 11 | 100% |+| windows | 30 | 3361 | 138 | 2825.3 | 21 | 11 | 100% |+| macos | 30 | 3423 | 119 | 2839.3 | 22 | 11 | 100% |+| linux | 26 | 2991 | 111 | 2484.6 | 20 | 11 | 100% |## Crate Summary| Crate | Suites | Integration files | Source unit files | Active tests | Ignored tests | Weighted points | Flows || --- | --- | --- | --- | --- | --- | --- | --- || screenpipe-engine | 11 | 20 | 119 | 1720 | 42 | 1325.1 | 10 |-| screenpipe-db | 5 | 56 | 23 | 534 | 21 | 507.3 | 9 |+| screenpipe-db | 5 | 57 | 23 | 535 | 21 | 508.3 | 9 || screenpipe-sqlite-coordinator | 1 | 0 | 3 | 27 | 0 | 27.0 | 2 || screenpipe-audio | 6 | 25 | 51 | 611 | 44 | 536.5 | 5 || screenpipe-screen | 6 | 9 | 18 | 257 | 9 | 232.1 | 4 |@@ -65,21 +65,21 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su| audio | 7 suites / 724 active / 45 ignored / 649.5 pts | 7 suites / 724 active / 45 ignored / 649.5 pts | 6 suites / 649 active / 44 ignored / 597.0 pts || audio-device | 2 suites / 218 active / 7 ignored / 195.5 pts | 2 suites / 218 active / 7 ignored / 195.5 pts | 1 suites / 143 active / 6 ignored / 143.0 pts || configuration | 2 suites / 143 active / 3 ignored / 129.2 pts | 2 suites / 143 active / 3 ignored / 129.2 pts | 2 suites / 143 active / 3 ignored / 129.2 pts |-| database | 6 suites / 482 active / 17 ignored / 455.3 pts | 6 suites / 482 active / 17 ignored / 455.3 pts | 6 suites / 482 active / 17 ignored / 455.3 pts |+| database | 6 suites / 483 active / 17 ignored / 456.3 pts | 6 suites / 483 active / 17 ignored / 456.3 pts | 6 suites / 483 active / 17 ignored / 456.3 pts || db-search | 2 suites / 113 active / 9 ignored / 113.0 pts | 2 suites / 113 active / 9 ignored / 113.0 pts | 2 suites / 113 active / 9 ignored / 113.0 pts || engine-lifecycle | 6 suites / 244 active / 1 ignored / 219.0 pts | 6 suites / 244 active / 1 ignored / 219.0 pts | 5 suites / 238 active / 1 ignored / 217.3 pts || local-api | 3 suites / 429 active / 9 ignored / 302.7 pts | 3 suites / 429 active / 9 ignored / 302.7 pts | 3 suites / 429 active / 9 ignored / 302.7 pts || meeting | 6 suites / 1618 active / 20 ignored / 1319.8 pts | 6 suites / 1618 active / 20 ignored / 1319.8 pts | 4 suites / 1281 active / 16 ignored / 1005.3 pts || ocr | 4 suites / 125 active / 7 ignored / 119.0 pts | 4 suites / 129 active / 7 ignored / 124.5 pts | 3 suites / 120 active / 6 ignored / 115.5 pts || os-integration | 1 suites / 6 active / 0 ignored / 1.7 pts | 1 suites / 6 active / 0 ignored / 1.7 pts | - |-| performance | 13 suites / 1536 active / 72 ignored / 1356.5 pts | 14 suites / 1643 active / 76 ignored / 1399.3 pts | 13 suites / 1536 active / 72 ignored / 1356.5 pts |+| performance | 13 suites / 1537 active / 72 ignored / 1357.5 pts | 14 suites / 1644 active / 76 ignored / 1400.3 pts | 13 suites / 1537 active / 72 ignored / 1357.5 pts || pipes | 1 suites / 511 active / 3 ignored / 357.7 pts | 1 suites / 511 active / 3 ignored / 357.7 pts | 1 suites / 511 active / 3 ignored / 357.7 pts || privacy | 5 suites / 942 active / 36 ignored / 763.8 pts | 5 suites / 1000 active / 17 ignored / 772.3 pts | 5 suites / 920 active / 14 ignored / 742.7 pts || real-app | - | 1 suites / 107 active / 4 ignored / 42.8 pts | - || speaker | 2 suites / 362 active / 9 ignored / 362.0 pts | 2 suites / 362 active / 9 ignored / 362.0 pts | 2 suites / 362 active / 9 ignored / 362.0 pts |-| storage | 4 suites / 599 active / 34 ignored / 493.1 pts | 4 suites / 599 active / 34 ignored / 493.1 pts | 4 suites / 599 active / 34 ignored / 493.1 pts |+| storage | 4 suites / 600 active / 34 ignored / 494.1 pts | 4 suites / 600 active / 34 ignored / 494.1 pts | 4 suites / 600 active / 34 ignored / 494.1 pts || sync | 1 suites / 511 active / 3 ignored / 357.7 pts | 1 suites / 511 active / 3 ignored / 357.7 pts | 1 suites / 511 active / 3 ignored / 357.7 pts |-| timeline | 4 suites / 1146 active / 38 ignored / 933.3 pts | 4 suites / 1146 active / 38 ignored / 933.3 pts | 4 suites / 1146 active / 38 ignored / 933.3 pts |+| timeline | 4 suites / 1147 active / 38 ignored / 934.3 pts | 4 suites / 1147 active / 38 ignored / 934.3 pts | 4 suites / 1147 active / 38 ignored / 934.3 pts || transcription | 5 suites / 801 active / 41 ignored / 626.6 pts | 5 suites / 801 active / 41 ignored / 626.6 pts | 5 suites / 801 active / 41 ignored / 626.6 pts || ui-events | 4 suites / 758 active / 28 ignored / 576.2 pts | 3 suites / 709 active / 5 ignored / 541.9 pts | 3 suites / 709 active / 5 ignored / 541.9 pts || vision-capture | 5 suites / 549 active / 32 ignored / 433.8 pts | 5 suites / 553 active / 32 ignored / 439.3 pts | 4 suites / 544 active / 31 ignored / 430.3 pts |@@ -132,7 +132,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su| db-audio-meetings-speakers | screenpipe-db | windows, macos, linux | database, audio, meeting, speaker | audio-record-transcribe, audio-device-health, meeting-live-notes | high | strong | integration | 15 | 113 | 1 | Audio transcript dedupe, live meeting mirroring, end-generation and open-meeting invariants, liveness, and speaker reassignment coverage. || db-runtime-reliability | screenpipe-db | windows, macos, linux | database, performance | performance-liveness | high | partial | mixed | 15 | 43 | 6 | SQLite hard-fault classification, failpoint VFS injection, fresh-identity recovery verification with integrity/FK/write canaries, query cancellation, close-severs-connections regressions, multi-pool WAL parity, runtime version pinning, and WAL chaos plus memory-pressure probes, plus read-only quarantine self-heal verification for transient IOERR faults. || db-search-indexing | screenpipe-db | windows, macos, linux | db-search, ocr, accessibility, performance | local-api-search, capture-ocr-pipeline, accessibility-ui-events, performance-liveness | high | strong | mixed | 13 | 105 | 4 | FTS, tokenizer, OCR snapshot search, query planning, ordering, accessibility search, and contention coverage. |-| db-timeline-frames | screenpipe-db | windows, macos, linux | database, timeline, storage, performance | timeline-streaming, performance-liveness | high | strong | mixed | 29 | 246 | 8 | Frame/audio joins, timeline query shape, suggestions frames, write queue, DB primitives (src/db.rs split into src/db/ modules), feedback record upserts, media eviction anti-join regressions, SAF output registry, semantic storage, and timeline performance. |+| db-timeline-frames | screenpipe-db | windows, macos, linux | database, timeline, storage, performance | timeline-streaming, performance-liveness | high | strong | mixed | 30 | 247 | 8 | Frame/audio joins, timeline query shape, suggestions frames, write queue, DB primitives (src/db.rs split into src/db/ modules), feedback record upserts, media eviction anti-join regressions, SAF output registry, semantic storage, and timeline performance. || engine-api-routes | screenpipe-engine | windows, macos, linux | local-api, timeline, meeting, transcription | local-api-search, timeline-streaming, meeting-live-notes, audio-record-transcribe | high | partial | mixed | 40 | 408 | 4 | Route/unit coverage for search, health, streaming, meetings, time/timezone, and transcription. Legacy endpoint/websocket tests require local data and remain ignored. || engine-capture-timeline | screenpipe-engine | windows, macos, linux | vision-capture, timeline, storage, performance | capture-ocr-pipeline, timeline-streaming, performance-liveness | high | partial | mixed | 25 | 301 | 26 | Covers capture trigger logic, frame/audio linking, hot cache, timeline refresh regressions, fragmented MP4 extraction, and HD-mode control. Several real-data tests are intentionally ignored by default. || engine-config-lifecycle | screenpipe-engine | windows, macos, linux | configuration, engine-lifecycle, performance | settings-to-engine-config, engine-health-lifecycle, performance-liveness | high | strong | mixed | 12 | 116 | 1 | Fast logic coverage for the config bridge, health-endpoint identity, tray health debounce, sleep/power policies, and queue backpressure. |@@ -339,6 +339,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su| db-timeline-frames | screenpipe-db | tests/timeline_frameless_audio_test.rs | integration | 3 | 0 | 3 || db-audio-meetings-speakers | screenpipe-db | tests/timeline_live_meeting_index_test.rs | integration | 2 | 0 | 2 || db-audio-meetings-speakers | screenpipe-db | tests/timeline_live_meeting_test.rs | integration | 12 | 0 | 12 |+| db-timeline-frames | screenpipe-db | tests/timeline_parquet_test.rs | integration | 1 | 0 | 1 || db-timeline-frames | screenpipe-db | tests/timeline_performance_test.rs | integration | 11 | 1 | 12 || db-accessibility-ui-events | screenpipe-db | tests/ui_events_batch_test.rs | integration | 4 | 0 | 4 || db-audio-meetings-speakers | screenpipe-db | tests/untranscribed_chunks_test.rs | integration | 14 | 0 | 14 |diff --git a/docs/coverage/core-engine-map.json b/docs/coverage/core-engine-map.jsonindex deee36ce1..adc852fa0 100644--- a/docs/coverage/core-engine-map.json+++ b/docs/coverage/core-engine-map.json@@ -688,6 +688,7 @@"tests/semantic_storage_test.rs","tests/suggestions_frames_table_test.rs","tests/timeline_frameless_audio_test.rs",+ "tests/timeline_parquet_test.rs","tests/timeline_performance_test.rs"],"platforms": [