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: load snapshot frames directly via asset protocol, bypass HTTP server
Louis Beaumontc028164686fc
diff --git a/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsxindex b414c44f1..2499f7ae7 100644--- a/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx@@ -162,6 +162,10 @@ export const CurrentFrameTimeline: FC<CurrentFrameTimelineProps> = ({lastFrameIdRef.current = frameId;}, [frameId]);+ // Snapshot frame direct-load state (bypasses HTTP server entirely)+ const [snapshotAssetUrl, setSnapshotAssetUrl] = useState<string | null>(null);+ const [snapshotFailed, setSnapshotFailed] = useState(false);+// Debounce frame changesuseEffect(() => {if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);@@ -178,6 +182,19 @@ export const CurrentFrameTimeline: FC<CurrentFrameTimelineProps> = ({};}, [frameId, filePath, offsetIndex, fpsFromServer]);+ // Detect snapshot frames (event-driven JPEGs) vs video chunks+ const isSnapshotFrame = useMemo(() => {+ if (!debouncedFrame?.filePath) return false;+ const lower = debouncedFrame.filePath.toLowerCase();+ return lower.endsWith('.jpg') || lower.endsWith('.jpeg') || lower.endsWith('.png');+ }, [debouncedFrame?.filePath]);++ // Reset snapshot state when frame changes+ useEffect(() => {+ setSnapshotFailed(false);+ setSnapshotAssetUrl(null);+ }, [debouncedFrame?.filePath]);+// Convert file path to asset URLconst getVideoUrl = useCallback(async (path: string): Promise<string | null> => {try {@@ -235,7 +252,7 @@ export const CurrentFrameTimeline: FC<CurrentFrameTimelineProps> = ({// Main video seeking effectuseEffect(() => {- if (!debouncedFrame || !useVideoMode) return;+ if (!debouncedFrame || !useVideoMode || isSnapshotFrame) return;const { filePath: path, offsetIndex: idx, fps: serverFps, frameId: fid } = debouncedFrame;// If this chunk previously failed, go straight to fallback@@ -348,13 +365,54 @@ export const CurrentFrameTimeline: FC<CurrentFrameTimelineProps> = ({loadedChunkRef.current = null;setUseVideoMode(false);});- }, [debouncedFrame, useVideoMode, getVideoUrl, resolveEffectiveFps]);+ }, [debouncedFrame, useVideoMode, getVideoUrl, resolveEffectiveFps, isSnapshotFrame]);++ // Snapshot frames: load directly via Tauri asset protocol (no HTTP/DB needed)+ useEffect(() => {+ if (!isSnapshotFrame || snapshotFailed || !debouncedFrame?.filePath) return;+ let cancelled = false;+ frameLoadStartTimeRef.current = performance.now();++ getVideoUrl(debouncedFrame.filePath).then((url) => {+ if (cancelled || !url) return;+ // Preload before displaying to avoid flicker+ const img = new Image();+ img.onload = () => {+ if (cancelled) return;+ setSnapshotAssetUrl(url);+ setIsLoading(false);+ setHasError(false);+ setNaturalDimensions({ width: img.naturalWidth, height: img.naturalHeight });+ if (frameLoadStartTimeRef.current !== null) {+ const loadTime = performance.now() - frameLoadStartTimeRef.current;+ posthog.capture("timeline_frame_load_time", {+ duration_ms: Math.round(loadTime),+ frame_id: debouncedFrame.frameId,+ success: true,+ mode: "snapshot_direct",+ frames_skipped: framesSkippedRef.current,+ });+ frameLoadStartTimeRef.current = null;+ framesSkippedRef.current = 0;+ }+ };+ img.onerror = () => {+ if (cancelled) return;+ setSnapshotFailed(true); // fall through to HTTP fallback+ };+ img.src = url;+ });++ return () => { cancelled = true; };+ }, [isSnapshotFrame, snapshotFailed, debouncedFrame?.filePath, debouncedFrame?.frameId, getVideoUrl]);// Fallback: ffmpeg <img> mode (same as old behavior)+ // Skipped for snapshot frames that loaded successfully via asset protocolconst fallbackImageUrl = useMemo(() => {if (useVideoMode || !debouncedFrame) return null;+ if (isSnapshotFrame && !snapshotFailed) return null;return `http://localhost:3030/frames/${debouncedFrame.frameId}`;- }, [useVideoMode, debouncedFrame]);+ }, [useVideoMode, debouncedFrame, isSnapshotFrame, snapshotFailed]);// Preload fallback image — only swap displayed URL when the new image loads successfullyuseEffect(() => {@@ -551,12 +609,12 @@ export const CurrentFrameTimeline: FC<CurrentFrameTimelineProps> = ({return () => observer.disconnect();}, [naturalDimensions]);- // Re-enable video mode when navigating to a non-failed chunk+ // Re-enable video mode when navigating to a non-failed video chunkuseEffect(() => {- if (debouncedFrame?.filePath && !isChunkFailed(debouncedFrame.filePath)) {+ if (debouncedFrame?.filePath && !isChunkFailed(debouncedFrame.filePath) && !isSnapshotFrame) {setUseVideoMode(true);}- }, [debouncedFrame?.filePath]);+ }, [debouncedFrame?.filePath, isSnapshotFrame]);if (!frameId) {return (@@ -695,8 +753,20 @@ export const CurrentFrameTimeline: FC<CurrentFrameTimelineProps> = ({}}/>- {/* Fallback mode: preloaded <img> layered on top of video */}- {displayedFallbackUrl && !useVideoMode && (+ {/* Snapshot frame: direct local file via asset protocol — no HTTP/DB needed */}+ {snapshotAssetUrl && isSnapshotFrame && !snapshotFailed && (+ // eslint-disable-next-line @next/next/no-img-element+ <img+ src={snapshotAssetUrl}+ className="absolute inset-0 w-full h-full object-contain"+ style={{ zIndex: 2 }}+ alt="Current frame"+ draggable={false}+ />+ )}++ {/* Fallback mode: preloaded <img> via HTTP server */}+ {displayedFallbackUrl && !useVideoMode && !(snapshotAssetUrl && isSnapshotFrame && !snapshotFailed) && (// eslint-disable-next-line @next/next/no-img-element<imgsrc={displayedFallbackUrl}diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex dad008cda..0fab58501 100755--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -8097,7 +8097,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.0.522"+version = "2.0.525"dependencies = ["anyhow","arboard",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex a2371beaf..93f86ebdc 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.524"+version = "2.0.525"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""