Skip to content

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

fix(timeline): fix calendar navigation race conditions

Louis Beaumont1d85b39d2ab9
diff --git a/screenpipe-app-tauri/components/rewind/timeline.tsx b/screenpipe-app-tauri/components/rewind/timeline.tsx
index c2ecee6c7..573055f1b 100644
--- a/screenpipe-app-tauri/components/rewind/timeline.tsx
+++ b/screenpipe-app-tauri/components/rewind/timeline.tsx
@@ -272,8 +272,10 @@ export default function Timeline() {
// Auto-select first frame when frames arrive and no frame is selected
// Skip during intentional navigation (day change) to prevent double-jump
useEffect(() => {
- if (isNavigatingRef.current) {
- return; // Don't auto-select during navigation
+ // Don't auto-select during navigation OR if there's a pending navigation
+ // The pending navigation effect handles frame selection during navigation
+ if (isNavigatingRef.current || pendingNavigationRef.current) {
+ return;
}
if (!currentFrame && frames.length > 0) {
setCurrentFrame(frames[0]);
@@ -444,10 +446,9 @@ export default function Timeline() {
startTime.setHours(0, 0, 0, 0);
const endTime = new Date(currentDateEffect);
- if (endTime.getDate() === new Date().getDate()) {
- // For today: use current time so server can poll for real-time frames
- // Don't subtract 5 minutes - this was breaking live polling
- // (server checks if now <= end_time, which was always false)
+ if (isSameDay(endTime, new Date())) {
+ // For today: don't set endTime to end of day, leave it as current time
+ // so server can poll for real-time frames
} else {
endTime.setHours(23, 59, 59, 999);
}
diff --git a/screenpipe-app-tauri/lib/hooks/use-timeline-data.tsx b/screenpipe-app-tauri/lib/hooks/use-timeline-data.tsx
index 5c2890477..d4c8a49b4 100644
--- a/screenpipe-app-tauri/lib/hooks/use-timeline-data.tsx
+++ b/screenpipe-app-tauri/lib/hooks/use-timeline-data.tsx
@@ -22,12 +22,8 @@ export function useTimelineData(
connectWebSocket();
}, []); // Only connect once when component mounts
- // Set initial frame when frames arrive and no frame is selected yet
- useEffect(() => {
- if (frames.length > 0) {
- setCurFrame(frames[0]);
- }
- }, [frames.length > 0]); // Only trigger when we go from 0 to some frames
+ // NOTE: Auto-select of first frame is handled in timeline.tsx to avoid
+ // interfering with calendar navigation. Don't add frame selection here.
return {
frames,