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: timeline navigation jumping back and reset button always disabled
Louis Beaumont5615a2303e31
diff --git a/screenpipe-app-tauri/components/rewind/timeline.tsx b/screenpipe-app-tauri/components/rewind/timeline.tsxindex 3c99a3100..bcf644089 100644--- a/screenpipe-app-tauri/components/rewind/timeline.tsx+++ b/screenpipe-app-tauri/components/rewind/timeline.tsx@@ -76,6 +76,9 @@ export default function Timeline() {setCurrentIndex(index);});+ // Flag to prevent frame-date sync from fighting with intentional navigation+ const isNavigatingRef = useRef(false);+// Re-show audio transcript when navigating timelineuseEffect(() => {setShowAudioTranscript(true);@@ -238,7 +241,14 @@ export default function Timeline() {checkIfThereAreFrames();}, [currentDate, websocket]); // Re-run when websocket connects or date changes+ // Sync currentDate to frame's date - but NOT during intentional navigation+ // This effect helps when scrolling across day boundaries, but must not fight+ // with explicit day changes from the controlsuseEffect(() => {+ // Skip if we're in the middle of intentional navigation+ if (isNavigatingRef.current) {+ return;+ }if (currentFrame) {const frameDate = new Date(currentFrame.timestamp);if (!isSameDay(frameDate, currentDate)) {@@ -375,31 +385,35 @@ export default function Timeline() {};const handleDateChange = async (newDate: Date) => {- const checkFramesForDate = await hasFramesForDate(newDate);+ // Set navigation flag to prevent frame-date sync from fighting+ isNavigatingRef.current = true;- if (!checkFramesForDate) {- let subDate;- if (isAfter(currentDate, newDate)) {- subDate = subDays(newDate, 1);- } else {- subDate = addDays(newDate, 1);- }+ try {+ const checkFramesForDate = await hasFramesForDate(newDate);- return await handleDateChange(subDate);- }+ if (!checkFramesForDate) {+ let subDate;+ if (isAfter(currentDate, newDate)) {+ subDate = subDays(newDate, 1);+ } else {+ subDate = addDays(newDate, 1);+ }++ // Limit recursion - don't go past start date+ if (isAfter(startAndEndDates.start, subDate)) {+ console.log("Reached start date boundary, stopping navigation");+ return;+ }++ return await handleDateChange(subDate);+ }- if (!hasDateBeenFetched(newDate)) {- setCurrentFrame(null);- const frameTimeStamp = new Date(newDate);- console.log(- frameTimeStamp.getDate() === new Date(currentDate).getDate(),- startAndEndDates.start.getDate(),- newDate.getDate(),- );- if (isSameDay(frameTimeStamp, new Date(currentDate))) {+ // Already on this day+ if (isSameDay(newDate, currentDate)) {return;}+ // Don't go before start dateif (isAfter(startAndEndDates.start, newDate)) {return;}@@ -410,15 +424,36 @@ export default function Timeline() {to_date: newDate.toISOString(),});+ // Clear frame first to prevent sync effect from reverting+ setCurrentFrame(null);+ setCurrentIndex(0);setCurrentDate(newDate);- } else {- jumpToTime(newDate);+ } finally {+ // Clear navigation flag after a short delay to let state settle+ setTimeout(() => {+ isNavigatingRef.current = false;+ }, 500);}};- const handleJumpToday = () => {- window.location.reload();- };+ const handleJumpToday = useCallback(async () => {+ const today = new Date();++ // Set navigation flag to prevent frame-date sync from fighting+ isNavigatingRef.current = true;++ try {+ // Clear current state+ setCurrentFrame(null);+ setCurrentIndex(0);+ setCurrentDate(today);+ } finally {+ // Clear navigation flag after state settles+ setTimeout(() => {+ isNavigatingRef.current = false;+ }, 500);+ }+ }, [setCurrentFrame, setCurrentDate]);const animateToIndex = (targetIndex: number, duration: number = 1000) => {const startIndex = currentIndex;diff --git a/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx b/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsxindex 0bc90f6bd..75a652665 100644--- a/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx+++ b/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx@@ -6,6 +6,7 @@ import {endOfDay,format,isAfter,+ isSameDay,startOfDay,subDays,} from "date-fns";@@ -51,20 +52,18 @@ export function TimelineControls({await onDateChange(newDate);};- // Disable forward button if we're at today+ // Disable forward button and jump-to-today if we're already at todayconst isAtToday = useMemo(- () => !isAfter(startOfDay(new Date()), startOfDay(currentDate)),+ () => isSameDay(new Date(), currentDate),[currentDate],);- const canGoBack = useMemo(- () =>- isAfter(- startOfDay(startAndEndDates.start),- startOfDay(subDays(currentDate, 1)),- ),- [startAndEndDates.start, currentDate],- );+ // Disable back button if we're at or before the earliest recorded date+ const isAtEarliestDate = useMemo(() => {+ const previousDay = subDays(currentDate, 1);+ // Disabled if previous day would be before the start date+ return isAfter(startOfDay(startAndEndDates.start), startOfDay(previousDay));+ }, [startAndEndDates.start, currentDate]);return (<div@@ -83,7 +82,7 @@ export function TimelineControls({size="icon"onClick={() => jumpDay(-1)}className="h-8 w-8 text-foreground hover:bg-foreground hover:text-background transition-colors duration-150"- disabled={canGoBack}+ disabled={isAtEarliestDate}><ChevronLeft className="h-4 w-4" /></Button>