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

refactor: add full date in rewind AI panel

Louis Beaumontb4487f790e68
diff --git a/pipes/rewind/src/app/page.tsx b/pipes/rewind/src/app/page.tsx
index f1fa4252d..710e06f4b 100644
--- a/pipes/rewind/src/app/page.tsx
+++ b/pipes/rewind/src/app/page.tsx
@@ -10,6 +10,7 @@ import { AGENTS } from "@/components/timeline/agents";
import { TimelineSelection } from "@/components/timeline/timeline-selection";
import { TimelineControls } from "@/components/timeline/timeline-controls";
import { TimelineSearch } from "@/components/timeline/timeline-search";
+import { TimelineSearch2 } from "@/components/timeline/timeline-search-v2";
export interface StreamTimeSeriesResponse {
timestamp: string;
@@ -71,6 +72,7 @@ export default function Timeline() {
y: 0,
});
const [currentDate, setCurrentDate] = useState(new Date());
+ const [searchResults, setSearchResults] = useState<number[]>([]);
useEffect(() => {
setAiPanelPosition({
@@ -459,12 +461,11 @@ export default function Timeline() {
onJumpToday={handleJumpToday}
className="shadow-lg"
/>
- <TimelineSearch
+ {/* <TimelineSearch2
frames={frames}
- onResultSelect={(index) => {
- animateToIndex(index);
- }}
- />
+ onResultSelect={animateToIndex}
+ onSearchResults={setSearchResults}
+ /> */}
</div>
</div>
@@ -520,13 +521,19 @@ export default function Timeline() {
</div>
<div className="w-4/5 mx-auto my-8 relative select-none">
- <div className="h-[60px] bg-card border rounded-lg shadow-sm cursor-crosshair relative">
+ <div
+ className="h-[60px] bg-card border rounded-lg shadow-sm cursor-crosshair relative overflow-hidden"
+ style={{
+ width: "100%",
+ boxSizing: "border-box",
+ }}
+ >
{loadedTimeRange && (
<TimelineSelection loadedTimeRange={loadedTimeRange} />
)}
<div
- className="absolute top-0 h-full w-1 bg-foreground/50 shadow-sm opacity-80 z-10"
- style={{ left: `${timePercentage}%` }}
+ className="absolute top-0 h-full w-1 bg-foreground/50 shadow-sm opacity-80"
+ style={{ left: `${timePercentage}%`, zIndex: 5 }}
>
<div className="relative -top-6 right-3 text-[10px] text-muted-foreground whitespace-nowrap">
{currentIndex < frames.length &&
@@ -551,6 +558,31 @@ export default function Timeline() {
})()}
</div>
</div>
+
+ {searchResults.map((frameIndex) => {
+ const percentage = (frameIndex / (frames.length - 1)) * 100;
+ return (
+ <div
+ key={frameIndex}
+ className="absolute top-0 h-full w-1.5 bg-blue-500/50 hover:bg-blue-500 cursor-pointer transition-colors"
+ style={{ left: `${percentage}%`, zIndex: 4 }}
+ onClick={() => {
+ animateToIndex(frameIndex);
+ setSearchResults([]); // Clear results after clicking
+ }}
+ >
+ <div className="absolute -top-6 -left-2 text-[10px] text-blue-500 whitespace-nowrap">
+ {new Date(frames[frameIndex].timestamp).toLocaleTimeString(
+ [],
+ {
+ hour: "2-digit",
+ minute: "2-digit",
+ }
+ )}
+ </div>
+ </div>
+ );
+ })}
</div>
<AIPanel
diff --git a/pipes/rewind/src/components/timeline/ai-panel.tsx b/pipes/rewind/src/components/timeline/ai-panel.tsx
index 9da1e3269..fb97b84c2 100644
--- a/pipes/rewind/src/components/timeline/ai-panel.tsx
+++ b/pipes/rewind/src/components/timeline/ai-panel.tsx
@@ -297,8 +297,21 @@ export function AIPanel({
<div className="flex items-center gap-2 flex-1">
<GripHorizontal className="w-4 h-4 text-muted-foreground group-hover:text-foreground" />
<div className="text-muted-foreground text-xs">
- {new Date(selectionRange.start.getTime()).toLocaleTimeString()} -{" "}
- {new Date(selectionRange.end.getTime()).toLocaleTimeString()}
+ {new Date(selectionRange.start).toLocaleString([], {
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ second: "2-digit",
+ })}
+ {" - "}
+ {new Date(selectionRange.end).toLocaleString([], {
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ second: "2-digit",
+ })}
</div>
</div>
<button
@@ -333,7 +346,7 @@ export function AIPanel({
{isExpanded && (
<div className="flex flex-col h-[calc(100%-52px)]">
<div
- className="flex-1 overflow-y-auto p-4 space-y-4 min-h-0 hover:cursor-auto text-foreground font-mono text-sm leading-relaxed"
+ className="flex-1 overflow-y-auto p-4 space-y-4 min-h-0 hover:cursor-auto text-foreground font-mono text-sm leading-relaxed "
style={{
WebkitUserSelect: "text",
userSelect: "text",
@@ -342,6 +355,8 @@ export function AIPanel({
overscrollBehavior: "contain",
overflowY: "scroll",
height: "100%",
+ maxWidth: "100%",
+ boxSizing: "border-box",
}}
>
{chatMessages.map((msg, index) => (
diff --git a/pipes/rewind/src/components/timeline/timeline-search-v2.tsx b/pipes/rewind/src/components/timeline/timeline-search-v2.tsx
new file mode 100644
index 000000000..63c4ac458
--- /dev/null
+++ b/pipes/rewind/src/components/timeline/timeline-search-v2.tsx
@@ -0,0 +1,309 @@
+"use client";
+
+import { useState, useCallback } from "react";
+import { Search, Loader2 } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ DialogPortal,
+ DialogOverlay,
+} from "@/components/ui/dialog";
+import { motion } from "framer-motion";
+import { StreamTimeSeriesResponse } from "@/app/page";
+
+interface TimelineSearchProps {
+ frames: StreamTimeSeriesResponse[];
+ onResultSelect: (index: number) => void;
+ onSearchResults?: (results: number[]) => void;
+}
+
+// Extract meaningful keywords from frames
+function extractKeywords(frames: StreamTimeSeriesResponse[]): string[] {
+ const keywords = new Map<string, number>();
+
+ // Common words to filter out
+ const stopWords = new Set([
+ "the",
+ "be",
+ "to",
+ "of",
+ "and",
+ "a",
+ "in",
+ "that",
+ "have",
+ "i",
+ "it",
+ "for",
+ "not",
+ "on",
+ "with",
+ "he",
+ "as",
+ "you",
+ "do",
+ "at",
+ "this",
+ "but",
+ "his",
+ "by",
+ "from",
+ "they",
+ "we",
+ "say",
+ "her",
+ "she",
+ "or",
+ "an",
+ "will",
+ "my",
+ "one",
+ "all",
+ "would",
+ "there",
+ "their",
+ "what",
+ "so",
+ "up",
+ "out",
+ "if",
+ "about",
+ "who",
+ "get",
+ "which",
+ "go",
+ "me",
+ "when",
+ "make",
+ "can",
+ "like",
+ "time",
+ "no",
+ "just",
+ "him",
+ "know",
+ "take",
+ "people",
+ "into",
+ "year",
+ "your",
+ "good",
+ "some",
+ "could",
+ "them",
+ "see",
+ "other",
+ "than",
+ "then",
+ "now",
+ "look",
+ "only",
+ "come",
+ "its",
+ "over",
+ "think",
+ "also",
+ "back",
+ "after",
+ "use",
+ "two",
+ "how",
+ "our",
+ "work",
+ "first",
+ "well",
+ "way",
+ "even",
+ "new",
+ "want",
+ "because",
+ "any",
+ "these",
+ "give",
+ "day",
+ "most",
+ "us",
+ ]);
+
+ // Patterns for valuable information
+ const patterns = {
+ email: /\b[\w\.-]+@[\w\.-]+\.\w+\b/g,
+ url: /https?:\/\/[^\s]+/g,
+ date: /\b\d{1,2}[-/]\d{1,2}[-/]\d{2,4}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]* \d{1,2}(?:st|nd|rd|th)?\b/gi,
+ time: /\b(?:1[0-2]|0?[1-9])(?::[0-5][0-9])?\s*(?:am|pm)\b/gi,
+ properNoun: /\b[A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\b/g,
+ appName:
+ /\b(?:vscode|chrome|firefox|safari|slack|discord|zoom|teams|figma|notion|github)\b/gi,
+ codeTerms:
+ /\b(?:function|class|const|let|var|import|export|async|await|return|if|else|for|while)\b/g,
+ numbers: /\b\d+(?:\.\d+)?[kmbt]?\b/gi,
+ };
+
+ frames.forEach((frame) => {
+ frame.devices.forEach((device) => {
+ const text = [
+ device.metadata.ocr_text,
+ device.metadata.window_name,
+ ...device.audio.map((a) => a.transcription),
+ ].join(" ");
+
+ // Extract patterns
+ Object.entries(patterns).forEach(([type, pattern]) => {
+ const matches = text.match(pattern) || [];
+ matches.forEach((match) => {
+ const key = `${match.toLowerCase()}`;
+ if (!stopWords.has(key) && key.length > 2) {
+ keywords.set(key, (keywords.get(key) || 0) + 1);
+ }
+ });
+ });
+
+ // Extract potential important phrases (2-3 words)
+ const words = text.split(/\s+/);
+ for (let i = 0; i < words.length - 1; i++) {
+ const phrase = words
+ .slice(i, i + 2)
+ .join(" ")
+ .toLowerCase();
+ if (phrase.split(" ").every((word) => !stopWords.has(word))) {
+ keywords.set(phrase, (keywords.get(phrase) || 0) + 1);
+ }
+ }
+ });
+ });
+
+ // Score and rank keywords
+ const scoredKeywords = Array.from(keywords.entries()).map(([word, count]) => {
+ let score = count;
+
+ // Boost certain types of keywords
+ if (word.match(patterns.email)) score *= 2;
+ if (word.match(patterns.properNoun)) score *= 1.5;
+ if (word.match(patterns.date)) score *= 1.3;
+ if (word.match(patterns.appName)) score *= 1.2;
+
+ // Penalize very common words
+ if (count > frames.length / 2) score *= 0.5;
+
+ return { word, score };
+ });
+
+ // Return top 10 most valuable keywords
+ return scoredKeywords
+ .sort((a, b) => b.score - a.score)
+ .slice(0, 10)
+ .map((k) => k.word);
+}
+
+export function TimelineSearch2({
+ frames,
+ onResultSelect,
+ onSearchResults,
+}: TimelineSearchProps) {
+ const [open, setOpen] = useState(false);
+ const [searchQuery, setSearchQuery] = useState("");
+ const [isSearching, setIsSearching] = useState(false);
+
+ const keywords = extractKeywords(frames);
+
+ const handleSearch = useCallback(
+ (query: string) => {
+ setIsSearching(true);
+
+ // Find all matching frames
+ const results = frames.reduce<number[]>((matches, frame, index) => {
+ const hasMatch = frame.devices.some((device) => {
+ const searchText = [
+ device.metadata.ocr_text,
+ device.metadata.window_name,
+ ...device.audio.map((a) => a.transcription),
+ ]
+ .join(" ")
+ .toLowerCase();
+
+ return searchText.includes(query.toLowerCase());
+ });
+
+ if (hasMatch) matches.push(index);
+ return matches;
+ }, []);
+
+ // Instead of jumping, send results to parent
+ if (results.length > 0) {
+ onSearchResults?.(results);
+ setOpen(false);
+ }
+
+ setIsSearching(false);
+ },
+ [frames, onSearchResults]
+ );
+
+ return (
+ <>
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => setOpen(true)}
+ className="rounded-full"
+ >
+ <Search className="h-4 w-4" />
+ </Button>
+
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogPortal>
+ <DialogOverlay className="backdrop-blur-sm" />
+ <DialogContent className="sm:max-w-[500px]">
+ <DialogTitle>search your timeline</DialogTitle>
+ <div className="p-6">
+ <div className="relative">
+ <Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
+ <Input
+ autoFocus
+ placeholder="search in your timeline..."
+ className="pl-9 h-12"
+ value={searchQuery}
+ onChange={(e) => setSearchQuery(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !isSearching) {
+ handleSearch(searchQuery);
+ }
+ }}
+ />
+ {isSearching && (
+ <Loader2 className="absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin" />
+ )}
+ </div>
+
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ className="mt-6"
+ >
+ <p className="text-sm text-muted-foreground mb-3">
+ common keywords
+ </p>
+ <div className="flex flex-wrap gap-2">
+ {keywords.map((keyword) => (
+ <Button
+ key={keyword}
+ variant="outline"
+ size="sm"
+ onClick={() => handleSearch(keyword)}
+ className="text-xs"
+ >
+ {keyword}
+ </Button>
+ ))}
+ </div>
+ </motion.div>
+ </div>
+ </DialogContent>
+ </DialogPortal>
+ </Dialog>
+ </>
+ );
+}
diff --git a/pipes/rewind/src/components/timeline/timeline-search.tsx b/pipes/rewind/src/components/timeline/timeline-search.tsx
index 7a4207330..9eb094e75 100644
--- a/pipes/rewind/src/components/timeline/timeline-search.tsx
+++ b/pipes/rewind/src/components/timeline/timeline-search.tsx
@@ -60,7 +60,7 @@ async function validateFrameContext(
model,
});
- const windowSize = 2;
+ const windowSize = 1000;
const start = Math.max(0, centerIndex - windowSize);
const end = Math.min(frames.length - 1, centerIndex + windowSize);
@@ -113,6 +113,7 @@ async function validateFrameContext(
return JSON.parse(response.choices[0].message.content);
}
+
async function findRelevantFrame(
query: string,
frames: StreamTimeSeriesResponse[],
@@ -207,10 +208,10 @@ async function findRelevantFrame(
await new Promise((resolve) => setTimeout(resolve, 1000));
// Add early return after checking N frames
- const MAX_FRAMES_TO_CHECK = 100; // Adjust this number
+ const MAX_FRAMES_TO_CHECK = 1000; // Adjust this number
let framesChecked = 0;
- const BATCH_SIZE = 50; // Adjust based on performance needs
+ const BATCH_SIZE = 2000; // Adjust based on performance needs
for (let i = 0; i < frames.length; i += BATCH_SIZE) {
if (signal?.aborted) {
throw new Error("AbortError");
@@ -444,6 +445,7 @@ export function TimelineSearch({
const [abortController, setAbortController] =
useState<AbortController | null>(null);
+
// Compute app statistics once when component mounts or frames update
const appStats = useMemo(() => {
const stats: AppStats = {
@@ -731,7 +733,7 @@ prioritize precision over recall - better to return no match than a wrong match.
<Input
autoFocus
placeholder="search in your timeline..."
- className="pl-9 h-10"
+ className="pl-9 h-12"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
onKeyDown={(e) => {