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
feat(timeline): click app icon to see context popover (time, windows, urls, audio)
Louis Beaumontbe3ecffb9072
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsxnew file mode 100644index 000000000..2275107f0--- /dev/null+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsx@@ -0,0 +1,297 @@+import { useEffect, useMemo, useState } from "react";+import { StreamTimeSeriesResponse } from "@/components/rewind/timeline";+import { Copy, Search, X, Globe, AppWindow, Mic, Clock } from "lucide-react";+import { format } from "date-fns";++interface AppContextData {+ frameCount: number;+ uniqueWindows: number;+ topWindows: { name: string; count: number }[];+ topUrls: { url: string; count: number }[];+}++interface AppContextPopoverProps {+ appName: string;+ frames: StreamTimeSeriesResponse[];+ onClose: () => void;+ onSearch?: () => void;+}++function extractDomain(url: string): string {+ try {+ return new URL(url).hostname.replace("www.", "");+ } catch {+ return url;+ }+}++export function AppContextPopover({+ appName,+ frames,+ onClose,+ onSearch,+}: AppContextPopoverProps) {+ const [data, setData] = useState<AppContextData | null>(null);+ const [copied, setCopied] = useState(false);++ // compute time range from frames+ const timeRange = useMemo(() => {+ if (!frames.length) return null;+ const timestamps = frames.map((f) => new Date(f.timestamp).getTime());+ return {+ start: new Date(Math.min(...timestamps)),+ end: new Date(Math.max(...timestamps)),+ };+ }, [frames]);++ // extract audio transcripts from already-loaded frames (no fetch)+ const audioTranscripts = useMemo(() => {+ const transcripts: { text: string; time: Date; speaker?: string }[] = [];+ for (const frame of frames) {+ for (const device of frame.devices) {+ for (const audio of device.audio || []) {+ if (audio.transcription?.trim()) {+ transcripts.push({+ text: audio.transcription.trim(),+ time: new Date(frame.timestamp),+ speaker: audio.speaker_name || undefined,+ });+ }+ }+ }+ }+ return transcripts;+ }, [frames]);++ // fetch window/url stats via raw_sql (one query)+ useEffect(() => {+ if (!timeRange) return;++ const startISO = timeRange.start.toISOString();+ const endISO = timeRange.end.toISOString();+ const escapedApp = appName.replace(/'/g, "''");++ const query = `+ SELECT 'summary' as type, COUNT(*) as val, COUNT(DISTINCT window_name) as val2, NULL as name+ FROM frames+ WHERE app_name = '${escapedApp}'+ AND timestamp BETWEEN '${startISO}' AND '${endISO}'+ UNION ALL+ SELECT 'window' as type, COUNT(*) as val, NULL as val2, window_name as name+ FROM frames+ WHERE app_name = '${escapedApp}'+ AND timestamp BETWEEN '${startISO}' AND '${endISO}'+ AND window_name IS NOT NULL AND window_name != ''+ GROUP BY window_name ORDER BY val DESC LIMIT 5+ UNION ALL+ SELECT 'url' as type, COUNT(*) as val, NULL as val2, browser_url as name+ FROM frames+ WHERE app_name = '${escapedApp}'+ AND timestamp BETWEEN '${startISO}' AND '${endISO}'+ AND browser_url IS NOT NULL AND browser_url != ''+ GROUP BY browser_url ORDER BY val DESC LIMIT 5+ `;++ fetch("http://localhost:3030/raw_sql", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ query }),+ })+ .then((r) => r.json())+ .then((rows: any[]) => {+ const summary = rows.find((r) => r.type === "summary");+ const windows = rows+ .filter((r) => r.type === "window")+ .map((r) => ({ name: r.name, count: Number(r.val) }));+ const urls = rows+ .filter((r) => r.type === "url")+ .map((r) => ({ url: r.name, count: Number(r.val) }));++ setData({+ frameCount: Number(summary?.val ?? frames.length),+ uniqueWindows: Number(summary?.val2 ?? 0),+ topWindows: windows,+ topUrls: urls,+ });+ })+ .catch(() => {+ // fallback: just use frame count+ setData({+ frameCount: frames.length,+ uniqueWindows: 0,+ topWindows: [],+ topUrls: [],+ });+ });+ }, [appName, timeRange, frames.length]);++ const approxMinutes = Math.max(1, Math.round(((data?.frameCount ?? frames.length) * 10) / 60));++ const handleCopy = () => {+ if (!timeRange) return;++ const lines = [+ `${appName} — ${format(timeRange.start, "h:mm a")} to ${format(timeRange.end, "h:mm a")}`,+ `~${approxMinutes} min`,+ "",+ ];++ if (data?.topWindows.length) {+ lines.push("Windows:");+ data.topWindows.forEach((w) => lines.push(` ${w.name}`));+ lines.push("");+ }++ if (data?.topUrls.length) {+ lines.push("URLs:");+ data.topUrls.forEach((u) => lines.push(` ${u.url}`));+ lines.push("");+ }++ if (audioTranscripts.length) {+ lines.push("Audio:");+ audioTranscripts.slice(0, 5).forEach((t) =>+ lines.push(` [${format(t.time, "h:mm a")}] ${t.text}`)+ );+ }++ navigator.clipboard.writeText(lines.join("\n"));+ setCopied(true);+ setTimeout(() => setCopied(false), 1500);+ };++ return (+ <div+ className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-[60] w-72 bg-popover border border-border rounded-lg shadow-2xl text-xs"+ style={{ direction: "ltr" }}+ onClick={(e) => e.stopPropagation()}+ onMouseDown={(e) => e.stopPropagation()}+ >+ {/* Header */}+ <div className="flex items-center justify-between px-3 py-2 border-b border-border">+ <div className="flex items-center gap-2">+ <img+ src={`http://localhost:11435/app-icon?name=${encodeURIComponent(appName)}`}+ className="w-4 h-4 rounded"+ alt=""+ />+ <span className="font-medium text-popover-foreground truncate max-w-[180px]">+ {appName}+ </span>+ </div>+ <button+ onClick={onClose}+ className="text-muted-foreground hover:text-foreground transition-colors"+ >+ <X className="w-3 h-3" />+ </button>+ </div>++ {/* Content */}+ <div className="px-3 py-2 space-y-2 max-h-64 overflow-y-auto">+ {/* Time summary */}+ {timeRange && (+ <div className="flex items-center gap-1.5 text-muted-foreground">+ <Clock className="w-3 h-3 flex-shrink-0" />+ <span>+ ~{approxMinutes} min · {format(timeRange.start, "h:mm a")}–+ {format(timeRange.end, "h:mm a")}+ </span>+ </div>+ )}++ {/* Top windows */}+ {data && data.topWindows.length > 0 && (+ <div className="space-y-1">+ <div className="flex items-center gap-1.5 text-muted-foreground">+ <AppWindow className="w-3 h-3 flex-shrink-0" />+ <span>{data.uniqueWindows} window{data.uniqueWindows !== 1 ? "s" : ""}</span>+ </div>+ <div className="pl-4 space-y-0.5">+ {data.topWindows.map((w, i) => (+ <div+ key={i}+ className="text-popover-foreground truncate"+ title={w.name}+ >+ {w.name}+ </div>+ ))}+ </div>+ </div>+ )}++ {/* Top URLs */}+ {data && data.topUrls.length > 0 && (+ <div className="space-y-1">+ <div className="flex items-center gap-1.5 text-muted-foreground">+ <Globe className="w-3 h-3 flex-shrink-0" />+ <span>top sites</span>+ </div>+ <div className="pl-4 space-y-0.5">+ {data.topUrls.map((u, i) => (+ <div+ key={i}+ className="text-popover-foreground truncate"+ title={u.url}+ >+ {extractDomain(u.url)}+ </div>+ ))}+ </div>+ </div>+ )}++ {/* Audio transcripts */}+ {audioTranscripts.length > 0 && (+ <div className="space-y-1">+ <div className="flex items-center gap-1.5 text-muted-foreground">+ <Mic className="w-3 h-3 flex-shrink-0" />+ <span>{audioTranscripts.length} transcript{audioTranscripts.length !== 1 ? "s" : ""}</span>+ </div>+ <div className="pl-4 space-y-1">+ {audioTranscripts.slice(0, 3).map((t, i) => (+ <div key={i} className="text-popover-foreground">+ <span className="text-muted-foreground">+ {format(t.time, "h:mm a")}+ </span>{" "}+ <span className="line-clamp-1">{t.text}</span>+ </div>+ ))}+ {audioTranscripts.length > 3 && (+ <div className="text-muted-foreground">+ +{audioTranscripts.length - 3} more+ </div>+ )}+ </div>+ </div>+ )}++ {/* Loading state */}+ {!data && (+ <div className="text-muted-foreground text-center py-2">loading...</div>+ )}+ </div>++ {/* Actions */}+ <div className="flex items-center gap-1 px-3 py-2 border-t border-border">+ <button+ onClick={handleCopy}+ className="flex items-center gap-1 px-2 py-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"+ >+ <Copy className="w-3 h-3" />+ <span>{copied ? "copied" : "copy"}</span>+ </button>+ {onSearch && (+ <button+ onClick={onSearch}+ className="flex items-center gap-1 px-2 py-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"+ >+ <Search className="w-3 h-3" />+ <span>search</span>+ </button>+ )}+ </div>+ </div>+ );+}diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsxindex 2d02e7bed..5818ce45c 100644--- a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx@@ -6,6 +6,7 @@ import { ZoomIn, ZoomOut, Mic } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import posthog from "posthog-js";import { cn } from "@/lib/utils";+import { AppContextPopover } from "./app-context-popover";interface TimelineSliderProps {frames: StreamTimeSeriesResponse[];@@ -143,6 +144,9 @@ export const TimelineSlider = ({);const { setSelectionRange, selectionRange } = useTimelineSelection();+ // App context popover state+ const [activePopoverGroup, setActivePopoverGroup] = useState<number | null>(null);+// Zoom state: 1 = normal, >1 = zoomed in, <1 = zoomed out// Range: 0.25 (very zoomed out) to 4 (very zoomed in)const [zoomLevel, setZoomLevel] = useState(1);@@ -445,6 +449,7 @@ export const TimelineSlider = ({setIsDragging(true);setDragStartIndex(index);setHasDragMoved(false); // Reset movement tracking+ setActivePopoverGroup(null); // Close popover when interacting with frames// Don't set selection immediately - wait for movement};@@ -587,13 +592,19 @@ export const TimelineSlider = ({// borderLeft removed — caused visible white lines between groups}}>- {/* Vertical stacked app icons - max 2 icons, hover to expand */}+ {/* Vertical stacked app icons - click for context popover */}{groupWidth > 30 && (<motion.divclassName="absolute top-1 left-1/2 -translate-x-1/2 z-10 flex flex-col cursor-pointer"style={{ direction: 'ltr' }}whileHover="expanded"initial="collapsed"+ onClick={(e) => {+ e.stopPropagation();+ setActivePopoverGroup(+ activePopoverGroup === groupIndex ? null : groupIndex+ );+ }}>{group.appNames.slice(0, 2).map((appName, idx) => (<motion.div@@ -618,6 +629,15 @@ export const TimelineSlider = ({</motion.div>)}+ {/* App context popover */}+ {activePopoverGroup === groupIndex && (+ <AppContextPopover+ appName={group.appName}+ frames={group.frames}+ onClose={() => setActivePopoverGroup(null)}+ />+ )}+{group.frames.map((frame, frameIdx) => {// O(1) lookup instead of O(n) indexOfconst frameIndex = frameIndexMap.get(frame.timestamp) ?? -1;