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: search ui in app
Louis Beaumont90deb7fdcc8b
diff --git a/examples/apps/screenpipe-app-tauri/app/page.tsx b/examples/apps/screenpipe-app-tauri/app/page.tsxindex 4bdd891b3..2f3e2f6c2 100644--- a/examples/apps/screenpipe-app-tauri/app/page.tsx+++ b/examples/apps/screenpipe-app-tauri/app/page.tsx@@ -12,7 +12,7 @@ import {} from "@/components/ui/card";import { Skeleton } from "@/components/ui/skeleton";-import React, { useEffect } from "react";+import React, { useEffect, useState } from "react";import NotificationHandler from "@/components/notification-handler";import ScreenpipeInstanceChecker from "@/components/screenpipe-instance-checker";import Header from "@/components/header";@@ -22,12 +22,15 @@ import { usePostHog } from "posthog-js/react";import Link from "next/link";import { useToast } from "@/components/ui/use-toast";import { DevSettings } from "@/components/dev-dialog";+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";+import SearchPanel from "@/components/search-panel";export default function Home() {const { settings } = useSettings();const posthog = usePostHog();- // console.log("settings", settings);const { toast } = useToast();+ const [activeTab, setActiveTab] = useState("search");+useEffect(() => {checkForAppUpdates({ toast });}, [toast]);@@ -59,11 +62,26 @@ export default function Home() {</div></div>) : settings.useOllama || settings.openaiApiKey ? (- <ChatList- apiKey={settings.openaiApiKey}- useOllama={settings.useOllama}- ollamaUrl={settings.ollamaUrl}- />+ <Tabs+ value={activeTab}+ onValueChange={setActiveTab}+ className="w-full max-w-4xl"+ >+ <TabsList className="grid w-full grid-cols-2">+ <TabsTrigger value="chat">chat</TabsTrigger>+ <TabsTrigger value="search">search</TabsTrigger>+ </TabsList>+ <TabsContent value="chat">+ <ChatList+ apiKey={settings.openaiApiKey}+ useOllama={settings.useOllama}+ ollamaUrl={settings.ollamaUrl}+ />+ </TabsContent>+ <TabsContent value="search">+ <SearchPanel />+ </TabsContent>+ </Tabs>) : (<div className="flex flex-col items-center justify-center h-[calc(80vh-200px)]"><Card className="w-[600px]">@@ -74,15 +92,6 @@ export default function Home() {about your data.<br /><br />- {/* <Link- // open new tab- href="https://youtu.be/WGnHmFFFJOc"- target="_blank"- // bold underline- className="font-bold underline"- >- Watch the onboarding video- </Link> */}<div className="aspect-w-16 aspect-h-9"><iframesrc="https://www.youtube.com/embed/u2GfjvEY6tk"diff --git a/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsx b/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsxindex a75b3d354..5e386977f 100644--- a/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsx+++ b/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsx@@ -220,6 +220,7 @@ export function ChatList({const results = await queryScreenpipeNtimes(generateObjectResult.object);+const toolCallId = generateToolCallId();const toolCallArgs = generateObjectResult.object;@@ -272,6 +273,7 @@ export function ChatList({- You must perform a timezone conversion to UTC before using any datetime in a tool call.- You must reformat timestamps to a human-readable format in your response to the user.- Never output UTC time unless explicitly asked by the user.+ - Do not try to embed videos in table (would crash the app)`,},// @ts-ignorediff --git a/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsx b/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsxindex dc292c3cc..01750c589 100644--- a/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsx+++ b/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsx@@ -1,8 +1,6 @@import { Message } from "ai";import remarkGfm from "remark-gfm";import remarkMath from "remark-math";-import { useState, useEffect, useCallback, memo } from "react";-import { readFile } from "@tauri-apps/plugin-fs";import { cn } from "@/lib/utils";import { CodeBlock } from "@/components/ui/codeblock";@@ -10,6 +8,7 @@ import { MemoizedReactMarkdown } from "@/components/markdown";import { IconOpenAI, IconUser, IconOllama } from "@/components/ui/icons";import { ChatMessageActions } from "@/components/chat-message-actions";import { useSettings } from "@/lib/hooks/use-settings";+import { VideoComponent } from "./video";export interface ChatMessageProps {message: Message;@@ -105,62 +104,3 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {</div>);}--const VideoComponent = memo(function VideoComponent({- filePath,-}: {- filePath: string;-}) {- const [videoSrc, setVideoSrc] = useState<string | null>(null);- const [error, setError] = useState<string | null>(null);-- const sanitizeFilePath = useCallback((path: string): string => {- // just extract the .mp4 file- return (- path.match(/[^"'()\[\]]+\.mp4/i)?.[0]?.trim() ||- "i failed to show the video 😭"- );- }, []);-- useEffect(() => {- async function loadVideo() {- try {- const sanitizedPath = sanitizeFilePath(filePath);- const videoData = await readFile(sanitizedPath);- const blob = new Blob([videoData], { type: "video/mp4" });- setVideoSrc(URL.createObjectURL(blob));- } catch (error) {- console.error("Failed to load video:", error);- setError(`Failed to load video: ${sanitizeFilePath(filePath)}`);- }- }-- loadVideo();- return () => {- if (videoSrc) URL.revokeObjectURL(videoSrc);- };- }, [filePath, sanitizeFilePath]);-- if (error) {- return (- <div className="w-full p-4 bg-red-100 border border-red-300 rounded-md">- <p className="text-red-700">{error}</p>- </div>- );- }-- if (!videoSrc) {- return (- <div className="w-full h-48 bg-gray-200 animate-pulse rounded-md flex items-center justify-center">- <span className="text-gray-500">Loading video...</span>- </div>- );- }-- return (- <video controls className="w-full max-w-2xl">- <source src={videoSrc} type="video/mp4" />- Your browser does not support the video tag.- </video>- );-});diff --git a/examples/apps/screenpipe-app-tauri/components/date-time-picker.tsx b/examples/apps/screenpipe-app-tauri/components/date-time-picker.tsxnew file mode 100644index 000000000..f6e9f11b7--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/date-time-picker.tsx@@ -0,0 +1,78 @@+import * as React from "react";+import { format } from "date-fns";+import { Calendar as CalendarIcon } from "lucide-react";++import { cn } from "@/lib/utils";+import { Button } from "@/components/ui/button";+import { Calendar } from "@/components/ui/calendar";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { Input } from "./ui/input";++export function DateTimePicker({+ date,+ setDate,+}: {+ date: Date;+ setDate: (date: Date) => void;+}) {+ const [selectedDateTime, setSelectedDateTime] = React.useState<Date>(date);++ React.useEffect(() => {+ setSelectedDateTime(date);+ }, [date]);++ const handleDateSelect = (selectedDate: Date | undefined) => {+ if (selectedDate) {+ const newDateTime = new Date(selectedDateTime);+ newDateTime.setFullYear(selectedDate.getFullYear());+ newDateTime.setMonth(selectedDate.getMonth());+ newDateTime.setDate(selectedDate.getDate());+ setSelectedDateTime(newDateTime);+ setDate(newDateTime);+ }+ };++ const handleTimeChange = (event: React.ChangeEvent<HTMLInputElement>) => {+ const [hours, minutes] = event.target.value.split(":").map(Number);+ if (!isNaN(hours) && !isNaN(minutes)) {+ const newDateTime = new Date(selectedDateTime);+ newDateTime.setHours(hours);+ newDateTime.setMinutes(minutes);+ setSelectedDateTime(newDateTime);+ setDate(newDateTime);+ }+ };++ return (+ <Popover>+ <PopoverTrigger asChild>+ <Button+ variant={"outline"}+ className={cn("w-full justify-start text-left font-normal")}+ >+ <CalendarIcon className="mr-2 h-4 w-4" />+ {format(date, "PPP HH:mm")}+ </Button>+ </PopoverTrigger>+ <PopoverContent className="w-auto p-0">+ <Calendar+ mode="single"+ selected={selectedDateTime}+ onSelect={handleDateSelect}+ initialFocus+ />+ <div className="p-3 border-t border-border">+ <Input+ type="time"+ onChange={handleTimeChange}+ value={format(selectedDateTime, "HH:mm")}+ />+ </div>+ </PopoverContent>+ </Popover>+ );+}diff --git a/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx b/examples/apps/screenpipe-app-tauri/components/empty-screen.tsxindex 7e6f68219..6f76a5376 100644--- a/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx+++ b/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx@@ -6,11 +6,11 @@ interface EmptyScreenProps {}const suggestions = [- "Summarize last hour audio conversation with action items",- "Read my data from last 60 mins and list apps i spent the most time on, with duration, list of topics, etc. (be creative), as a table",- "Look at my data from last hour and tell me how i can become a better programmer",- "Create a table of everything I did in the last hour",- "Create a bullet list of everything I did in the last hour with timestamps and path to the video",+ "Summarize last 15 mins audio conversation with action items",+ "Write instructions to reproduce my engineering work from last 15 mins",+ "Look at my data from last 15 mins and tell me how i can become a better programmer",+ "Create a table of everything I did in the last 15 mins",+ "Create a bullet list of everything I did in the last 15 mins with timestamps and path to the video","Show me a video of what i was doing at 8.11 am (take file_path and put it in an inline code block)",];diff --git a/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx b/examples/apps/screenpipe-app-tauri/components/pipe-store.tsxindex e085f3ca5..9c9cd4dfc 100644--- a/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx+++ b/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx@@ -45,8 +45,8 @@ const PipeDialog: React.FC = () => {// "https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript/pipe-tagging-activity",// "https://github.com/mediar-ai/screenpipe/tree/pipe-logs/examples/typescript/pipe-stream-ocr-text",]);- console.log("pipes", pipes);- console.log("newRepoUrl", newRepoUrl);+ // console.log("pipes", pipes);+ // console.log("newRepoUrl", newRepoUrl);const [selectedPipe, setSelectedPipe] = useState<Pipe | null>(null);const { settings, updateSettings } = useSettings();const [installedPipes, setInstalledPipes] = useState<string[]>([]);diff --git a/examples/apps/screenpipe-app-tauri/components/search-panel.tsx b/examples/apps/screenpipe-app-tauri/components/search-panel.tsxnew file mode 100644index 000000000..906e36de7--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/search-panel.tsx@@ -0,0 +1,394 @@+import React, { useState } from "react";+import { Input } from "@/components/ui/input";+import { Button } from "@/components/ui/button";+import { Card, CardContent } from "@/components/ui/card";+import { queryScreenpipe, ContentItem } from "@/lib/screenpipe";+import { Skeleton } from "@/components/ui/skeleton";+import { Slider } from "@/components/ui/slider";+import { Switch } from "@/components/ui/switch";+import { Label } from "@/components/ui/label";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { Progress } from "@/components/ui/progress";+import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from "@/components/ui/dialog";+import { VideoComponent } from "./video";+import { ChevronLeft, ChevronRight } from "lucide-react";++import { DateTimePicker } from "./date-time-picker";+import { IconCode } from "./ui/icons";+import { CodeBlock } from "./ui/codeblock";+import {+ Accordion,+ AccordionContent,+ AccordionItem,+ AccordionTrigger,+} from "./ui/accordion";+import { useToast } from "./ui/use-toast";+import { Badge } from "./ui/badge";++export default function Search() {+ const [query, setQuery] = useState("");+ const [results, setResults] = useState<ContentItem[]>([]);+ const [isLoading, setIsLoading] = useState(false);+ const [startDate, setStartDate] = useState<Date>(+ new Date(Date.now() - 24 * 3600000)+ );+ const [endDate, setEndDate] = useState<Date>(new Date());+ const [includeFrames, setIncludeFrames] = useState(false);+ const [limit, setLimit] = useState(50);+ const [appName, setAppName] = useState("");+ const [windowName, setWindowName] = useState("");+ const [contentType, setContentType] = useState("all");+ const [offset, setOffset] = useState(0);+ const [totalResults, setTotalResults] = useState(0);+ const [isDialogOpen, setIsDialogOpen] = useState(false);+ const { toast } = useToast();++ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });+ const generateCurlCommand = () => {+ const baseUrl = "http://localhost:3030";+ const queryParams = new URLSearchParams({+ content_type: contentType,+ limit: limit.toString(),+ offset: offset.toString(),+ start_time: startDate.toISOString().replace(/\.\d{3}Z$/, "Z"),+ end_time: endDate.toISOString().replace(/\.\d{3}Z$/, "Z"),+ });++ if (query) queryParams.append("q", query);+ if (appName) queryParams.append("app_name", appName);+ if (windowName) queryParams.append("window_name", windowName);+ if (includeFrames) queryParams.append("include_frames", "true");++ return `curl "${baseUrl}/search?\\+${queryParams.toString().replace(/&/g, "\\\n&")}" | jq`;+ };+ const handleSearch = async (newOffset = 0) => {+ setIsLoading(true);+ setOffset(newOffset);+ const response = await queryScreenpipe({+ q: query || undefined,+ content_type: contentType as "all" | "ocr" | "audio",+ limit,+ offset: newOffset,+ start_time: startDate.toISOString().replace(/\.\d{3}Z$/, "Z"),+ end_time: endDate.toISOString().replace(/\.\d{3}Z$/, "Z"),+ app_name: appName || undefined,+ window_name: windowName || undefined,+ include_frames: includeFrames,+ });+ if (response) {+ console.log("response", response);+ setResults(response.data);+ setTotalResults(response.pagination.total);+ }+ setIsLoading(false);+ };++ const handleNextPage = () => {+ if (offset + limit < totalResults) {+ handleSearch(offset + limit);+ }+ };++ const handlePrevPage = () => {+ if (offset - limit >= 0) {+ handleSearch(offset - limit);+ }+ };+ const handleBadgeClick = (type: "app" | "window", value: string) => {+ if (type === "app") {+ setAppName(value);+ } else if (type === "window") {+ setWindowName(value);+ }+ };+ const renderContent = (item: ContentItem) => {+ const copyContent = () => {+ let textToCopy = "";+ switch (item.type) {+ case "OCR":+ textToCopy = item.content.text;+ break;+ case "Audio":+ textToCopy = item.content.transcription;+ break;+ case "FTS":+ textToCopy = item.content.matched_text;+ break;+ }+ copyToClipboard(textToCopy);+ toast({+ title: "Copied to clipboard",+ description: "The content has been copied to your clipboard.",+ });+ };++ return (+ <div className="py-4">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button onClick={copyContent} variant="outline" size="sm">+ Copy+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <p>Copy content to clipboard</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <Accordion type="single" collapsible className="w-full">+ <AccordionItem value="item-1">+ <AccordionTrigger className="flex items-center">+ <div className="flex items-center w-full">+ <Badge className="mr-2">{item.type}</Badge>+ </div>+ <span className="flex-grow text-center truncate">+ {item.type === "OCR" && item.content.text.substring(0, 50)}+ {item.type === "Audio" &&+ item.content.transcription.substring(0, 50)}+ {item.type === "FTS" &&+ item.content.matched_text.substring(0, 50)}+ ...+ </span>+ </AccordionTrigger>+ <AccordionContent>+ {item.type === "OCR" && (+ <>+ <p className="mt-2">{item.content.text}</p>+ <VideoComponent filePath={item.content.file_path} />+ {includeFrames && item.content.frame && (+ <Dialog>+ <DialogTrigger asChild>+ <img+ src={`data:image/jpeg;base64,${item.content.frame}`}+ alt="Frame"+ className="mt-2 w-24 h-auto cursor-pointer"+ />+ </DialogTrigger>+ <DialogContent className="sm:max-w-[80vw]">+ <img+ src={`data:image/jpeg;base64,${item.content.frame}`}+ alt="Frame"+ className="w-full h-auto"+ />+ </DialogContent>+ </Dialog>+ )}+ </>+ )}+ {item.type === "Audio" && (+ <>+ <p className="mt-2">{item.content.transcription}</p>+ <VideoComponent filePath={item.content.file_path} />+ </>+ )}+ {item.type === "FTS" && (+ <>+ <p className="mt-2">{item.content.matched_text}</p>+ {item.content.original_frame_text && (+ <p className="mt-2 text-sm text-gray-600">+ Original: {item.content.original_frame_text}+ </p>+ )}+ </>+ )}+ </AccordionContent>+ </AccordionItem>+ </Accordion>+ </div>+ );+ };++ return (+ <div className="space-y-4">+ <div className="grid grid-cols-2 gap-4">+ <Input+ type="text"+ placeholder="Search your data..."+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ autoCorrect="off"+ />+ <Select value={contentType} onValueChange={setContentType}>+ <SelectTrigger>+ <SelectValue placeholder="Content Type" />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="all">All</SelectItem>+ <SelectItem value="ocr">OCR</SelectItem>+ <SelectItem value="audio">Audio</SelectItem>+ </SelectContent>+ </Select>+ <DateTimePicker date={startDate} setDate={setStartDate} />+ <DateTimePicker date={endDate} setDate={setEndDate} />+ <Input+ type="text"+ placeholder="App Name"+ value={appName}+ onChange={(e) => setAppName(e.target.value)}+ autoCorrect="off"+ />+ <Input+ type="text"+ placeholder="Window Name"+ value={windowName}+ onChange={(e) => setWindowName(e.target.value)}+ autoCorrect="off"+ />+ <div className="flex items-center space-x-2">+ <Switch+ id="include-frames"+ checked={includeFrames}+ onCheckedChange={setIncludeFrames}+ />+ <Label htmlFor="include-frames">Include Frames</Label>+ </div>+ <div className="flex flex-col space-y-2">+ <Label>Limit: {limit}</Label>+ <Slider+ value={[limit]}+ onValueChange={(value: number[]) => setLimit(value[0])}+ min={1}+ max={100}+ step={1}+ />+ </div>+ </div>+ <div className="flex items-center space-x-2">+ <Button+ onClick={() => handleSearch(0)}+ disabled={isLoading}+ className="flex-grow items-center"+ >+ {isLoading ? "Searching..." : "Search"}+ </Button>+ <Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>+ <DialogTrigger asChild>+ <Button variant="outline" size="sm">+ <IconCode className="m-2" />+ </Button>+ </DialogTrigger>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>cURL Command</DialogTitle>+ </DialogHeader>+ <CodeBlock language="bash" value={generateCurlCommand()} />+ </DialogContent>+ </Dialog>+ </div>+ {isLoading && <Progress value={33} className="w-full" />}+ <div className="space-y-4">+ {isLoading ? (+ Array(3)+ .fill(0)+ .map((_, index) => (+ <Card key={index}>+ <CardContent className="p-4">+ <Skeleton className="h-4 w-1/4 mb-2" />+ <Skeleton className="h-4 w-full mb-2" />+ <Skeleton className="h-4 w-full mb-2" />+ <Skeleton className="h-4 w-3/4" />+ </CardContent>+ </Card>+ ))+ ) : results.length > 0 ? (+ results.map((item, index) => (+ <Card key={index}>+ <CardContent className="p-4">+ <p className="text-sm text-gray-500">{item.type}</p>+ {renderContent(item)}+ <div className="flex flex-wrap items-center gap-2 mt-2">+ <p className="text-xs text-gray-400">+ {new Date(item.content.timestamp).toLocaleString()}+ </p>+ {/* @ts-ignore */}+ {item.content.app_name && (+ <Badge+ className="text-xs"+ onClick={() =>+ // @ts-ignore+ handleBadgeClick("app", item.content.app_name)+ }+ >+ {/* @ts-ignore */}+ {item.content.app_name}+ </Badge>+ )}+ {/* @ts-ignore */}+ {item.content.window_name && (+ <Badge+ className="text-xs"+ onClick={() =>+ // @ts-ignore+ handleBadgeClick("window", item.content.window_name)+ }+ >+ {/* @ts-ignore */}+ {item.content.window_name}+ </Badge>+ )}+ {item.content.tags &&+ item.content.tags.map((tag, index) => (+ <Badge+ key={index}+ className="text-xs"+ // onClick={() => handleBadgeClick("tag", tag)}+ >+ {tag}+ </Badge>+ ))}+ </div>+ </CardContent>+ </Card>+ ))+ ) : (+ <p>No results found</p>+ )}+ {totalResults > 0 && (+ <div className="flex justify-between items-center mt-4">+ <Button+ onClick={handlePrevPage}+ disabled={offset === 0}+ variant="outline"+ size="sm"+ >+ <ChevronLeft className="mr-2 h-4 w-4" /> Previous+ </Button>+ <span className="text-sm text-gray-500">+ Showing {offset + 1} - {Math.min(offset + limit, totalResults)} of{" "}+ {totalResults}+ </span>+ <Button+ onClick={handleNextPage}+ disabled={offset + limit >= totalResults}+ variant="outline"+ size="sm"+ >+ Next <ChevronRight className="ml-2 h-4 w-4" />+ </Button>+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/examples/apps/screenpipe-app-tauri/components/ui/calendar.tsx b/examples/apps/screenpipe-app-tauri/components/ui/calendar.tsxnew file mode 100644index 000000000..2f0243457--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/ui/calendar.tsx@@ -0,0 +1,66 @@+"use client"++import * as React from "react"+import { ChevronLeft, ChevronRight } from "lucide-react"+import { DayPicker } from "react-day-picker"++import { cn } from "@/lib/utils"+import { buttonVariants } from "@/components/ui/button"++export type CalendarProps = React.ComponentProps<typeof DayPicker>++function Calendar({+ className,+ classNames,+ showOutsideDays = true,+ ...props+}: CalendarProps) {+ return (+ <DayPicker+ showOutsideDays={showOutsideDays}+ className={cn("p-3", className)}+ classNames={{+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",+ month: "space-y-4",+ caption: "flex justify-center pt-1 relative items-center",+ caption_label: "text-sm font-medium",+ nav: "space-x-1 flex items-center",+ nav_button: cn(+ buttonVariants({ variant: "outline" }),+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"+ ),+ nav_button_previous: "absolute left-1",+ nav_button_next: "absolute right-1",+ table: "w-full border-collapse space-y-1",+ head_row: "flex",+ head_cell:+ "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",+ row: "flex w-full mt-2",+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",+ day: cn(+ buttonVariants({ variant: "ghost" }),+ "h-9 w-9 p-0 font-normal aria-selected:opacity-100"+ ),+ day_range_end: "day-range-end",+ day_selected:+ "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",+ day_today: "bg-accent text-accent-foreground",+ day_outside:+ "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",+ day_disabled: "text-muted-foreground opacity-50",+ day_range_middle:+ "aria-selected:bg-accent aria-selected:text-accent-foreground",+ day_hidden: "invisible",+ ...classNames,+ }}+ components={{+ IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" />,+ IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" />,+ }}+ {...props}+ />+ )+}+Calendar.displayName = "Calendar"++export { Calendar }diff --git a/examples/apps/screenpipe-app-tauri/components/ui/progress.tsx b/examples/apps/screenpipe-app-tauri/components/ui/progress.tsxnew file mode 100644index 000000000..5c87ea486--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/ui/progress.tsx@@ -0,0 +1,28 @@+"use client"++import * as React from "react"+import * as ProgressPrimitive from "@radix-ui/react-progress"++import { cn } from "@/lib/utils"++const Progress = React.forwardRef<+ React.ElementRef<typeof ProgressPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>+>(({ className, value, ...props }, ref) => (+ <ProgressPrimitive.Root+ ref={ref}+ className={cn(+ "relative h-4 w-full overflow-hidden rounded-full bg-secondary",+ className+ )}+ {...props}+ >+ <ProgressPrimitive.Indicator+ className="h-full w-full flex-1 bg-primary transition-all"+ style={{ transform: `translateX(-${100 - (value || 0)}%)` }}+ />+ </ProgressPrimitive.Root>+))+Progress.displayName = ProgressPrimitive.Root.displayName++export { Progress }diff --git a/examples/apps/screenpipe-app-tauri/components/ui/slider.tsx b/examples/apps/screenpipe-app-tauri/components/ui/slider.tsxnew file mode 100644index 000000000..c31c2b3bc--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/ui/slider.tsx@@ -0,0 +1,28 @@+"use client"++import * as React from "react"+import * as SliderPrimitive from "@radix-ui/react-slider"++import { cn } from "@/lib/utils"++const Slider = React.forwardRef<+ React.ElementRef<typeof SliderPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>+>(({ className, ...props }, ref) => (+ <SliderPrimitive.Root+ ref={ref}+ className={cn(+ "relative flex w-full touch-none select-none items-center",+ className+ )}+ {...props}+ >+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">+ <SliderPrimitive.Range className="absolute h-full bg-primary" />+ </SliderPrimitive.Track>+ <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />+ </SliderPrimitive.Root>+))+Slider.displayName = SliderPrimitive.Root.displayName++export { Slider }diff --git a/examples/apps/screenpipe-app-tauri/components/video.tsx b/examples/apps/screenpipe-app-tauri/components/video.tsxnew file mode 100644index 000000000..e74f5b44f--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/video.tsx@@ -0,0 +1,109 @@+import { memo, useCallback, useEffect, useState } from "react";+import { readFile, open } from "@tauri-apps/plugin-fs";+import { Button } from "./ui/button";+import { Link } from "lucide-react";++export const VideoComponent = memo(function VideoComponent({+ filePath,+}: {+ filePath: string;+}) {+ const [mediaSrc, setMediaSrc] = useState<string | null>(null);+ const [error, setError] = useState<string | null>(null);+ const [isAudio, setIsAudio] = useState(false);++ const sanitizeFilePath = useCallback((path: string): string => {+ // Keep the full path, just remove any surrounding quotes+ return path.replace(/^["']|["']$/g, "").trim();+ }, []);+ const openFileLocation = useCallback(async () => {+ try {+ await open(sanitizeFilePath(filePath));+ } catch (error) {+ console.error("Failed to open file location:", error);+ }+ }, [filePath, sanitizeFilePath]);+ const renderFileLink = () => (+ // <Button+ // variant="outline"+ // size="sm"+ // className="mt-2 text-xs"+ // onClick={openFileLocation}+ // >+ // <Link className="w-4 h-4 mr-2" />+ // Open file location+ // </Button>+ // just a link+ <p className="mt-2 text-center text-xs text-gray-500">{filePath}</p>+ );+ useEffect(() => {+ async function loadMedia() {+ try {+ const sanitizedPath = sanitizeFilePath(filePath);+ if (!sanitizedPath) {+ throw new Error("Invalid file path");+ }++ setIsAudio(+ sanitizedPath.toLowerCase().includes("input") ||+ sanitizedPath.toLowerCase().includes("output")+ );++ const mediaData = await readFile(sanitizedPath);+ const blob = new Blob([mediaData], {+ type: isAudio ? "audio/mpeg" : "video/mp4",+ });+ setMediaSrc(URL.createObjectURL(blob));+ } catch (error) {+ console.error("Failed to load media:", error);+ setError(+ `Failed to load media: ${+ error instanceof Error ? error.message : "Unknown error"+ }`+ );+ }+ }++ loadMedia();+ return () => {+ if (mediaSrc) URL.revokeObjectURL(mediaSrc);+ };+ }, [filePath, sanitizeFilePath]);++ if (error) {+ return (+ <div className="w-full p-4 bg-red-100 border border-red-300 rounded-md">+ <p className="text-red-700">{error}</p>+ {renderFileLink()}+ </div>+ );+ }++ if (!mediaSrc) {+ return (+ <div className="w-full h-48 bg-gray-200 animate-pulse rounded-md flex items-center justify-center">+ <span className="text-gray-500">Loading media...</span>+ </div>+ );+ }++ return (+ <div className="w-full max-w-2xl text-center">+ {isAudio ? (+ <div className="bg-gray-100 p-4 rounded-md">+ <p className="mb-2 text-gray-700">Audio Device Recording</p>+ <audio controls className="w-full">+ <source src={mediaSrc} type="audio/mpeg" />+ Your browser does not support the audio element.+ </audio>+ </div>+ ) : (+ <video controls className="w-full rounded-md">+ <source src={mediaSrc} type="video/mp4" />+ Your browser does not support the video tag.+ </video>+ )}+ {renderFileLink()}+ </div>+ );+});diff --git a/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts b/examples/apps/screenpipe-app-tauri/lib/screenpipe.tsindex c13f0c8fa..3c25a726a 100644--- a/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts+++ b/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts@@ -1,5 +1,55 @@import { z } from "zod";+// Define types based on the server's schema+export type OCRContent = {+ frame_id: number;+ text: string;+ timestamp: string;+ file_path: string;+ offset_index: number;+ app_name: string;+ window_name: string;+ tags: string[];+ frame?: string;+};++export type AudioContent = {+ chunk_id: number;+ transcription: string;+ timestamp: string;+ file_path: string;+ offset_index: number;+ tags: string[];+};++export type FTSContent = {+ text_id: number;+ matched_text: string;+ frame_id: number;+ timestamp: string;+ app_name: string;+ window_name: string;+ file_path: string;+ original_frame_text?: string;+ tags: string[];+};++export type ContentItem =+ | { type: "OCR"; content: OCRContent }+ | { type: "Audio"; content: AudioContent }+ | { type: "FTS"; content: FTSContent };++export type PaginationInfo = {+ limit: number;+ offset: number;+ total: number;+};++export type ScreenpipeResponse = {+ data: ContentItem[];+ pagination: PaginationInfo;+};+export const screenpipeQuery = z.object({q: z.string()@@ -25,7 +75,7 @@ export const screenpipeQuery = z.object({.number().default(50).describe(- "Number of results to return (default: 50). Be mindful of the length of the response as it will be fed to an LLM"+ "Number of results to return. Be mindful of the length of the response as it will be fed to an LLM"),offset: z.number().default(0).describe("Offset for pagination (default: 0)"),start_time: z@@ -59,6 +109,10 @@ export const screenpipeQuery = z.object({`).optional(), // Add window_name with description+ include_frames: z+ .boolean()+ .default(false)+ .describe("Include frames in the response"),});export const screenpipeMultiQuery = z.object({@@ -67,13 +121,18 @@ export const screenpipeMultiQuery = z.object({export async function queryScreenpipeNtimes(params: z.infer<typeof screenpipeMultiQuery>-) {+): Promise<ScreenpipeResponse[]> {console.log("queryScreenpipeNtimes", params);- return Promise.all(params.queries.map(queryScreenpipe));+ const results = await Promise.all(params.queries.map(queryScreenpipe));+ return results.filter(+ (result): result is ScreenpipeResponse => result !== null+ );}// Add this new function to handle screenpipe requests-export async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {+export async function queryScreenpipe(+ params: z.infer<typeof screenpipeQuery>+): Promise<ScreenpipeResponse | null> {try {console.log("params", params);const queryParams = new URLSearchParams(@@ -95,8 +154,23 @@ export async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {throw new Error(`HTTP error! status: ${response.status} ${text}`);}const result = await response.json();- console.log("result", result);- return result;+ // remove all elements with empty text+ const resultWithNoEmptyText = {+ ...result,+ data: result.data.filter(+ (element: any) =>+ (element.content?.text !== undefined &&+ element.content?.text !== null &&+ element.content?.text?.length > 100) ||+ // same for .transcription+ (element.content?.transcription !== undefined &&+ element.content?.transcription !== null &&+ element.content?.transcription?.length > 10)+ ),+ };+ console.log("result", resultWithNoEmptyText);+ console.log("result", resultWithNoEmptyText.data.length);+ return resultWithNoEmptyText;} catch (error) {console.error("Error querying screenpipe:", error);return null;diff --git a/examples/apps/screenpipe-app-tauri/package.json b/examples/apps/screenpipe-app-tauri/package.jsonindex 38d6281fa..29429bc21 100644--- a/examples/apps/screenpipe-app-tauri/package.json+++ b/examples/apps/screenpipe-app-tauri/package.json@@ -20,9 +20,11 @@"@radix-ui/react-icons": "^1.3.0","@radix-ui/react-label": "^2.1.0","@radix-ui/react-popover": "^1.1.1",+ "@radix-ui/react-progress": "^1.1.0","@radix-ui/react-scroll-area": "^1.1.0","@radix-ui/react-select": "^2.1.1","@radix-ui/react-separator": "^1.1.0",+ "@radix-ui/react-slider": "^1.2.0","@radix-ui/react-slot": "^1.1.0","@radix-ui/react-switch": "^1.1.0","@radix-ui/react-tabs": "^1.1.0",@@ -43,12 +45,14 @@"class-variance-authority": "^0.7.0","clsx": "^2.1.1","cmdk": "1.0.0",+ "date-fns": "^3.6.0","lucide-react": "^0.414.0","next": "14.2.4","ollama-ai-provider": "^0.11.0","openai": "^4.53.0","posthog-js": "^1.154.6","react": "^18",+ "react-day-picker": "8.10.1","react-dom": "^18","react-markdown": "^9.0.1","react-syntax-highlighter": "^15.5.0",diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex ca32a0a69..a382397c1 100644--- a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.1.91"+version = "0.1.912"description = ""authors = ["you"]license = ""diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json b/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.jsonindex 8f72529fb..426db93b5 100644--- a/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json+++ b/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json@@ -21,6 +21,7 @@"store:allow-load","shell:allow-open","fs:allow-watch",+ "fs:allow-open","fs:default","fs:allow-read-file","fs:allow-read-dir",diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json b/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.jsonindex e0e65c78b..95c85ef4c 100644--- a/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json+++ b/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json@@ -1 +1 @@-{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:default","process:allow-restart","process:allow-exit","notification:default","core:resources:default","core:menu:default","core:tray:default","shell:default","store:allow-get","store:allow-set","store:allow-save","store:allow-load","shell:allow-open","fs:allow-watch","fs:default","fs:allow-read-file","fs:allow-read-dir","fs:allow-read","fs:allow-write-file","fs:read-dirs","fs:allow-copy-file","fs:allow-exists","fs:allow-read-text-file","fs:allow-create","fs:allow-mkdir",{"identifier":"fs:scope","allow":[{"path":"$XDG_DATA_HOME","requireLiteralLeadingDot":false},{"path":"$XDG_DATA_HOME/**","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/*","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/*","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/**","requireLiteralLeadingDot":false},{"path":"$APPDATA/*","requireLiteralLeadingDot":false},{"path":"$APPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPCONFIG/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$HOME/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$APP/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/data/**","requireLiteralLeadingDot":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"cli:default","shell:default","dialog:default","updater:default","os:default","os:allow-arch","os:allow-hostname","os:allow-os-type","core:path:default","process:default"]}}\ No newline at end of file+{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:default","process:allow-restart","process:allow-exit","notification:default","core:resources:default","core:menu:default","core:tray:default","shell:default","store:allow-get","store:allow-set","store:allow-save","store:allow-load","shell:allow-open","fs:allow-watch","fs:allow-open","fs:default","fs:allow-read-file","fs:allow-read-dir","fs:allow-read","fs:allow-write-file","fs:read-dirs","fs:allow-copy-file","fs:allow-exists","fs:allow-read-text-file","fs:allow-create","fs:allow-mkdir",{"identifier":"fs:scope","allow":[{"path":"$XDG_DATA_HOME","requireLiteralLeadingDot":false},{"path":"$XDG_DATA_HOME/**","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/*","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/*","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/**","requireLiteralLeadingDot":false},{"path":"$APPDATA/*","requireLiteralLeadingDot":false},{"path":"$APPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPCONFIG/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$HOME/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$APP/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/data/**","requireLiteralLeadingDot":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"cli:default","shell:default","dialog:default","updater:default","os:default","os:allow-arch","os:allow-hostname","os:allow-os-type","core:path:default","process:default"]}}\ No newline at end of file