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): disable empty days in calendar picker + skip them on arrow nav
Louis Beaumont7a0db84b9ff6
diff --git a/apps/screenpipe-app-tauri/components/rewind/hooks/use-date-navigation.ts b/apps/screenpipe-app-tauri/components/rewind/hooks/use-date-navigation.tsindex 24339e03c..4198fd83f 100644--- a/apps/screenpipe-app-tauri/components/rewind/hooks/use-date-navigation.ts+++ b/apps/screenpipe-app-tauri/components/rewind/hooks/use-date-navigation.ts@@ -10,7 +10,11 @@ import { useKeywordSearchStore } from "@/lib/hooks/use-keyword-search-store";import posthog from "posthog-js";import type { StreamTimeSeriesResponse } from "@/components/rewind/timeline";-const MAX_DATE_RETRIES = 7; // Don't walk back more than 7 days+// How far the arrow keys walk past empty days. The underlying SQL uses+// the timestamp index (O(log n)) so a wider window costs nothing. 7 was+// too tight — users with >7 day recording gaps would dead-end on the+// arrow and have to use the calendar instead.+const MAX_DATE_RETRIES = 365;export function useDateNavigation(opts: {frames: StreamTimeSeriesResponse[];diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsxindex 201ba97c5..504399ed2 100644--- a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx@@ -14,10 +14,11 @@ import {subDays,} from "date-fns";import { cn } from "@/lib/utils";-import { useMemo, useState } from "react";+import { useEffect, useMemo, useState } from "react";import { usePlatform } from "@/lib/hooks/use-platform";import { useSettings } from "@/lib/hooks/use-settings";import { Calendar } from "@/components/ui/calendar";+import { listDaysWithFrames } from "@/lib/actions/has-frames-date";import {Popover,PopoverContent,@@ -132,6 +133,22 @@ export function TimelineControls({const { isMac } = usePlatform();const { settings } = useSettings();const [calendarOpen, setCalendarOpen] = useState(false);++ // Set of "YYYY-MM-DD" local-day strings that have at least one frame.+ // Used to grey out empty days in the calendar picker so users don't+ // click a blank day and see an empty timeline. Refreshes whenever the+ // popover opens, so newly-recorded frames register without a reload.+ const [daysWithFrames, setDaysWithFrames] = useState<Set<string>>(new Set());+ useEffect(() => {+ if (!calendarOpen) return;+ let cancelled = false;+ listDaysWithFrames().then((s) => {+ if (!cancelled) setDaysWithFrames(s);+ });+ return () => {+ cancelled = true;+ };+ }, [calendarOpen]);const searchShortcutDisplay = useMemo(() => formatShortcutForDisplay(settings.searchShortcut || (isMac ? "Control+Super+K" : "Alt+K"), isMac),[settings.searchShortcut, isMac]@@ -223,10 +240,19 @@ export function TimelineControls({setCalendarOpen(false);}}}- disabled={(date) =>- isAfter(startOfDay(date), startOfDay(new Date())) ||- isAfter(startOfDay(startAndEndDates.start), startOfDay(date))- }+ disabled={(date) => {+ const day = startOfDay(date);+ // Future dates and dates before the user's earliest+ // recording always disabled.+ if (isAfter(day, startOfDay(new Date()))) return true;+ if (isAfter(startOfDay(startAndEndDates.start), day)) return true;+ // Empty days disabled IF we've loaded the day set.+ // Skip the check on first render (set is empty)+ // so the picker is functional during the brief+ // fetch window.+ if (daysWithFrames.size === 0) return false;+ return !daysWithFrames.has(format(date, "yyyy-MM-dd"));+ }}/></PopoverContent></Popover>diff --git a/apps/screenpipe-app-tauri/lib/actions/has-frames-date.ts b/apps/screenpipe-app-tauri/lib/actions/has-frames-date.tsindex bbcafb587..8a4b57be1 100644--- a/apps/screenpipe-app-tauri/lib/actions/has-frames-date.ts+++ b/apps/screenpipe-app-tauri/lib/actions/has-frames-date.ts@@ -5,6 +5,40 @@import { isSameDay } from "date-fns";import { localFetch } from "@/lib/api";+/**+ * List the local-calendar days that have at least one frame in the DB.+ *+ * Returns a Set of "YYYY-MM-DD" local-day strings. Used by the timeline+ * calendar picker to disable empty days, and by future "skip empty days"+ * logic that wants to know the full set rather than walk one-by-one.+ *+ * SQL groups by `DATE(timestamp, 'localtime')` so days are returned in+ * the user's local timezone — matches what `format(date, "yyyy-MM-dd")`+ * produces in the UI. Without this conversion a UTC-stored timestamp+ * just past midnight could be reported on the wrong calendar day.+ */+export async function listDaysWithFrames(): Promise<Set<string>> {+ try {+ const query = `+ SELECT DISTINCT DATE(timestamp, 'localtime') AS day+ FROM frames+ WHERE timestamp IS NOT NULL+ ORDER BY day+ `;+ const response = await localFetch("/raw_sql", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ query }),+ });+ if (!response.ok) return new Set();+ const rows = (await response.json()) as Array<{ day: string }>;+ return new Set(rows.map((r) => r.day).filter(Boolean));+ } catch (e) {+ console.error("listDaysWithFrames failed:", e);+ return new Set();+ }+}+export async function hasFramesForDate(date: Date): Promise<boolean> {try {// Set up start and end of the day