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: retranscribe NOT NULL constraint on timestamp by using COALESCE

Louis Beaumontd56ba704b0df
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index 1d60e94e8..6b00a533e 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -781,7 +781,8 @@ impl DatabaseManager {
) -> Result<Vec<AudioChunkInfo>, sqlx::Error> {
let rows = sqlx::query_as::<_, AudioChunkInfo>(
r#"SELECT ac.id, ac.file_path, at.transcription, at.transcription_engine,
- at.offset_index, at.timestamp, at.device, at.is_input_device
+ at.offset_index, COALESCE(at.timestamp, ac.timestamp) as timestamp,
+ at.device, at.is_input_device
FROM audio_chunks ac
LEFT JOIN audio_transcriptions at ON ac.id = at.audio_chunk_id
WHERE ac.timestamp >= ?1 AND ac.timestamp <= ?2
diff --git a/crates/screenpipe-db/src/types.rs b/crates/screenpipe-db/src/types.rs
index c058a9c08..99776b703 100644
--- a/crates/screenpipe-db/src/types.rs
+++ b/crates/screenpipe-db/src/types.rs
@@ -13,7 +13,7 @@ pub struct AudioChunkInfo {
pub transcription: Option<String>,
pub transcription_engine: Option<String>,
pub offset_index: Option<i64>,
- pub timestamp: Option<DateTime<Utc>>,
+ pub timestamp: DateTime<Utc>,
pub device: Option<String>,
pub is_input_device: Option<bool>,
}
diff --git a/crates/screenpipe-server/src/routes/retranscribe.rs b/crates/screenpipe-server/src/routes/retranscribe.rs
index e83ef7c06..a4fe4e080 100644
--- a/crates/screenpipe-server/src/routes/retranscribe.rs
+++ b/crates/screenpipe-server/src/routes/retranscribe.rs
@@ -190,7 +190,7 @@ pub async fn retranscribe_handler(
let device_name = chunk.device.as_deref().unwrap_or("unknown");
let is_input = chunk.is_input_device.unwrap_or(false);
let engine_name = engine.to_string();
- let timestamp = chunk.timestamp.unwrap_or_else(chrono::Utc::now);
+ let timestamp = chunk.timestamp;
if let Err(e) = state
.db
.replace_audio_transcription(