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

chore: cleanup PR #2255 — remove plan file, run cargo fmt

Louis Beaumontebf6cbdc4d71
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index 7f2638790..900b0dba4 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -2245,7 +2245,7 @@ impl DatabaseManager {
} else {
audio_timestamp
};
-
+
let audio_end = if let Some(end) = end_offset {
audio_timestamp + chrono::Duration::milliseconds((end * 1000.0) as i64)
} else {
diff --git a/crates/screenpipe-db/src/types.rs b/crates/screenpipe-db/src/types.rs
index cee22f101..8414da76f 100644
--- a/crates/screenpipe-db/src/types.rs
+++ b/crates/screenpipe-db/src/types.rs
@@ -582,17 +582,35 @@ mod tests {
#[test]
fn test_content_type_case_insensitive() {
// Test lowercase (original behavior)
- assert_eq!(ContentType::Audio, serde_json::from_str(r#""audio""#).unwrap());
- assert_eq!(ContentType::Vision, serde_json::from_str(r#""vision""#).unwrap());
- assert_eq!(ContentType::Input, serde_json::from_str(r#""input""#).unwrap());
+ assert_eq!(
+ ContentType::Audio,
+ serde_json::from_str(r#""audio""#).unwrap()
+ );
+ assert_eq!(
+ ContentType::Vision,
+ serde_json::from_str(r#""vision""#).unwrap()
+ );
+ assert_eq!(
+ ContentType::Input,
+ serde_json::from_str(r#""input""#).unwrap()
+ );
assert_eq!(ContentType::All, serde_json::from_str(r#""all""#).unwrap());
-
+
// Test uppercase (new behavior with aliases)
- assert_eq!(ContentType::Audio, serde_json::from_str(r#""Audio""#).unwrap());
- assert_eq!(ContentType::Vision, serde_json::from_str(r#""Vision""#).unwrap());
- assert_eq!(ContentType::Input, serde_json::from_str(r#""Input""#).unwrap());
+ assert_eq!(
+ ContentType::Audio,
+ serde_json::from_str(r#""Audio""#).unwrap()
+ );
+ assert_eq!(
+ ContentType::Vision,
+ serde_json::from_str(r#""Vision""#).unwrap()
+ );
+ assert_eq!(
+ ContentType::Input,
+ serde_json::from_str(r#""Input""#).unwrap()
+ );
assert_eq!(ContentType::All, serde_json::from_str(r#""All""#).unwrap());
-
+
// Test OCR/UI aliases (both cases)
assert_eq!(ContentType::OCR, serde_json::from_str(r#""ocr""#).unwrap());
assert_eq!(ContentType::OCR, serde_json::from_str(r#""OCR""#).unwrap());
diff --git a/crates/screenpipe-db/tests/keyword_search_order_test.rs b/crates/screenpipe-db/tests/keyword_search_order_test.rs
index 152c4e807..8f1a4cc99 100644
--- a/crates/screenpipe-db/tests/keyword_search_order_test.rs
+++ b/crates/screenpipe-db/tests/keyword_search_order_test.rs
@@ -1,8 +1,8 @@
#[cfg(test)]
mod tests {
use chrono::{Duration, Utc};
- use screenpipe_db::{DatabaseManager, OcrEngine, Order};
use screenpipe_db::fts_indexer::index_all_tables;
+ use screenpipe_db::{DatabaseManager, OcrEngine, Order};
use std::sync::Arc;
async fn setup_test_db() -> DatabaseManager {
diff --git a/crates/screenpipe-db/tests/timeline_performance_test.rs b/crates/screenpipe-db/tests/timeline_performance_test.rs
index 14ab6967e..2162fdcea 100644
--- a/crates/screenpipe-db/tests/timeline_performance_test.rs
+++ b/crates/screenpipe-db/tests/timeline_performance_test.rs
@@ -590,9 +590,14 @@ mod timeline_performance_tests {
.await
.unwrap();
- db.insert_ocr_text(frame_id, &format!("OCR text for frame {}", i), "", Arc::new(OcrEngine::Tesseract))
- .await
- .unwrap();
+ db.insert_ocr_text(
+ frame_id,
+ &format!("OCR text for frame {}", i),
+ "",
+ Arc::new(OcrEngine::Tesseract),
+ )
+ .await
+ .unwrap();
}
// Insert an audio transcription that spans 6 seconds (should cover ~3 frames)
@@ -615,8 +620,8 @@ mod timeline_performance_tests {
device_type: DeviceType::Output,
},
None,
- Some(0.0), // start_time offset
- Some(6.0), // end_time offset (6 seconds)
+ Some(0.0), // start_time offset
+ Some(6.0), // end_time offset (6 seconds)
Some(audio_start_time),
)
.await
@@ -655,10 +660,8 @@ mod timeline_performance_tests {
);
// Verify the audio is on the correct frames (frames 2, 3, 4 based on timestamps)
- let frame_timestamps_with_audio: Vec<_> = frames_with_audio
- .iter()
- .map(|f| f.timestamp)
- .collect();
+ let frame_timestamps_with_audio: Vec<_> =
+ frames_with_audio.iter().map(|f| f.timestamp).collect();
let expected_start = audio_start_time;
let expected_end = audio_start_time + Duration::seconds(6);
@@ -683,7 +686,7 @@ mod timeline_performance_tests {
// Create frames at the beginning of the time range
let start_time = Utc::now() - Duration::minutes(5);
-
+
let _ = db
.insert_video_chunk("test_video.mp4", "test_device")
.await
@@ -705,9 +708,14 @@ mod timeline_performance_tests {
.await
.unwrap();
- db.insert_ocr_text(frame_id, &format!("OCR text for frame {}", i), "", Arc::new(OcrEngine::Tesseract))
- .await
- .unwrap();
+ db.insert_ocr_text(
+ frame_id,
+ &format!("OCR text for frame {}", i),
+ "",
+ Arc::new(OcrEngine::Tesseract),
+ )
+ .await
+ .unwrap();
}
// Insert audio that's AFTER all frames (should fall back to closest frame)
diff --git a/plans/fix-timeline-audio-flagging.md b/plans/fix-timeline-audio-flagging.md
deleted file mode 100644
index 759dcdcda..000000000
--- a/plans/fix-timeline-audio-flagging.md
+++ /dev/null
@@ -1,187 +0,0 @@
-# Fix: Timeline Scrollbar Not Flagging Transcriptions
-
-## Problem Summary
-
-The timeline scrollbar at the bottom of the page is not consistently showing audio indicators (taller bars) for frames that have transcriptions. While transcriptions exist in the database and can be retrieved via agent search, they are not being properly flagged in the timeline UI.
-
-## Root Cause Analysis
-
-The issue is in the audio-to-frame matching logic in [`find_video_chunks`](../crates/screenpipe-db/src/db.rs:2318) function.
-
-### Current Implementation (Problematic)
-
-```rust
-// Process audio data with proper synchronization
-for row in audio_rows {
- let timestamp: DateTime<Utc> = row.get("timestamp");
-
- // Find the closest frame
- if let Some((&key, _)) = frames_map
- .range(..=(timestamp, i64::MAX))
- .next_back()
- .or_else(|| frames_map.iter().next())
- {
- if let Some(frame_data) = frames_map.get_mut(&key) {
- frame_data.audio_entries.push(AudioEntry { ... });
- }
- }
-}
-```
-
-### Issues Identified
-
-1. **Single Frame Assignment**: Audio is only assigned to ONE frame, but audio chunks can span multiple frames (several seconds of audio)
-
-2. **Timestamp Mismatch**: Audio timestamps and frame timestamps are independent:
- - Frames are captured at screen capture intervals (~0.5-2 seconds)
- - Audio chunks have their own timestamps with `start_time` and `end_time` offsets
- - The current logic only matches to the closest frame BEFORE the audio timestamp
-
-3. **No Time Window Tolerance**: The matching logic doesn't account for:
- - Audio duration (can be 5-30+ seconds per chunk)
- - Frames that occur DURING the audio playback
-
-4. **BTreeMap Key Structure**: The key `(DateTime<Utc>, i64)` uses `offset_index` as secondary key, making range queries by timestamp alone awkward
-
-## Data Flow
-
-```
-┌─────────────────────────────────────────────────────────────────┐
-│ Database Queries │
-├─────────────────────────────────────────────────────────────────┤
-│ frames_query: Get frames with OCR data │
-│ audio_query: Get audio transcriptions │
-│ │
-│ Both use same time range: start_time to end_time │
-└─────────────────────────────────────────────────────────────────┘
- │
- ▼
-┌─────────────────────────────────────────────────────────────────┐
-│ Audio-to-Frame Matching │
-├─────────────────────────────────────────────────────────────────┤
-│ Current: Match audio to single frame closest BEFORE timestamp │
-│ Problem: Audio spans multiple frames, only one gets flagged │
-└─────────────────────────────────────────────────────────────────┘
- │
- ▼
-┌─────────────────────────────────────────────────────────────────┐
-│ Timeline Display │
-├─────────────────────────────────────────────────────────────────┤
-│ hasAudio = Boolean(frame?.devices?.[0]?.audio?.length) │
-│ - Taller bars for frames with audio │
-│ - Most frames show no audio even though audio exists │
-└─────────────────────────────────────────────────────────────────┘
-```
-
-## Proposed Solution
-
-### Option A: Multi-Frame Audio Assignment (Recommended)
-
-Assign audio to ALL frames that fall within the audio's time range:
-
-```rust
-// For each audio entry, find ALL frames within its time range
-for row in audio_rows {
- let audio_timestamp: DateTime<Utc> = row.get("timestamp");
- let start_offset: f64 = row.try_get("start_time").unwrap_or(0.0);
- let end_offset: f64 = row.try_get("end_time").unwrap_or(0.0);
-
- // Calculate audio time range
- let audio_start = audio_timestamp + chrono::Duration::milliseconds(start_offset as i64 * 1000);
- let audio_end = audio_timestamp + chrono::Duration::milliseconds(end_offset as i64 * 1000);
-
- // Find all frames within this range
- for (&key, frame_data) in frames_map.range((audio_start, i64::MIN)..=(audio_end, i64::MAX)) {
- frame_data.audio_entries.push(AudioEntry { ... });
- }
-}
-```
-
-**Pros:**
-- Accurate representation of when audio occurred
-- All relevant frames show audio indicators
-- Better UX for finding audio in timeline
-
-**Cons:**
-- More complex matching logic
-- Potential for duplicate audio entries across frames
-- Need to handle deduplication in UI
-
-### Option B: Time Window Tolerance
-
-Use a time window tolerance when matching audio to frames:
-
-```rust
-const AUDIO_MATCH_WINDOW_SECS: i64 = 30; // 30 second window
-
-for row in audio_rows {
- let timestamp: DateTime<Utc> = row.get("timestamp");
- let window_start = timestamp - chrono::Duration::seconds(AUDIO_MATCH_WINDOW_SECS);
- let window_end = timestamp + chrono::Duration::seconds(AUDIO_MATCH_WINDOW_SECS);
-
- // Find frames within the window
- for (&key, frame_data) in frames_map.range((window_start, i64::MIN)..=(window_end, i64::MAX)) {
- frame_data.audio_entries.push(AudioEntry { ... });
- }
-}
-```
-
-### Option C: Frontend Fallback (Quick Fix)
-
-Add a fallback in the frontend to check for audio in nearby frames:
-
-```typescript
-// In timeline.tsx
-const hasAudio = useMemo(() => {
- // Check current frame
- if (frame?.devices?.[0]?.audio?.length) return true;
-
- // Check nearby frames (within 30 seconds)
- const frameTime = new Date(frame.timestamp).getTime();
- const nearbyFrames = frames.filter(f => {
- const t = new Date(f.timestamp).getTime();
- return Math.abs(t - frameTime) < 30000; // 30 seconds
- });
-
- return nearbyFrames.some(f => f?.devices?.[0]?.audio?.length);
-}, [frame, frames]);
-```
-
-## Recommended Implementation Plan
-
-### Phase 1: Backend Fix (Option A)
-
-1. **Modify [`find_video_chunks`](../crates/screenpipe-db/src/db.rs:2318)** to assign audio to all frames within the audio's time range
-
-2. **Add deduplication** to prevent the same audio from appearing multiple times in the UI for the same frame
-
-3. **Update tests** to verify multi-frame audio assignment
-
-### Phase 2: Frontend Enhancement
-
-1. **Update timeline tooltip** to show all audio entries for a frame
-
-2. **Add audio duration indicator** to show how long the audio spans
-
-3. **Consider visual indicator** for frames with long audio vs short audio
-
-## Files to Modify
-
-1. `crates/screenpipe-db/src/db.rs` - Audio-to-frame matching logic
-2. `crates/screenpipe-server/src/routes/streaming.rs` - Audio entry creation
-3. `apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx` - Frontend display (optional enhancement)
-
-## Testing Plan
-
-1. **Unit Tests**: Add tests for multi-frame audio assignment
-2. **Integration Tests**: Verify audio appears on correct frames in timeline
-3. **Manual Testing**:
- - Record screen with audio
- - Verify timeline shows audio indicators on all relevant frames
- - Check that clicking a frame with audio shows the transcription
-
-## Estimated Effort
-
-- Backend changes: Moderate complexity
-- Testing: Moderate
-- Frontend enhancements: Low (optional)