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(ui): click-to-jump on timeline, auto-clear selection, fix calendar

Louis Beaumont0b3c1a2abd59
diff --git a/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx b/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx
index c4ca84952..1b2e5d610 100644
--- a/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx
+++ b/screenpipe-app-tauri/components/rewind/timeline/timeline-controls.tsx
@@ -98,9 +98,9 @@ export function TimelineControls({
<Popover open={calendarOpen} onOpenChange={setCalendarOpen}>
<PopoverTrigger asChild>
- <Button
- variant="ghost"
- className="px-3 h-8 text-sm font-mono text-foreground min-w-[100px] text-center hover:bg-foreground hover:text-background transition-colors duration-150"
+ <button
+ type="button"
+ className="px-3 h-8 text-sm font-mono text-foreground min-w-[100px] text-center hover:bg-foreground hover:text-background transition-colors duration-150 flex items-center justify-center"
>
<AnimatePresence mode="wait">
<motion.div
@@ -120,7 +120,7 @@ export function TimelineControls({
{format(currentDate, "d MMM yyyy")}
</motion.div>
</AnimatePresence>
- </Button>
+ </button>
</PopoverTrigger>
<PopoverContent
className="w-auto p-0 z-[200]"
diff --git a/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx b/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
index f86cd019f..0bf07f5b5 100644
--- a/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
+++ b/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
@@ -69,6 +69,7 @@ export const TimelineSlider = ({
const [hoveredTimestamp, setHoveredTimestamp] = useState<string | null>(null);
const [isDragging, setIsDragging] = useState(false);
const [dragStartIndex, setDragStartIndex] = useState<number | null>(null);
+ const [hasDragMoved, setHasDragMoved] = useState(false); // Track if mouse moved during drag
const [selectedIndices, setSelectedIndices] = useState<Set<number>>(
new Set(),
);
@@ -326,17 +327,50 @@ export const TimelineSlider = ({
}
}, [selectionRange]);
+ // Clear selection when user scrolls/navigates away from the selected range
+ useEffect(() => {
+ if (!selectionRange || selectedIndices.size === 0 || !frames.length) return;
+
+ // Check if current frame is still within or near the selection
+ const currentFrame = frames[currentIndex];
+ if (!currentFrame) return;
+
+ const currentTime = new Date(currentFrame.timestamp).getTime();
+ const selectionStart = selectionRange.start.getTime();
+ const selectionEnd = selectionRange.end.getTime();
+
+ // Allow some buffer (30 seconds) outside selection before clearing
+ const buffer = 30000;
+ const isNearSelection =
+ currentTime >= selectionStart - buffer &&
+ currentTime <= selectionEnd + buffer;
+
+ if (!isNearSelection) {
+ setSelectionRange(null);
+ setSelectedIndices(new Set());
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [currentIndex, frames.length]);
+
const handleDragStart = (index: number) => {
setIsDragging(true);
setDragStartIndex(index);
- setSelectedIndices(new Set([index]));
-
- const startDate = new Date(frames[index].timestamp);
- setSelectionRange({ start: startDate, end: startDate, frameIds: [] });
+ setHasDragMoved(false); // Reset movement tracking
+ // Don't set selection immediately - wait for movement
};
const handleDragOver = (index: number) => {
if (isDragging && dragStartIndex !== null && frames && frames.length > 0) {
+ // Check if we've actually moved to a different frame
+ if (index !== dragStartIndex) {
+ setHasDragMoved(true); // Mark that mouse has moved during drag
+ }
+
+ // Only create selection if we've moved
+ if (!hasDragMoved && index === dragStartIndex) {
+ return; // No movement yet, don't create selection
+ }
+
const start = Math.min(dragStartIndex, index);
const end = Math.max(dragStartIndex, index);
const newSelection = new Set<number>();
@@ -367,14 +401,21 @@ export const TimelineSlider = ({
};
const handleDragEnd = () => {
- // Track selection if multiple frames were selected
- if (selectedIndices.size > 1) {
+ // If no movement during drag, this was a click - jump to that frame
+ if (!hasDragMoved && dragStartIndex !== null) {
+ onFrameChange(dragStartIndex);
+ // Don't create selection for clicks
+ setSelectedIndices(new Set());
+ setSelectionRange(null);
+ } else if (selectedIndices.size > 1) {
+ // Track selection if multiple frames were selected
posthog.capture("timeline_selection_made", {
frames_selected: selectedIndices.size,
});
}
setIsDragging(false);
setDragStartIndex(null);
+ setHasDragMoved(false);
};
// Calculate group width for positioning labels