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(ui): improve timeline UX with monochrome design and consolidated search
Louis Beaumonte4a41f03bf5c
diff --git a/screenpipe-app-tauri/components/rewind/search-modal.tsx b/screenpipe-app-tauri/components/rewind/search-modal.tsxdeleted file mode 100644index 8dde6255d..000000000--- a/screenpipe-app-tauri/components/rewind/search-modal.tsx+++ /dev/null@@ -1,432 +0,0 @@-"use client";--import { useEffect, useState, useRef, useCallback, useMemo } from "react";-import { Search, X, Loader2, Mic, ArrowRight, MessageSquare } from "lucide-react";-import { useKeywordSearchStore, SearchMatch } from "@/lib/hooks/use-keyword-search-store";-import { useDebounce } from "@/lib/hooks/use-debounce";-import { format, subDays, startOfDay, endOfDay, isToday, isYesterday } from "date-fns";-import { emit } from "@tauri-apps/api/event";-import { commands } from "@/lib/utils/tauri";--interface SearchModalProps {- isOpen: boolean;- onClose: () => void;- onNavigateToTimestamp: (timestamp: string) => void;-}--interface ParsedQuery {- keywords: string[];- app?: string;- timeRange?: { start: Date; end: Date };- timeLabel?: string;-}--// Parse natural language query into structured filters-function parseQuery(query: string): ParsedQuery {- const result: ParsedQuery = { keywords: [] };- const words = query.toLowerCase().split(/\s+/).filter(Boolean);- const keywordWords: string[] = [];-- for (const word of words) {- // Time filters- if (word === "today") {- result.timeRange = { start: startOfDay(new Date()), end: endOfDay(new Date()) };- result.timeLabel = "today";- } else if (word === "yesterday") {- const yesterday = subDays(new Date(), 1);- result.timeRange = { start: startOfDay(yesterday), end: endOfDay(yesterday) };- result.timeLabel = "yesterday";- } else if (word === "week" || word === "this-week") {- result.timeRange = { start: subDays(new Date(), 7), end: new Date() };- result.timeLabel = "this week";- }- // App filters (common apps)- else if (["slack", "discord", "teams", "zoom", "chrome", "safari", "firefox", "vscode", "code", "notion", "figma", "terminal", "iterm"].includes(word)) {- result.app = word === "code" ? "Visual Studio Code" : word.charAt(0).toUpperCase() + word.slice(1);- }- // Explicit app filter with @- else if (word.startsWith("@")) {- result.app = word.slice(1).charAt(0).toUpperCase() + word.slice(2);- }- // Regular keyword- else {- keywordWords.push(word);- }- }-- result.keywords = keywordWords;- return result;-}--// Highlight matched text in a string-function highlightMatch(text: string, keywords: string[]): React.ReactNode {- if (!keywords.length || !text) return text;-- const pattern = new RegExp(`(${keywords.map(k => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})`, 'gi');- const parts = text.split(pattern);-- return parts.map((part, i) => {- const isMatch = keywords.some(k => part.toLowerCase() === k.toLowerCase());- return isMatch ? (- <span key={i} className="bg-foreground/20 text-foreground font-medium">{part}</span>- ) : (- <span key={i}>{part}</span>- );- });-}--// Format relative time-function formatRelativeTime(timestamp: string): string {- const date = new Date(timestamp);- const time = format(date, "h:mm a");-- if (isToday(date)) return time;- if (isYesterday(date)) return `yesterday ${time}`;- return format(date, "MMM d") + " " + time;-}--// Group results by date-function groupResultsByDate(results: SearchMatch[]): { label: string; results: SearchMatch[] }[] {- const groups: Map<string, SearchMatch[]> = new Map();-- for (const result of results) {- const date = new Date(result.timestamp);- let label: string;-- if (isToday(date)) {- label = "today";- } else if (isYesterday(date)) {- label = "yesterday";- } else {- label = format(date, "EEEE, MMM d");- }-- if (!groups.has(label)) {- groups.set(label, []);- }- groups.get(label)!.push(result);- }-- return Array.from(groups.entries()).map(([label, results]) => ({ label, results }));-}--export function SearchModal({ isOpen, onClose, onNavigateToTimestamp }: SearchModalProps) {- const [query, setQuery] = useState("");- const [selectedIndex, setSelectedIndex] = useState(0);- const [recentSearches, setRecentSearches] = useState<string[]>([]);- const inputRef = useRef<HTMLInputElement>(null);- const listRef = useRef<HTMLDivElement>(null);-- const debouncedQuery = useDebounce(query, 200);- const parsedQuery = useMemo(() => parseQuery(debouncedQuery), [debouncedQuery]);-- const {- searchResults,- isSearching,- searchKeywords,- resetSearch,- } = useKeywordSearchStore();-- // Load recent searches from localStorage- useEffect(() => {- const saved = localStorage.getItem("recentSearches");- if (saved) {- try {- setRecentSearches(JSON.parse(saved).slice(0, 5));- } catch {- // ignore- }- }- }, []);-- // Save search to recent- const saveToRecent = useCallback((searchQuery: string) => {- if (!searchQuery.trim()) return;- const updated = [searchQuery, ...recentSearches.filter(s => s !== searchQuery)].slice(0, 5);- setRecentSearches(updated);- localStorage.setItem("recentSearches", JSON.stringify(updated));- }, [recentSearches]);-- // Focus input when modal opens- useEffect(() => {- if (isOpen && inputRef.current) {- inputRef.current.focus();- setSelectedIndex(0);- }- }, [isOpen]);-- // Perform search when query changes- useEffect(() => {- if (!debouncedQuery.trim()) {- resetSearch();- return;- }-- const keywords = parsedQuery.keywords.join(" ");- if (!keywords) {- resetSearch();- return;- }-- searchKeywords(keywords, {- limit: 20,- start_time: parsedQuery.timeRange?.start,- end_time: parsedQuery.timeRange?.end,- app_names: parsedQuery.app ? [parsedQuery.app] : undefined,- });- }, [debouncedQuery, parsedQuery, searchKeywords, resetSearch]);-- // Keyboard navigation- useEffect(() => {- if (!isOpen) return;-- const handleKeyDown = (e: KeyboardEvent) => {- switch (e.key) {- case "Escape":- onClose();- break;- case "ArrowDown":- e.preventDefault();- setSelectedIndex(i => Math.min(i + 1, searchResults.length - 1));- break;- case "ArrowUp":- e.preventDefault();- setSelectedIndex(i => Math.max(i - 1, 0));- break;- case "Enter":- e.preventDefault();- if (e.metaKey || e.ctrlKey) {- // Send to AI chat- handleSendToAI();- } else if (searchResults[selectedIndex]) {- // Navigate to timestamp- handleSelectResult(searchResults[selectedIndex]);- }- break;- }- };-- window.addEventListener("keydown", handleKeyDown);- return () => window.removeEventListener("keydown", handleKeyDown);- }, [isOpen, searchResults, selectedIndex, onClose]);-- // Scroll selected item into view- useEffect(() => {- if (listRef.current && searchResults.length > 0) {- const selectedEl = listRef.current.querySelector(`[data-index="${selectedIndex}"]`);- selectedEl?.scrollIntoView({ block: "nearest" });- }- }, [selectedIndex, searchResults.length]);-- const handleSelectResult = useCallback((result: SearchMatch) => {- saveToRecent(query);- onNavigateToTimestamp(result.timestamp);- onClose();- }, [query, saveToRecent, onNavigateToTimestamp, onClose]);-- const handleSendToAI = useCallback(async () => {- const result = searchResults[selectedIndex];- if (!result) return;-- saveToRecent(query);-- // Build context for AI chat- const context = `Context from search result:\n${result.app_name} - ${result.window_name}\nTime: ${format(new Date(result.timestamp), "PPpp")}\n\nText:\n${result.text}`;-- // Open AI chat window with context (no pre-filled prompt - let user ask anything)- await commands.showWindow("Chat");- await emit("chat-prefill", {- context,- });-- onClose();- }, [searchResults, selectedIndex, query, saveToRecent, onClose]);-- const handleRecentClick = useCallback((recent: string) => {- setQuery(recent);- inputRef.current?.focus();- }, []);-- if (!isOpen) return null;-- const groupedResults = groupResultsByDate(searchResults);- const hasResults = searchResults.length > 0;- const showEmpty = !isSearching && debouncedQuery && !hasResults;- const showRecent = !debouncedQuery && recentSearches.length > 0;-- return (- <div className="fixed inset-0 z-50 flex items-start justify-center pt-[15vh]">- {/* Backdrop */}- <div- className="absolute inset-0 bg-black/60 backdrop-blur-sm"- onClick={onClose}- />-- {/* Modal */}- <div className="relative w-full max-w-xl mx-4 bg-card border border-border shadow-2xl overflow-hidden">- {/* Search Input */}- <div className="flex items-center gap-3 px-4 py-3 border-b border-border">- <Search className="w-4 h-4 text-muted-foreground flex-shrink-0" />- <input- ref={inputRef}- type="text"- value={query}- onChange={(e) => setQuery(e.target.value)}- placeholder="Search your memory..."- className="flex-1 bg-transparent text-foreground placeholder:text-muted-foreground text-sm outline-none"- autoComplete="off"- autoCorrect="off"- autoCapitalize="off"- spellCheck={false}- />- {isSearching && <Loader2 className="w-4 h-4 text-muted-foreground animate-spin" />}- {query && (- <button- onClick={() => setQuery("")}- className="p-1 hover:bg-muted rounded"- >- <X className="w-3 h-3 text-muted-foreground" />- </button>- )}- </div>-- {/* Parsed query indicator */}- {debouncedQuery && (parsedQuery.app || parsedQuery.timeLabel) && (- <div className="px-4 py-2 text-xs text-muted-foreground border-b border-border bg-muted/30">- → {parsedQuery.keywords.length > 0 && `"${parsedQuery.keywords.join(" ")}"`}- {parsedQuery.app && <span className="ml-1">in {parsedQuery.app}</span>}- {parsedQuery.timeLabel && <span className="ml-1">· {parsedQuery.timeLabel}</span>}- </div>- )}-- {/* Results */}- <div- ref={listRef}- className="max-h-[50vh] overflow-y-auto"- onWheel={(e) => e.stopPropagation()}- >- {/* Recent searches */}- {showRecent && (- <div className="p-3">- <div className="text-xs font-medium text-muted-foreground mb-2">recent</div>- <div className="space-y-1">- {recentSearches.map((recent, i) => (- <button- key={i}- onClick={() => handleRecentClick(recent)}- className="w-full text-left px-2 py-1.5 text-sm text-foreground hover:bg-muted rounded transition-colors"- >- {recent}- </button>- ))}- </div>- <div className="mt-4 text-xs text-muted-foreground">- <span className="opacity-60">tips:</span> "slack yesterday" · "@zoom meeting" · "budget today"- </div>- </div>- )}-- {/* Empty state */}- {showEmpty && (- <div className="p-8 text-center text-sm text-muted-foreground">- no results for "{debouncedQuery}"- </div>- )}-- {/* Results count */}- {hasResults && (- <div className="px-4 py-2 text-xs text-muted-foreground border-b border-border">- {searchResults.length} result{searchResults.length !== 1 ? "s" : ""}- </div>- )}-- {/* Grouped results */}- {groupedResults.map((group) => (- <div key={group.label}>- <div className="px-4 py-1.5 text-[10px] font-medium text-muted-foreground uppercase tracking-wider bg-muted/30">- {group.label}- </div>- {group.results.map((result) => {- const globalIndex = searchResults.indexOf(result);- const isSelected = globalIndex === selectedIndex;- const isAudio = result.text?.includes("[audio]") || result.window_name?.toLowerCase().includes("zoom") || result.window_name?.toLowerCase().includes("meet");-- return (- <div- key={result.frame_id}- data-index={globalIndex}- onClick={() => handleSelectResult(result)}- className={`- px-4 cursor-pointer transition-all border-b border-border/50 group/result- ${isSelected ? "bg-foreground/10 py-3" : "hover:bg-muted/50 py-2"}- `}- >- <div className="flex items-start gap-3">- {/* App icon */}- <img- src={`http://localhost:11435/app-icon?name=${encodeURIComponent(result.app_name)}`}- className="w-5 h-5 rounded flex-shrink-0 opacity-80"- alt=""- onError={(e) => {- e.currentTarget.style.display = 'none';- }}- />-- {/* Time */}- <div className="flex-shrink-0 w-14 text-xs font-mono text-muted-foreground">- {format(new Date(result.timestamp), "h:mm a")}- </div>-- {/* App name */}- <div className="flex-shrink-0 w-24 flex items-center gap-1">- {isAudio && <Mic className="w-3 h-3 text-green-400 flex-shrink-0" />}- <span className="text-xs font-medium text-foreground truncate">- {result.app_name}- </span>- </div>-- {/* Matched text - expand on select */}- <div className="flex-1 min-w-0">- <p className={`text-sm text-muted-foreground ${isSelected ? "" : "truncate"}`}>- {highlightMatch(- isSelected- ? (result.text?.slice(0, 300) || result.window_name || "")- : (result.text?.slice(0, 80) || result.window_name || ""),- parsedQuery.keywords- )}- {isSelected && result.text && result.text.length > 300 && "..."}- </p>- {/* Window name on expanded view */}- {isSelected && result.window_name && (- <p className="text-xs text-muted-foreground/60 mt-1 truncate">- {result.window_name}- </p>- )}- </div>-- {/* Arrow indicator for selected */}- <ArrowRight className={`w-4 h-4 flex-shrink-0 transition-opacity ${isSelected ? "text-foreground opacity-100" : "text-muted-foreground opacity-0 group-hover/result:opacity-50"}`} />- </div>- </div>- );- })}- </div>- ))}- </div>-- {/* Footer with keyboard hints */}- <div className="px-4 py-2 border-t border-border bg-muted/30 flex items-center justify-between text-[10px] text-muted-foreground font-mono">- <div className="flex items-center gap-4">- <span>↑↓ navigate</span>- <span>⏎ go to timeline</span>- <span className="flex items-center gap-1">- <MessageSquare className="w-3 h-3" />- ⌘⏎ ask AI- </span>- </div>- <span>esc close</span>- </div>- </div>- </div>- );-}diff --git a/screenpipe-app-tauri/components/rewind/timeline.tsx b/screenpipe-app-tauri/components/rewind/timeline.tsxindex 0a62def83..86826f9bf 100644--- a/screenpipe-app-tauri/components/rewind/timeline.tsx+++ b/screenpipe-app-tauri/components/rewind/timeline.tsx@@ -1,9 +1,8 @@"use client";import { useEffect, useState, useRef, useMemo, useCallback } from "react";-import { Loader2, RotateCcw, AlertCircle, X, Search } from "lucide-react";+import { Loader2, RotateCcw, AlertCircle, X } from "lucide-react";import { commands } from "@/lib/utils/tauri";import { listen } from "@tauri-apps/api/event";-import { SearchModal } from "@/components/rewind/search-modal";import { AudioTranscript } from "@/components/rewind/timeline/audio-transcript";import { TimelineProvider } from "@/lib/hooks/use-timeline-selection";import { throttle } from "lodash";@@ -65,8 +64,7 @@ const easeOutCubic = (x: number): number => {export default function Timeline() {const [currentIndex, setCurrentIndex] = useState(0);const [showAudioTranscript, setShowAudioTranscript] = useState(true);- const [showSearchModal, setShowSearchModal] = useState(false);- const containerRef = useRef<HTMLDivElement | null>(null);+ const containerRef = useRef<HTMLDivElement | null>(null);// const [searchResults, setSearchResults] = useState<number[]>([]);const [startAndEndDates, setStartAndEndDates] = useState<TimeRange>({// Default to 1 year ago so navigation works even if getStartDate fails@@ -258,23 +256,22 @@ export default function Timeline() {posthog.capture("timeline_opened");}, []);- // Keyboard shortcut for search modal (/ or Cmd+K)+ // Keyboard shortcut for search window (/ or Cmd+K)useEffect(() => {const handleKeyDown = (e: KeyboardEvent) => {- // Don't trigger if already in an input or search modal is open- if (showSearchModal) return;+ // Don't trigger if already in an inputif (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;- // / key or Cmd+K+ // / key or Cmd+K - open search windowif (e.key === "/" || (e.key === "k" && (e.metaKey || e.ctrlKey))) {e.preventDefault();- setShowSearchModal(true);+ commands.openSearchWindow(null);}};window.addEventListener("keydown", handleKeyDown);return () => window.removeEventListener("keydown", handleKeyDown);- }, [showSearchModal]);+ }, []);useEffect(() => {const getStartDateAndSet = async () => {@@ -830,24 +827,6 @@ export default function Timeline() {</div></div>- {/* Search Modal */}- <SearchModal- isOpen={showSearchModal}- onClose={() => setShowSearchModal(false)}- onNavigateToTimestamp={(timestamp) => {- // Navigate to the timestamp- const targetDate = new Date(timestamp);- pendingNavigationRef.current = targetDate;- setSeekingTimestamp(timestamp);-- if (!isSameDay(targetDate, currentDate)) {- handleDateChange(targetDate);- } else {- jumpToTime(targetDate);- setSeekingTimestamp(null);- }- }}- /></div></TimelineProvider>);diff --git a/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx b/screenpipe-app-tauri/components/rewind/timeline/timeline.tsxindex 9fc73fccb..fe63e4f8d 100644--- a/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx+++ b/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx@@ -88,12 +88,24 @@ export const TimelineSlider = ({return () => cancelAnimationFrame(animationId);}, [zoomLevel, targetZoom]);+ // Track if we're in a zoom gesture to prevent simultaneous scrolling+ const isZoomingRef = useRef(false);+ const zoomTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);+// Handle pinch-to-zoom (trackpad) and Cmd+Scroll (mouse)const handleWheel = useCallback((e: WheelEvent) => {// Pinch gesture on trackpad sends ctrlKey=true// Cmd+Scroll on mouse sends metaKey=trueif (e.ctrlKey || e.metaKey) {e.preventDefault();+ e.stopPropagation();++ // Mark that we're zooming - this prevents scroll from happening+ isZoomingRef.current = true;+ if (zoomTimeoutRef.current) clearTimeout(zoomTimeoutRef.current);+ zoomTimeoutRef.current = setTimeout(() => {+ isZoomingRef.current = false;+ }, 150); // Debounce - wait 150ms after last zoom event// Calculate zoom delta (negative deltaY = zoom in)const zoomDelta = -e.deltaY * 0.008;@@ -102,7 +114,8 @@ export const TimelineSlider = ({const newZoom = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, prev * (1 + zoomDelta)));return newZoom;});- } else {+ } else if (!isZoomingRef.current) {+ // Only allow scroll when not in a zoom gesture// Regular scroll - speed scales inversely with zoom// When zoomed out (0.25), scroll moves 4x faster through frames// When zoomed in (4), scroll moves 0.25x slower@@ -385,9 +398,9 @@ export const TimelineSlider = ({animate={{ opacity: [0, 1, 0] }}transition={{ duration: 1.5, ease: "easeOut" }}>- <div className="h-full w-full bg-gradient-to-l from-green-400/40 via-green-400/20 to-transparent" />+ <div className="h-full w-full bg-gradient-to-l from-foreground/30 via-foreground/15 to-transparent" /><motion.div- className="absolute right-2 top-1/2 -translate-y-1/2 bg-green-500 text-white text-xs font-medium px-2 py-1 rounded-full shadow-lg"+ className="absolute right-2 top-1/2 -translate-y-1/2 bg-foreground text-background text-xs font-medium px-2 py-1 rounded-full shadow-lg"initial={{ scale: 0, x: 20 }}animate={{ scale: 1, x: 0 }}exit={{ scale: 0, x: 20 }}@@ -401,7 +414,7 @@ export const TimelineSlider = ({ref={containerRef}className="w-full overflow-x-auto overflow-y-visible scrollbar-hide bg-gradient-to-t from-black/50 to-black/0"style={{- paddingTop: "40px", // Space for tooltips above+ paddingTop: "60px", // Space for tooltips abovepaddingBottom: "24px", // Space for time axis below}}>@@ -477,17 +490,17 @@ export const TimelineSlider = ({data-timestamp={frame.timestamp}className={cn("flex-shrink-0 cursor-ew-resize rounded-t relative hover:z-50 transition-all duration-200",- (isSelected || isInRange) && "ring-2 ring-blue-400 ring-offset-1 ring-offset-black/20"+ (isSelected || isInRange) && "ring-2 ring-foreground/60 ring-offset-1 ring-offset-black/20")}style={{width: `${frameWidth}px`,marginLeft: `${frameMargin}px`,marginRight: `${frameMargin}px`,- backgroundColor: isCurrent ? '#3b82f6' : group.color,+ backgroundColor: isCurrent ? 'hsl(var(--foreground))' : group.color,height: isCurrent || isSelected || isInRange ? "75%" : "45%",opacity: isCurrent || isSelected || isInRange ? 1 : 0.7,direction: "ltr",- boxShadow: isCurrent ? '0 0 15px rgba(59, 130, 246, 0.6), 0 0 30px rgba(59, 130, 246, 0.3)' : 'none',+ boxShadow: isCurrent ? '0 0 10px rgba(255, 255, 255, 0.4), 0 0 20px rgba(255, 255, 255, 0.2)' : 'none',transform: isCurrent ? 'scale(1.1)' : 'scale(1)',transition: 'all 0.2s ease-out',borderRadius: '4px 4px 0 0',@@ -509,9 +522,9 @@ export const TimelineSlider = ({}}onMouseLeave={() => setHoveredTimestamp(null)}>- {/* Audio indicator - green dot at top of bar */}+ {/* Audio indicator - subtle dot at top of bar */}{hasAudio && (- <div className="absolute top-0.5 left-1/2 -translate-x-1/2 w-1.5 h-1.5 rounded-full bg-green-400 shadow-sm" />+ <div className="absolute top-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-foreground/60" />)}{/* Time marker below frame */}@@ -527,7 +540,7 @@ export const TimelineSlider = ({{/* Tooltip on hover */}{(hoveredTimestamp === frame.timestamp ||frames[currentIndex]?.timestamp === frame.timestamp) && (- <div className="absolute bottom-full left-1/2 z-50 -translate-x-1/2 mb-8 w-max bg-popover border border-border rounded-lg px-3 py-2 text-xs shadow-2xl">+ <div className="absolute bottom-full left-1/2 z-50 -translate-x-1/2 mb-2 w-max bg-popover border border-border rounded-lg px-3 py-2 text-xs shadow-2xl"><div className="flex items-center gap-2 mb-1"><imgsrc={`http://localhost:11435/app-icon?name=${encodeURIComponent(group.appName)}`}@@ -542,7 +555,7 @@ export const TimelineSlider = ({{format(new Date(frame.timestamp), 'h:mm:ss a')}</p>{hasAudio && (- <p className="text-green-400 flex items-center gap-1 mt-1">+ <p className="text-muted-foreground flex items-center gap-1 mt-1"><Mic className="w-3 h-3" /><span>audio recorded</span></p>@@ -563,11 +576,11 @@ export const TimelineSlider = ({<div className="absolute bottom-0 left-0 right-0 h-6 flex items-center justify-center pointer-events-none"><div className="flex items-center gap-4 text-[10px] text-muted-foreground"><span className="flex items-center gap-1">- <div className="w-3 h-3 rounded bg-blue-500" />+ <div className="w-3 h-3 rounded bg-foreground" /><span>current</span></span><span className="flex items-center gap-1">- <Mic className="w-3 h-3 text-green-400" />+ <Mic className="w-3 h-3 text-muted-foreground" /><span>has audio</span></span><span className="opacity-60">scroll to navigate • pinch to zoom</span>