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
Bump app to v2.0.600
Louis Beaumont7acf335478bf
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/audio-transcript.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/audio-transcript.tsxindex b3255b011..c885b3c1c 100644--- a/apps/screenpipe-app-tauri/components/rewind/timeline/audio-transcript.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/audio-transcript.tsx@@ -4,7 +4,22 @@import { useState, useRef, useMemo, useCallback, useEffect } from "react";import { AudioData, StreamTimeSeriesResponse, TimeRange } from "@/components/rewind/timeline";import { Button } from "@/components/ui/button";-import { GripHorizontal, X, Users, Copy, Check, BotMessageSquare, Sparkles } from "lucide-react";+import { GripHorizontal, X, Users, Copy, Check, BotMessageSquare, Sparkles, MoreVertical, RefreshCw, Loader2 } from "lucide-react";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogFooter,+} from "@/components/ui/dialog";+import { Input } from "@/components/ui/input";+import { useToast } from "@/components/ui/use-toast";import { showChatWithPrefill } from "@/lib/chat-utils";import {ConversationBubble,@@ -125,6 +140,22 @@ export function AudioTranscript({Map<number, { speakerId: number; speakerName: string }>>(new Map());+ // Track retranscription overrides (chunk-level text updates)+ const [transcriptionOverrides, setTranscriptionOverrides] = useState<+ Map<number, string>+ >(new Map());++ const handleRetranscribed = useCallback(+ (audioChunkId: number, newText: string) => {+ setTranscriptionOverrides((prev) => {+ const next = new Map(prev);+ next.set(audioChunkId, newText);+ return next;+ });+ },+ []+ );+const handleSpeakerAssigned = useCallback((audioChunkId: number, newSpeakerId: number, newSpeakerName: string) => {setSpeakerOverrides((prev) => {@@ -381,6 +412,62 @@ export function AudioTranscript({});}, [tabMode, meetingConversationData, conversationData, getSpeakerInfo]);+ // Retranscribe: re-run STT on all audio in the current view+ const [isRetranscribing, setIsRetranscribing] = useState(false);+ const [showRetranscribeDialog, setShowRetranscribeDialog] = useState(false);+ const [retranscribePrompt, setRetranscribePrompt] = useState("");+ const { toast } = useToast();++ const handleRetranscribe = useCallback(async () => {+ const data = tabMode === "meeting" ? meetingConversationData : conversationData;+ if (!data.items.length || !data.timeRange) return;++ setShowRetranscribeDialog(false);+ setIsRetranscribing(true);++ try {+ const body: Record<string, unknown> = {+ start: data.timeRange.start.toISOString(),+ end: data.timeRange.end.toISOString(),+ };+ if (retranscribePrompt.trim()) {+ body.prompt = retranscribePrompt.trim();+ }++ const res = await fetch("http://localhost:3030/audio/retranscribe", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(body),+ });++ if (!res.ok) {+ const err = await res.json().catch(() => ({}));+ throw new Error(err.error || `failed (${res.status})`);+ }++ const result = await res.json();++ // Apply all new transcriptions as overrides+ for (const t of result.transcriptions ?? []) {+ handleRetranscribed(t.audio_chunk_id, t.new_text);+ }++ toast({+ title: "retranscribed",+ description: `${result.chunks_processed} chunk${result.chunks_processed !== 1 ? "s" : ""} updated`,+ });+ } catch (e: any) {+ toast({+ title: "retranscribe failed",+ description: e.message,+ variant: "destructive",+ });+ } finally {+ setIsRetranscribing(false);+ setRetranscribePrompt("");+ }+ }, [tabMode, meetingConversationData, conversationData, retranscribePrompt, handleRetranscribed, toast]);+const handleSendToChat = useCallback(async () => {const data = tabMode === "meeting" ? meetingConversationData : conversationData;if (!data.items.length) return;@@ -635,6 +722,27 @@ export function AudioTranscript({</TooltipTrigger><TooltipContent side="bottom"><p>{copied ? "copied!" : "copy"}</p></TooltipContent></Tooltip>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="ghost" size="sm" className="h-6 w-6 p-0">+ {isRetranscribing ? (+ <Loader2 className="h-3 w-3 animate-spin" />+ ) : (+ <MoreVertical className="h-3 w-3" />+ )}+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-44">+ <DropdownMenuItem+ onClick={() => setShowRetranscribeDialog(true)}+ disabled={isRetranscribing}+ className="text-xs gap-2"+ >+ <RefreshCw className="h-3 w-3" />+ retranscribe+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu><Tooltip><TooltipTrigger asChild><Button variant="ghost" size="sm" className="h-6 w-6 p-0" onClick={handleClose}>@@ -733,7 +841,7 @@ export function AudioTranscript({audioChunkId={item.audio.audio_chunk_id}speakerId={speakerId}speakerName={speakerName}- transcription={item.audio.transcription}+ transcription={transcriptionOverrides.get(item.audio.audio_chunk_id) ?? item.audio.transcription}audioFilePath={item.audio.audio_file_path}durationSecs={item.audio.duration_secs}timestamp={item.audio.timestamp}@@ -790,7 +898,7 @@ export function AudioTranscript({audioChunkId={item.audio.audio_chunk_id}speakerId={speakerId}speakerName={speakerName}- transcription={item.audio.transcription}+ transcription={transcriptionOverrides.get(item.audio.audio_chunk_id) ?? item.audio.transcription}audioFilePath={item.audio.audio_file_path}durationSecs={item.audio.duration_secs}timestamp={item.audio.timestamp}@@ -826,6 +934,48 @@ export function AudioTranscript({borderBottomRightRadius: "12px",}}/>++ {/* Retranscribe dialog */}+ <Dialog open={showRetranscribeDialog} onOpenChange={setShowRetranscribeDialog}>+ <DialogContent className="sm:max-w-md">+ <DialogHeader>+ <DialogTitle className="text-sm">retranscribe audio</DialogTitle>+ </DialogHeader>+ <div className="space-y-3">+ <p className="text-xs text-muted-foreground">+ re-run speech-to-text on all audio chunks in the current view.+ optionally provide a prompt to guide transcription (e.g. speaker names, technical terms, language).+ </p>+ <Input+ placeholder="optional prompt (e.g. 'speakers: marc, ben. topic: AI startups')"+ value={retranscribePrompt}+ onChange={(e) => setRetranscribePrompt(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter") handleRetranscribe();+ }}+ className="text-xs"+ />+ </div>+ <DialogFooter>+ <Button+ variant="outline"+ size="sm"+ className="text-xs"+ onClick={() => setShowRetranscribeDialog(false)}+ >+ cancel+ </Button>+ <Button+ size="sm"+ className="text-xs gap-1.5"+ onClick={handleRetranscribe}+ >+ <RefreshCw className="h-3 w-3" />+ retranscribe+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog></div>) : null;}diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 9744f2119..ef96ebbac 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -8183,7 +8183,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.0.599"+version = "2.0.600"dependencies = ["anyhow","arboard",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 5de402de1..dde71f6c7 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.0.599"+version = "2.0.600"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/crates/screenpipe-audio/src/audio_manager/reconciliation.rs b/crates/screenpipe-audio/src/audio_manager/reconciliation.rsindex 8be233d5e..7a964e7ce 100644--- a/crates/screenpipe-audio/src/audio_manager/reconciliation.rs+++ b/crates/screenpipe-audio/src/audio_manager/reconciliation.rs@@ -6,8 +6,8 @@ use std::path::Path;use std::sync::Arc;use screenpipe_core::Language;-use screenpipe_db::DatabaseManager;-use tracing::{error, info, warn};+use screenpipe_db::{DatabaseManager, UntranscribedChunk};+use tracing::{debug, error, info, warn};use whisper_rs::WhisperContext;use crate::core::engine::AudioTranscriptionEngine;@@ -15,11 +15,15 @@ use crate::transcription::stt::stt;use crate::transcription::VocabularyEntry;use crate::utils::ffmpeg::read_audio_from_file;-/// Finds audio chunks with no transcription row (orphans) and transcribes them.+/// Maximum number of consecutive 30s chunks to concatenate into a single batch.+/// 10 × 30s = 5 minutes — gives Whisper much more context for better quality.+const MAX_BATCH_CHUNKS: usize = 10;++/// Finds audio chunks with no transcription row (orphans), groups consecutive+/// chunks from the same device, concatenates them, and transcribes the batch.///-/// This handles cases where audio was persisted to disk + DB but transcription-/// was deferred (smart mode) and then lost due to app restart, STT failure,-/// channel drop, or DB write failure.+/// This gives Whisper 2-5 minutes of context instead of 30s, significantly+/// improving transcription quality — the whole point of batch mode.////// Returns the number of chunks successfully transcribed.pub async fn reconcile_untranscribed(@@ -48,61 +52,87 @@ pub async fn reconcile_untranscribed(chunks.len());+ // Group consecutive chunks by device for batched transcription.+ let batches = group_chunks_by_device(&chunks);+ info!(+ "reconciliation: grouped into {} batches (max {}×30s each)",+ batches.len(),+ MAX_BATCH_CHUNKS+ );+let mut success_count = 0;- for chunk in &chunks {- let path = Path::new(&chunk.file_path);- if !path.exists() {- warn!(- "reconciliation: audio file missing, skipping chunk {}: {}",- chunk.id, chunk.file_path- );- continue;- }+ for batch in &batches {+ let (device_name, is_input) = extract_device_from_path(&batch[0].file_path);- // Extract device name and type from file path.- // Format: .../Device Name (output)_2026-02-27_23-15-38.mp4- let (device_name, is_input) = extract_device_from_path(&chunk.file_path);+ // Read and concatenate audio from all chunks in this batch+ let mut combined_samples: Vec<f32> = Vec::new();+ let mut sample_rate = 0u32;+ let mut valid_chunks: Vec<&UntranscribedChunk> = Vec::new();- // Decode audio from file (blocking ffmpeg call — run off the async runtime)- let path_owned = chunk.file_path.clone();- let (samples, sample_rate) = match tokio::task::spawn_blocking(move || {- read_audio_from_file(Path::new(&path_owned))- })- .await- {- Ok(Ok(result)) => result,- Ok(Err(e)) => {- error!(- "reconciliation: failed to read audio for chunk {}: {}",- chunk.id, e+ for chunk in batch {+ let path = Path::new(&chunk.file_path);+ if !path.exists() {+ warn!(+ "reconciliation: audio file missing, skipping chunk {}: {}",+ chunk.id, chunk.file_path);continue;}- Err(e) => {- error!(- "reconciliation: spawn_blocking panicked for chunk {}: {}",- chunk.id, e- );- continue;++ let path_owned = chunk.file_path.clone();+ match tokio::task::spawn_blocking(move || {+ read_audio_from_file(Path::new(&path_owned))+ })+ .await+ {+ Ok(Ok((samples, sr))) => {+ sample_rate = sr;+ combined_samples.extend_from_slice(&samples);+ valid_chunks.push(chunk);+ }+ Ok(Err(e)) => {+ error!(+ "reconciliation: failed to read audio for chunk {}: {}",+ chunk.id, e+ );+ }+ Err(e) => {+ error!(+ "reconciliation: spawn_blocking panicked for chunk {}: {}",+ chunk.id, e+ );+ }}- };+ }++ if valid_chunks.is_empty() || combined_samples.is_empty() {+ continue;+ }++ let batch_duration = combined_samples.len() as f64 / sample_rate as f64;+ debug!(+ "reconciliation: transcribing batch of {} chunks ({:.0}s) for {}",+ valid_chunks.len(),+ batch_duration,+ device_name+ );- // Create a fresh WhisperState (cheap — reuses GPU model)+ // Create a single WhisperState for the entire batchlet mut state = match whisper_context.create_state() {Ok(s) => s,Err(e) => {error!(- "reconciliation: failed to create whisper state for chunk {}: {}",- chunk.id, e+ "reconciliation: failed to create whisper state: {}",+ e);continue;}};- // Run STT- let text = match stt(- &samples,+ // Transcribe the concatenated audio in one shot+ let full_text = match stt(+ &combined_samples,sample_rate,&device_name,engine.clone(),@@ -116,45 +146,82 @@ pub async fn reconcile_untranscribed({Ok(t) => t,Err(e) => {- error!(- "reconciliation: stt failed for chunk {}: {}",- chunk.id, e- );+ error!("reconciliation: stt failed for batch: {}", e);continue;}};- // Write transcription to DB+ // Store the full batch transcription on the FIRST chunk.+ // Delete the remaining chunks (and their files) to avoid duplicates.+ let primary_chunk = valid_chunks[0];let engine_name = engine.to_string();- let duration_secs = samples.len() as f64 / sample_rate as f64;+if let Err(e) = db.replace_audio_transcription(- chunk.id,- &text,+ primary_chunk.id,+ &full_text,&engine_name,&device_name,is_input,- chunk.timestamp,- Some(duration_secs),+ primary_chunk.timestamp,+ Some(batch_duration),).await{error!("reconciliation: failed to write transcription for chunk {}: {}",- chunk.id, e+ primary_chunk.id, e);continue;}-success_count += 1;- // Yield to other tasks between chunks+ // Delete the secondary chunks — they're now merged into the primary.+ for chunk in &valid_chunks[1..] {+ if let Err(e) = db.delete_audio_chunk(chunk.id).await {+ warn!(+ "reconciliation: failed to delete merged chunk {}: {}",+ chunk.id, e+ );+ }+ // Clean up the audio file too+ let _ = std::fs::remove_file(&chunk.file_path);+ success_count += 1;+ }++ // Yield to other tasks between batchestokio::task::yield_now().await;}success_count}+/// Group chunks into batches of consecutive chunks from the same device.+/// Chunks are already ordered by timestamp ASC from the DB query.+fn group_chunks_by_device(chunks: &[UntranscribedChunk]) -> Vec<Vec<&UntranscribedChunk>> {+ let mut batches: Vec<Vec<&UntranscribedChunk>> = Vec::new();++ for chunk in chunks {+ let (device, _) = extract_device_from_path(&chunk.file_path);++ let should_start_new = match batches.last() {+ None => true,+ Some(current_batch) => {+ let (last_device, _) = extract_device_from_path(¤t_batch[0].file_path);+ last_device != device || current_batch.len() >= MAX_BATCH_CHUNKS+ }+ };++ if should_start_new {+ batches.push(vec![chunk]);+ } else {+ batches.last_mut().unwrap().push(chunk);+ }+ }++ batches+}+/// Extract device name and is_input from an audio file path./// Path format: `.../Device Name (output)_2026-02-27_23-15-38.mp4`/// Returns (device_name, is_input).@@ -175,3 +242,95 @@ fn extract_device_from_path(file_path: &str) -> (String, bool) {let is_input = device_part.contains("(input)");(device_part.to_string(), is_input)}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn extract_device_output() {+ let (name, is_input) = extract_device_from_path(+ "/Users/user/.screenpipe/data/Display 3 (output)_2026-02-27_23-15-38.mp4",+ );+ assert_eq!(name, "Display 3 (output)");+ assert!(!is_input);+ }++ #[test]+ fn extract_device_input() {+ let (name, is_input) = extract_device_from_path(+ "/Users/user/.screenpipe/data/input (input)_2026-02-27_23-15-38.mp4",+ );+ assert_eq!(name, "input (input)");+ assert!(is_input);+ }++ #[test]+ fn group_chunks_same_device() {+ let chunks = vec![+ UntranscribedChunk {+ id: 1,+ file_path: "/data/input (input)_2026-02-27_23-15-08.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ UntranscribedChunk {+ id: 2,+ file_path: "/data/input (input)_2026-02-27_23-15-38.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ UntranscribedChunk {+ id: 3,+ file_path: "/data/input (input)_2026-02-27_23-16-08.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ ];+ let batches = group_chunks_by_device(&chunks);+ assert_eq!(batches.len(), 1);+ assert_eq!(batches[0].len(), 3);+ }++ #[test]+ fn group_chunks_alternating_devices() {+ let chunks = vec![+ UntranscribedChunk {+ id: 1,+ file_path: "/data/input (input)_2026-02-27_23-15-08.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ UntranscribedChunk {+ id: 2,+ file_path: "/data/Display 3 (output)_2026-02-27_23-15-08.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ UntranscribedChunk {+ id: 3,+ file_path: "/data/input (input)_2026-02-27_23-15-38.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ UntranscribedChunk {+ id: 4,+ file_path: "/data/Display 3 (output)_2026-02-27_23-15-38.mp4".to_string(),+ timestamp: chrono::Utc::now(),+ },+ ];+ let batches = group_chunks_by_device(&chunks);+ // input, output, input, output → 4 batches (alternating)+ assert_eq!(batches.len(), 4);+ }++ #[test]+ fn group_chunks_respects_max_batch() {+ let mut chunks = Vec::new();+ for i in 0..(MAX_BATCH_CHUNKS + 3) {+ chunks.push(UntranscribedChunk {+ id: i as i64,+ file_path: format!("/data/input (input)_2026-02-27_23-{:02}-08.mp4", i),+ timestamp: chrono::Utc::now(),+ });+ }+ let batches = group_chunks_by_device(&chunks);+ assert_eq!(batches.len(), 2);+ assert_eq!(batches[0].len(), MAX_BATCH_CHUNKS);+ assert_eq!(batches[1].len(), 3);+ }+}diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rsindex fb2e8d1f4..98ec7c467 100644--- a/crates/screenpipe-db/src/db.rs+++ b/crates/screenpipe-db/src/db.rs@@ -539,6 +539,22 @@ impl DatabaseManager {Ok(rows)}+ /// Delete an audio chunk and its transcriptions (cascade via FK).+ /// Used by batch reconciliation to merge multiple 30s chunks into one.+ pub async fn delete_audio_chunk(&self, chunk_id: i64) -> Result<(), sqlx::Error> {+ let mut tx = self.begin_immediate_with_retry().await?;+ sqlx::query("DELETE FROM audio_transcriptions WHERE audio_chunk_id = ?1")+ .bind(chunk_id)+ .execute(&mut **tx.conn())+ .await?;+ sqlx::query("DELETE FROM audio_chunks WHERE id = ?1")+ .bind(chunk_id)+ .execute(&mut **tx.conn())+ .await?;+ tx.commit().await?;+ Ok(())+ }+pub async fn count_audio_transcriptions(&self,audio_chunk_id: i64,