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: hot cache warm wait, permission recovery UX, timeline retry backoff
Louis Beaumont57cca740f810
diff --git a/Cargo.lock b/Cargo.lockindex 005c6753c..122ceab4c 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -7961,7 +7961,7 @@ dependencies = [[[package]]name = "whisper-rs"version = "0.15.1"-source = "git+https://codeberg.org/tazz4843/whisper-rs.git?rev=d38738df8dc54b12d2918494586ba0817c3cb12f#d38738df8dc54b12d2918494586ba0817c3cb12f"+source = "git+https://github.com/tazz4843/whisper-rs.git?rev=d38738df8dc54b12d2918494586ba0817c3cb12f#d38738df8dc54b12d2918494586ba0817c3cb12f"dependencies = ["tracing","whisper-rs-sys",@@ -7970,7 +7970,7 @@ dependencies = [[[package]]name = "whisper-rs-sys"version = "0.14.1"-source = "git+https://codeberg.org/tazz4843/whisper-rs.git?rev=d38738df8dc54b12d2918494586ba0817c3cb12f#d38738df8dc54b12d2918494586ba0817c3cb12f"+source = "git+https://github.com/tazz4843/whisper-rs.git?rev=d38738df8dc54b12d2918494586ba0817c3cb12f#d38738df8dc54b12d2918494586ba0817c3cb12f"dependencies = ["bindgen 0.71.1","cfg-if",diff --git a/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx b/apps/screenpipe-app-tauri/app/permission-recovery/page.tsxindex 807ef12da..c6a7487ae 100644--- a/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx+++ b/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx@@ -5,9 +5,8 @@"use client";import React, { useState, useEffect, useCallback, useRef } from "react";-import { Monitor, Mic, Keyboard, Globe, Check, RefreshCw, ExternalLink } from "lucide-react";-import { Button } from "@/components/ui/button";-import { commands, type OSPermission } from "@/lib/utils/tauri";+import { Monitor, Mic, Keyboard, Globe, Check, RefreshCw } from "lucide-react";+import { commands } from "@/lib/utils/tauri";import { usePlatform } from "@/lib/hooks/use-platform";import posthog from "posthog-js";@@ -24,31 +23,50 @@ function PermissionRow({status: "granted" | "denied" | "checking";onFix: () => void;}) {+ const isGranted = status === "granted";return (- <div className="flex items-center justify-between py-2">- <div className="flex items-center space-x-3">- <div className="text-muted-foreground">{icon}</div>- <div>- <span className="font-mono text-sm">{label}</span>- <span className="font-mono text-xs text-muted-foreground ml-2">{description}</span>+ <button+ onClick={isGranted ? undefined : onFix}+ disabled={isGranted || status === "checking"}+ className="w-full flex items-center gap-3 px-4 py-3 border border-border/50 transition-all group disabled:cursor-default hover:enabled:bg-foreground hover:enabled:text-background"+ >+ <div+ className={`w-7 h-7 rounded-full flex items-center justify-center shrink-0 transition-colors ${+ isGranted ? "bg-foreground/10" : "bg-muted group-hover:bg-background/10"+ }`}+ >+ <div+ className={`transition-colors ${+ isGranted ? "text-foreground" : "text-muted-foreground group-hover:text-background/70"+ }`}+ >+ {status === "checking" ? (+ <RefreshCw className="w-3 h-3 animate-spin" />+ ) : isGranted ? (+ <Check className="w-3.5 h-3.5" strokeWidth={2.5} />+ ) : (+ icon+ )}</div></div>- {status === "checking" ? (- <RefreshCw className="w-3 h-3 animate-spin text-muted-foreground" />- ) : status === "granted" ? (- <span className="font-mono text-xs text-muted-foreground">ok</span>- ) : (- <Button- variant="outline"- size="sm"- onClick={onFix}- className="font-mono text-xs h-7"- >- <ExternalLink className="w-3 h-3 mr-1" />- fix- </Button>- )}- </div>++ <div className="flex flex-col items-start min-w-0">+ <span className="font-mono text-xs font-medium">{label}</span>+ <span className="font-mono text-[10px] text-muted-foreground group-hover:enabled:text-background/50 leading-tight">+ {description}+ </span>+ </div>++ <div className="ml-auto shrink-0">+ {isGranted ? (+ <span className="font-mono text-[10px] text-muted-foreground">ok</span>+ ) : status === "checking" ? null : (+ <span className="font-mono text-[10px] text-muted-foreground group-hover:text-background/70">+ grant →+ </span>+ )}+ </div>+ </button>);}@@ -109,9 +127,11 @@ export default function PermissionRecoveryPage() {}}, [permissions, arcChecked, arcInstalled, arcAutomationOk]);- const openSettings = async (permission: OSPermission) => {+ const handleFix = async (permission: Parameters<typeof commands.requestPermission>[0]) => {posthog.capture("permission_recovery_manual_fix", { permission });- try { await commands.openPermissionSettings(permission); } catch {}+ try { await commands.requestPermission(permission); } catch {}+ // Immediate recheck after requesting+ await checkPermissions();};const screenStatus = permissions?.screenRecording === "granted" || permissions?.screenRecording === "notNeeded"@@ -148,20 +168,20 @@ export default function PermissionRecoveryPage() {</p></div>- <div className="divide-y divide-border">+ <div className="space-y-2"><PermissionRowicon={<Monitor className="w-4 h-4" strokeWidth={1.5} />}label="screen"description="capture display"status={screenStatus}- onFix={() => openSettings("screenRecording")}+ onFix={() => handleFix("screenRecording")}/><PermissionRowicon={<Mic className="w-4 h-4" strokeWidth={1.5} />}label="microphone"description="transcribe audio"status={micStatus}- onFix={() => openSettings("microphone")}+ onFix={() => handleFix("microphone")}/>{isMacOS && (<PermissionRow@@ -169,7 +189,7 @@ export default function PermissionRecoveryPage() {label="accessibility"description="shortcuts"status={accessibilityStatus}- onFix={() => openSettings("accessibility")}+ onFix={() => handleFix("accessibility")}/>)}{isMacOS && arcInstalled && (diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsxindex fb16e55e8..2984761b7 100644--- a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx@@ -1253,10 +1253,11 @@ export const TimelineSlider = ({group.topDomains.slice(0, groupWidth > 60 ? 2 : 1).map((domain, idx) => (<motion.divkey={`fav-${domain}-${idx}`}- className="w-5 h-5 rounded-full flex-shrink-0 overflow-hidden flex items-center justify-center ring-1 ring-white/20 shadow-sm shadow-black/30"+ className="w-5 h-5 rounded-md flex-shrink-0 overflow-hidden flex items-center justify-center"style={{zIndex: 10 - idx,position: 'relative',+ backgroundColor: appNameToColor(group.appName, 0.3),}}variants={{collapsed: {@@ -1274,7 +1275,7 @@ export const TimelineSlider = ({domain={domain}fallbackAppName={group.appName}size={20}- className="w-full h-full object-cover"+ className="w-full h-full rounded-sm object-cover"/></motion.div>))diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-timeline-store.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-timeline-store.tsxindex 19867a435..bb9d829fa 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-timeline-store.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-timeline-store.tsx@@ -21,11 +21,12 @@ let errorGraceTimer: ReturnType<typeof setTimeout> | null = null;const MAX_SILENT_RETRIES = 5; // Increased from 3 - retry more before showing errorconst RETRY_DELAY_MS = 2000; // Wait 2 seconds between retries-// Request timeout logic - retry if no frames arrive+// Request timeout logic - retry with exponential backoff (never give up)let requestTimeoutTimer: ReturnType<typeof setTimeout> | null = null;let requestRetryCount = 0;-const REQUEST_TIMEOUT_MS = 5000; // 5 seconds to receive frames-const MAX_REQUEST_RETRIES = 3; // Retry request 3 times before giving up+const REQUEST_TIMEOUT_BASE_MS = 5000; // Initial timeout: 5 seconds+const REQUEST_TIMEOUT_MAX_MS = 60000; // Cap at 60 seconds+// No MAX_REQUEST_RETRIES — keep retrying forever with backoff// Reconnect timeout - must be tracked to prevent cascadelet reconnectTimeout: ReturnType<typeof setTimeout> | null = null;@@ -622,34 +623,38 @@ export const useTimelineStore = create<TimelineState>((set, get) => ({sentRequests: new Set(state.sentRequests).add(requestKey),}));- // Start timeout - if no frames arrive, retry+ // Start timeout - if no frames arrive, retry with exponential backoffif (requestTimeoutTimer) {clearTimeout(requestTimeoutTimer);}+ const timeoutMs = Math.min(+ REQUEST_TIMEOUT_BASE_MS * Math.pow(2, requestRetryCount),+ REQUEST_TIMEOUT_MAX_MS+ );requestTimeoutTimer = setTimeout(() => {requestTimeoutTimer = null;const { frames: currentFrames, pendingDateSwap: stillSwapping } = get();- // Retry if no frames arrived (or still waiting for date swap to complete)- if ((currentFrames.length === 0 || stillSwapping) && requestRetryCount < MAX_REQUEST_RETRIES) {+ // Retry forever with backoff if no frames arrived+ if (currentFrames.length === 0 || stillSwapping) {requestRetryCount++;// Clear this date from sentRequests to allow retryset((state) => {const newSentRequests = new Set(state.sentRequests);newSentRequests.delete(requestKey);- return { sentRequests: newSentRequests };+ return {+ sentRequests: newSentRequests,+ message: requestRetryCount > 2+ ? "Loading history... server is warming up"+ : null,+ };});// Retry the requestget().fetchTimeRange(startTime, endTime);- } else if ((currentFrames.length === 0 || stillSwapping) && requestRetryCount >= MAX_REQUEST_RETRIES) {- set({- isLoading: false,- message: "No data available for this time range"- });}- }, REQUEST_TIMEOUT_MS);+ }, timeoutMs);} else if (attempt < 5) {// WebSocket not open — retry after a short delay instead of silently dropping.// This happens during cross-date navigation when the WS may be reconnecting.diff --git a/crates/screenpipe-server/src/hot_frame_cache.rs b/crates/screenpipe-server/src/hot_frame_cache.rsindex b350cab64..754dc3f2a 100644--- a/crates/screenpipe-server/src/hot_frame_cache.rs+++ b/crates/screenpipe-server/src/hot_frame_cache.rs@@ -10,7 +10,7 @@use chrono::{DateTime, Datelike, Utc};use std::collections::BTreeMap;-use tokio::sync::{broadcast, RwLock};+use tokio::sync::{broadcast, watch, RwLock};use tracing::{info, warn};use crate::video_cache::{AudioEntry, DeviceFrame, FrameMetadata, TimeSeriesFrame};@@ -63,6 +63,10 @@ pub struct HotFrameCache {/// and extended by push_frame (live capture). The streaming handler uses/// this to skip the DB backfill when the cache already covers the range.cache_warm_start: RwLock<Option<DateTime<Utc>>>,+ /// Signals when warm_from_db has completed. WS handlers wait on this+ /// before responding to time-range requests so they don't return empty.+ warm_ready_tx: watch::Sender<bool>,+ warm_ready_rx: watch::Receiver<bool>,}impl Default for HotFrameCache {@@ -76,6 +80,7 @@ impl HotFrameCache {pub fn new() -> Self {let (frame_tx, _) = broadcast::channel(256);let (audio_tx, _) = broadcast::channel(256);+ let (warm_tx, warm_rx) = watch::channel(false);Self {frames: RwLock::new(BTreeMap::new()),audio: RwLock::new(BTreeMap::new()),@@ -83,6 +88,8 @@ impl HotFrameCache {audio_notify: audio_tx,cache_day: RwLock::new(Utc::now().ordinal()),cache_warm_start: RwLock::new(None),+ warm_ready_tx: warm_tx,+ warm_ready_rx: warm_rx,}}@@ -177,6 +184,23 @@ impl HotFrameCache {ts.ordinal() == *day && ts.year() == Utc::now().year()}+ /// Wait until warm_from_db has completed (or timeout after `max_wait`).+ /// Returns true if warm completed, false if timed out.+ pub async fn wait_warm(&self, max_wait: std::time::Duration) -> bool {+ if *self.warm_ready_rx.borrow() {+ return true;+ }+ let mut rx = self.warm_ready_rx.clone();+ let result = tokio::time::timeout(max_wait, rx.wait_for(|v| *v)).await;+ match result {+ Ok(Ok(_)) => true,+ _ => {+ warn!("hot_frame_cache: wait_warm timed out after {:?}", max_wait);+ false+ }+ }+ }+/// Warm the cache from DB on cold start (load last N hours).pub async fn warm_from_db(&self, db: &screenpipe_db::DatabaseManager, hours: i64) {let end = Utc::now();@@ -252,6 +276,9 @@ impl HotFrameCache {warn!("hot_frame_cache: failed to warm from DB: {}", e);}}++ // Signal that warm is complete (even on failure — callers should not block forever)+ let _ = self.warm_ready_tx.send(true);}}diff --git a/crates/screenpipe-server/src/routes/streaming.rs b/crates/screenpipe-server/src/routes/streaming.rsindex bf27cbe56..c72ad0198 100644--- a/crates/screenpipe-server/src/routes/streaming.rs+++ b/crates/screenpipe-server/src/routes/streaming.rs@@ -284,6 +284,13 @@ async fn handle_stream_frames_socket(*live_sub_clone.lock().await = Some(is_today);if is_today {+ // Wait for cache to warm before responding (max 30s).+ // Without this, early WS connections get empty results+ // and the frontend shows "Building Your Memory" permanently.+ cache_clone+ .wait_warm(std::time::Duration::from_secs(30))+ .await;+// Read from hot cache — pure in-memory, <1mslet frames =cache_clone.get_frames_in_range(start_time, end_time).await;