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
release-app extend rewind timeline to 7 days
Louis Beaumont127e7c3f44c9
diff --git a/pipes/rewind/src/app/page.tsx b/pipes/rewind/src/app/page.tsxindex 7a3c0aa5a..120e7deea 100644--- a/pipes/rewind/src/app/page.tsx+++ b/pipes/rewind/src/app/page.tsx@@ -8,6 +8,7 @@ import { TimelineProvider } from "@/lib/hooks/use-timeline-selection";import { throttle } from "lodash";import { AGENTS } from "@/components/timeline/agents";import { TimelineSelection } from "@/components/timeline/timeline-selection";+import { TimelineControls } from "@/components/timeline/timeline-controls";export interface StreamTimeSeriesResponse {timestamp: string;@@ -63,6 +64,7 @@ export default function Timeline() {x: 0,y: 0,});+ const [currentDate, setCurrentDate] = useState(new Date());useEffect(() => {setPosition({@@ -78,8 +80,9 @@ export default function Timeline() {const endTime = new Date();endTime.setMinutes(endTime.getMinutes() - 2);- const startTime = new Date();- startTime.setHours(0, 1, 0, 0);++ const startTime = new Date(endTime);+ startTime.setDate(startTime.getDate() - 7);const url = `http://localhost:3030/stream/frames?start_time=${startTime.toISOString()}&end_time=${endTime.toISOString()}&order=descending`;@@ -312,6 +315,98 @@ export default function Timeline() {};}, [handleScroll]);+ const jumpToDate = (targetDate: Date) => {+ // Find the closest frame to the target date+ if (frames.length === 0) return;++ const targetTime = targetDate.getTime();+ let closestIndex = 0;+ let closestDiff = Infinity;++ frames.forEach((frame, index) => {+ const frameTime = new Date(frame.timestamp).getTime();+ const diff = Math.abs(frameTime - targetTime);+ if (diff < closestDiff) {+ closestDiff = diff;+ closestIndex = index;+ }+ });++ // Update cursor position+ setCurrentIndex(closestIndex);+ if (frames[closestIndex]) {+ setCurrentFrame(frames[closestIndex].devices[0]);+ setCurrentDate(new Date(frames[closestIndex].timestamp));+ }+ };++ const handleDateChange = (newDate: Date) => {+ // Ensure we're comparing dates at start of day+ const targetStartOfDay = new Date(+ newDate.getFullYear(),+ newDate.getMonth(),+ newDate.getDate(),+ 0,+ 0,+ 0,+ 0+ );++ let closestIndex = 0;+ let closestDiff = Infinity;++ frames.forEach((frame, index) => {+ const frameDate = new Date(frame.timestamp);+ const frameStartOfDay = new Date(+ frameDate.getFullYear(),+ frameDate.getMonth(),+ frameDate.getDate(),+ 0,+ 0,+ 0,+ 0+ );++ const diff = Math.abs(+ frameStartOfDay.getTime() - targetStartOfDay.getTime()+ );+ if (diff < closestDiff) {+ closestDiff = diff;+ closestIndex = index;+ }+ });++ setCurrentIndex(closestIndex);+ if (frames[closestIndex]) {+ setCurrentFrame(frames[closestIndex].devices[0]);+ }+ };++ const handleJumpToday = () => {+ jumpToDate(new Date());+ };++ // More explicit date handling+ useEffect(() => {+ if (frames[currentIndex]) {+ const frameTimestamp = frames[currentIndex].timestamp;+ const frameDate = new Date(frameTimestamp);++ // Force date to start of day to avoid timezone issues+ const localDate = new Date(+ frameDate.getFullYear(),+ frameDate.getMonth(),+ frameDate.getDate(),+ 0,+ 0,+ 0,+ 0+ );++ setCurrentDate(localDate);+ }+ }, [currentIndex, frames]);+return (<TimelineProvider><div@@ -326,12 +421,14 @@ export default function Timeline() {msUserSelect: "none",}}>- <button- onClick={handleRefresh}- className="absolute top-4 right-4 p-2 text-foreground hover:text-foreground/70 bg-background rounded border border-muted-foreground hover:border-foreground/50 transition-colors z-50"- >- <RotateCcw className="h-4 w-4" />- </button>+ <div className="absolute top-4 left-1/2 -translate-x-1/2 z-50">+ <TimelineControls+ currentDate={currentDate}+ onDateChange={handleDateChange}+ onJumpToday={handleJumpToday}+ className="shadow-lg"+ />+ </div><div className="flex-1 relative min-h-0">{isLoading && (@@ -371,7 +468,7 @@ export default function Timeline() {{currentFrame && (<imgsrc={`data:image/png;base64,${currentFrame.frame}`}- className="absolute inset-0 w-4/5 h-auto max-h-[75vh] object-contain mx-auto border rounded-xl p-2 mt-2"+ className="absolute inset-0 w-4/5 h-auto max-h-[75vh] object-contain mx-auto border rounded-xl p-2 mt-20"alt="Current frame"/>)}@@ -435,28 +532,26 @@ export default function Timeline() {)}<div className="relative mt-1 px-2 text-[10px] text-muted-foreground select-none">- {Array(7)+ {Array(8).fill(0).map((_, i) => {if (!loadedTimeRange) return null;- const totalMinutes =- (loadedTimeRange.end.getTime() -- loadedTimeRange.start.getTime()) /- (1000 * 60);- const minutesPerStep = totalMinutes / 6;+ const totalDays = 7;+ const daysPerStep = totalDays / 7;const date = new Date(loadedTimeRange.start.getTime() +- i * minutesPerStep * 60 * 1000+ i * daysPerStep * 24 * 60 * 60 * 1000);return (<divkey={i}className="absolute transform -translate-x-1/2"- style={{ left: `${(i * 100) / 6}%` }}+ style={{ left: `${(i * 100) / 7}%` }}>- {date.toLocaleTimeString([], {- hour: "2-digit",- minute: "2-digit",+ {date.toLocaleDateString([], {+ weekday: "short",+ month: "short",+ day: "numeric",})}</div>);diff --git a/pipes/rewind/src/components/timeline/timeline-controls.tsx b/pipes/rewind/src/components/timeline/timeline-controls.tsxnew file mode 100644index 000000000..494a9cbed--- /dev/null+++ b/pipes/rewind/src/components/timeline/timeline-controls.tsx@@ -0,0 +1,96 @@+"use client";+import { Button } from "@/components/ui/button";+import { ChevronLeft, ChevronRight, RefreshCw } from "lucide-react";+import { format, isAfter, startOfDay } from "date-fns";+import { cn } from "@/lib/utils";+import { motion, AnimatePresence } from "framer-motion";++interface TimelineControlsProps {+ currentDate: Date;+ onDateChange: (date: Date) => void;+ onJumpToday: () => void;+ className?: string;+}++export function TimelineControls({+ currentDate,+ onDateChange,+ onJumpToday,+ className,+}: TimelineControlsProps) {+ const today = startOfDay(new Date());++ const jumpDay = (days: number) => {+ const newDate = new Date(currentDate);+ newDate.setDate(newDate.getDate() + days);++ // Prevent jumping to future dates+ if (isAfter(newDate, today)) {+ onDateChange(today);+ return;+ }++ onDateChange(newDate);+ };++ // Disable forward button if we're at today+ const isAtToday = startOfDay(currentDate).getTime() === today.getTime();++ return (+ <div+ className={cn(+ "flex items-center gap-2 p-2 bg-muted/50 rounded-md",+ className+ )}+ >+ <Button+ variant="ghost"+ size="icon"+ onClick={() => jumpDay(-1)}+ className="h-8 w-8"+ >+ <ChevronLeft className="h-4 w-4" />+ </Button>++ <AnimatePresence mode="wait">+ <motion.div+ key={currentDate.toISOString()}+ initial={{ y: -20, opacity: 0 }}+ animate={{ y: 0, opacity: 1 }}+ exit={{ y: 20, opacity: 0 }}+ transition={{+ type: "spring",+ stiffness: 500,+ damping: 30,+ duration: 0.2,+ }}+ className="bg-background border rounded px-3 py-1 text-sm font-mono"+ >+ {format(currentDate, "d MMM yyyy")}+ </motion.div>+ </AnimatePresence>++ <Button+ variant="ghost"+ size="icon"+ onClick={() => jumpDay(1)}+ className="h-8 w-8"+ disabled={isAtToday}+ >+ <ChevronRight className="h-4 w-4" />+ </Button>++ <div className="h-4 w-px bg-border mx-2" />++ <Button+ variant="ghost"+ size="icon"+ onClick={onJumpToday}+ className="h-8 w-8"+ disabled={isAtToday}+ >+ <RefreshCw className="h-4 w-4" />+ </Button>+ </div>+ );+}diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 7a4e1ec52..1f1755d55 100644--- a/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.26.7"+version = "0.26.8"description = ""authors = ["you"]license = ""diff --git a/screenpipe-server/src/video_cache.rs b/screenpipe-server/src/video_cache.rsindex 6f7113178..963fff297 100644--- a/screenpipe-server/src/video_cache.rs+++ b/screenpipe-server/src/video_cache.rs@@ -121,9 +121,9 @@ impl Default for CacheConfig {fn default() -> Self {Self {cache_dir: PathBuf::from("frame_cache"),- max_cache_size_gb: 3.0,- frame_retention_days: 1,- compression_quality: 50,+ max_cache_size_gb: 10.0,+ frame_retention_days: 7,+ compression_quality: 35,}}}@@ -654,8 +654,12 @@ async fn extract_frame(let temp_dir = tempfile::tempdir()?;let output_pattern = temp_dir.path().join("frame%d.jpg");- // Calculate frame interval based on target FPS- let frame_interval = (source_fps / 0.1).round() as i64; // Using 0.1 as target FPS+ // Reduce frame rate even further for older content+ let frame_interval = if is_older_than_24h(&tasks[0].0.timestamp) {+ (source_fps / 0.05).round() as i64 // 1 frame every 20 seconds for older content+ } else {+ (source_fps / 0.1).round() as i64 // 1 frame every 10 seconds for recent content+ };debug!("extracting frames with interval {} (source: {}fps, target: {}fps)",@@ -688,21 +692,23 @@ async fn extract_frame("-i",&video_file_path,"-vf",- &format!("{},format=yuv420p,scale=iw:ih", select_filter),+ &format!("{},format=yuv420p,scale=iw*0.8:ih*0.8", select_filter),"-strict","unofficial","-c:v","mjpeg","-q:v",- "8",+ "12","-qmin",- "8",- "-qmax","12",+ "-qmax",+ "15","-vsync","0","-threads",- "2",+ "1", // Limit to single thread+ "-cpu-used", // Faster encoding+ "4",output_pattern.to_str().unwrap(),]);@@ -991,3 +997,7 @@ async fn get_video_fps(ffmpeg_path: &PathBuf, video_path: &str) -> Result<f64> {debug!("detected fps from video metadata: {}", fps);Ok(fps)}++fn is_older_than_24h(timestamp: &DateTime<Utc>) -> bool {+ Utc::now() - *timestamp > Duration::hours(24)+}