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
refactor: search pipe remove visual noise, implement AI query generation, add gemini icon
Louis Beaumont8baf7e560108
diff --git a/pipes/search/package.json b/pipes/search/package.jsonindex 7d73982cc..b5f142af9 100644--- a/pipes/search/package.json+++ b/pipes/search/package.json@@ -1,6 +1,6 @@{"name": "search",- "version": "0.1.7",+ "version": "0.1.8","private": true,"scripts": {"dev": "next dev --turbopack",diff --git a/pipes/search/src/components/chat-message.tsx b/pipes/search/src/components/chat-message.tsxindex f3e67aa8f..969429bdd 100644--- a/pipes/search/src/components/chat-message.tsx+++ b/pipes/search/src/components/chat-message.tsx@@ -10,6 +10,7 @@ import {IconUser,IconOllama,IconClaude,+ IconGemini,} from "@/components/ui/icons";import { ChatMessageActions } from "@/components/chat-message-actions";import { useSettings } from "@/lib/hooks/use-settings";@@ -48,6 +49,8 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {<IconOpenAI />) : settings.aiModel.includes("claude") ? (<IconClaude />+ ) : settings.aiModel.includes("gemini") ? (+ <IconGemini />) : (<>π¦</>)}diff --git a/pipes/search/src/components/search-chat.tsx b/pipes/search/src/components/search-chat.tsxindex c141a47ae..3435ed35a 100644--- a/pipes/search/src/components/search-chat.tsx+++ b/pipes/search/src/components/search-chat.tsx@@ -1185,6 +1185,28 @@ export function SearchChat() {// Add any other reset logic you need};+ // Add this effect near other useEffect hooks+ useEffect(() => {+ const handleKeyDown = (e: KeyboardEvent) => {+ // Check for Cmd+Shift (macOS) or Ctrl+Shift (Windows/Linux)+ if (+ e.shiftKey &&+ ((currentPlatform === "macos" && e.metaKey) ||+ (currentPlatform !== "macos" && e.ctrlKey)) &&+ !e.altKey && // ensure alt/option isn't pressed+ !e.key.match(/^[a-zA-Z0-9]$/) // prevent triggering on letter/number keys+ ) {+ e.preventDefault();+ if (floatingInputRef.current && results.length > 0) {+ handleFloatingInputSubmit(new Event("submit") as any);+ }+ }+ };++ window.addEventListener("keydown", handleKeyDown);+ return () => window.removeEventListener("keydown", handleKeyDown);+ }, [currentPlatform, results.length, floatingInput, isStreaming]);+return (<div className="w-full max-w-4xl mx-auto p-4 mt-12"><div className="fixed top-4 left-4 z-50 flex items-center gap-2">@@ -1203,17 +1225,18 @@ export function SearchChat() {{/* Add the new SearchFilterGenerator component */}<SearchFilterGeneratoronApplyFilters={(filters) => {- // Update all the relevant state variables- if (filters.query !== undefined) setQuery(filters.query);- if (filters.contentType !== undefined)- handleContentTypeFromFilter(filters.contentType);- if (filters.appName !== undefined) setAppName(filters.appName);- if (filters.windowName !== undefined)- setWindowName(filters.windowName);- if (filters.startDate !== undefined)- setStartDate(filters.startDate);- if (filters.endDate !== undefined) setEndDate(filters.endDate);- if (filters.limit !== undefined) setLimit(filters.limit);+ // Always use empty string instead of undefined for text inputs+ setQuery(filters.query ?? "");+ setAppName(filters.appName ?? "");+ setWindowName(filters.windowName ?? "");++ // Use default values for other types+ handleContentTypeFromFilter(filters.contentType ?? "all");+ setStartDate(+ filters.startDate ?? new Date(Date.now() - 24 * 3600000)+ );+ setEndDate(filters.endDate ?? new Date());+ setLimit(filters.limit ?? 30);// Automatically perform search with new filtershandleSearch(0);@@ -1889,7 +1912,7 @@ export function SearchChat() {<Tooltip><TooltipTrigger><div className="text-muted-foreground">- <Bot className="h-4 w-4" />+ <Bot className="h-4 w-4 mr-2" /></div></TooltipTrigger><TooltipContent>@@ -1930,29 +1953,27 @@ export function SearchChat() {)}>- <SelectTrigger className="w-[170px] h-12">+ <SelectTrigger+ className="w-[170px] h-12"+ title={selectedAgent.description}+ ><SelectValue placeholder="select agent" /></SelectTrigger><SelectContent>{AGENTS.map((agent) => (- <SelectItem key={agent.id} value={agent.id}>+ <SelectItem+ key={agent.id}+ value={agent.id}+ title={+ AGENTS.find((a) => a.id === agent.id)?.description+ }+ ><span className="font-mono text-sm">{agent.name}</span></SelectItem>))}</SelectContent></Select>- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <HelpCircle className="h-4 w-4 text-gray-400" />- </TooltipTrigger>- <TooltipContent>- <p>{selectedAgent.description}</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>-<Buttontype="submit"className="w-12"@@ -1963,13 +1984,18 @@ export function SearchChat() {title={isAiDisabled? "Please sign in to use AI features"- : undefined+ : `${currentPlatform === "macos" ? "β" : "ctrl"}+shift`}>{isStreaming ? (<Square className="h-4 w-4" />) : (- <Send className="h-4 w-4" />+ <div className="flex items-center">+ <Send className="h-4 w-4" />+ <span className="sr-only">+ {currentPlatform === "macos" ? "β" : "ctrl"}+shift+ </span>+ </div>)}</Button>@@ -1984,29 +2010,15 @@ export function SearchChat() {</span></TooltipTrigger><TooltipContent>- <p>+ <p className="text-sm">{calculateSelectedContentLength() > MAX_CONTENT_LENGTH? `selected content exceeds maximum allowed: ${calculateSelectedContentLength()} / ${MAX_CONTENT_LENGTH} characters. unselect some items to use AI.`: `${calculateSelectedContentLength()} / ${MAX_CONTENT_LENGTH} characters used for AI message`}- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>-- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <HelpCircle className="h-4 w-4 text-muted-foreground ml-1 cursor-help" />- </TooltipTrigger>- <TooltipContent>- <p className="text-sm">- ai models can only process a limited amount of text at- once.<br />- this circle shows how much of that limit you arere- using.- <br />! the exclamation mark indicates when you exceed- the limit.+ <span className="text-muted-foreground mt-1 block">+ ai models can only process a limited amount of text at+ once. the circle indicates your current usage.+ </span></p></TooltipContent></Tooltip>diff --git a/pipes/search/src/components/search-filter-generator.tsx b/pipes/search/src/components/search-filter-generator.tsxindex d468ceed6..f76732f16 100644--- a/pipes/search/src/components/search-filter-generator.tsx+++ b/pipes/search/src/components/search-filter-generator.tsx@@ -16,10 +16,9 @@ import {import { toast } from "@/lib/use-toast";import { SheetTitle } from "./ui/sheet";import { motion } from "framer-motion";-import { z } from "zod";-import { zodResponseFormat } from "openai/helpers/zod";import { Card, CardContent } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";+import { useSqlAutocomplete } from "@/lib/hooks/use-sql-autocomplete";interface SearchFilters {query: string;@@ -37,23 +36,9 @@ interface SearchFilterGeneratorProps {interface SearchFilterVariant {filters: Partial<SearchFilters>;- description: string;title: string;}-const SearchFilterSchema = z.object({- title: z.string(),- query: z.string().optional(),- contentType: z- .enum(["all", "ocr", "audio", "ui", "audio+ui", "ocr+ui", "audio+ocr"])- .optional(),- appName: z.string().optional(),- windowName: z.string().optional(),- startDate: z.string().optional(), // ISO date string- endDate: z.string().optional(), // ISO date string- limit: z.number().optional(),-});-export function SearchFilterGenerator({onApplyFilters,}: SearchFilterGeneratorProps) {@@ -65,6 +50,8 @@ export function SearchFilterGenerator({[]);const { settings } = useSettings();+ const { items: appStats } = useSqlAutocomplete("app");+ const { items: windowStats } = useSqlAutocomplete("window");React.useEffect(() => {setIsMac(navigator.userAgent.includes("Mac"));@@ -81,12 +68,22 @@ export function SearchFilterGenerator({return () => document.removeEventListener("keydown", down);}, []);- const handleGenerateFilters = async () => {+ const handleGenerateFilters = React.useCallback(async () => {if (!prompt.trim()) return;setIsLoading(true);setFilterVariants([]);try {+ // Format top apps and windows for the prompt+ const topApps = appStats+ .slice(0, 5)+ .map((app) => `${app.name} (${app.count} occurrences)`)+ .join(", ");+ const topWindows = windowStats+ .slice(0, 5)+ .map((win) => `${win.name} (${win.count} occurrences)`)+ .join(", ");+const openai = new OpenAI({apiKey:settings.aiProviderType === "screenpipe-cloud"@@ -98,117 +95,112 @@ export function SearchFilterGenerator({const currentDate = new Date().toISOString();- const completion = await openai.beta.chat.completions.parse({+ const completion = await openai.chat.completions.create({model: settings.aiModel,messages: [{role: "system",- content: `You are a search filter generator for Screenpipe's 24/7 recording context database. Generate 3 different search filter interpretations based on the user's natural language query. The current date and time is ${currentDate}. Use this as reference when interpreting relative time expressions like "today", "last week", etc.--Key Database Tables & Content Types:--1. Screen Recording (OCR):-- Captures all visible text from screens via OCR-- Includes app_name, window_name, timestamp-- Full text search via ocr_text_fts table-- Best for finding: code snippets, documentation, browser content, chat messages, emails--2. Audio Recording:-- Transcribed speech from microphone input-- Includes speaker identification, device info-- Full text search via audio_transcriptions_fts-- Best for finding: meetings, calls, voice notes, spoken commands-- Can filter by specific speakers or devices--3. UI Monitoring:-- App and window state/focus tracking-- Includes app_name, window_name, timestamps-- Full text search via ui_monitoring_fts-- Best for: productivity analysis, app usage patterns, window switching behavior--Common Query Types & Examples:--1. Meeting & Communication:-{- query: "meet",- contentType: "audio",- startDate: "2024-03-20T09:00:00Z",- endDate: "2024-03-20T12:00:00Z",- limit: 120-}--2. Email & Messages:-{- query: "john",- contentType: "ocr",- windowName: "Gmail",- startDate: "2024-03-13T00:00:00Z",- endDate: "2024-03-20T23:59:59Z",- limit: 25-}+ content: `you are a search filter generator for screenpipe's 24/7 recording context database. your task is to generate exactly 3 search filter variations in json format.-3. Code & Development:-{- query: "transformers",- contentType: "ocr",- windowName: "Visual Studio Code",- limit: 50-}+common apps in user's database:+${topApps}-4. Productivity Analysis:-{- query: "",- contentType: "ui",- windowName: "Twitter", // Single window name, not pipe-separated- startDate: "2024-03-19T00:00:00Z",- endDate: "2024-03-19T23:59:59Z",- limit: 100-}+common window titles:+${topWindows}-5. Research & Documentation:+required output format:{- query: "papers",- contentType: "ocr+audio",- windowName: "arXiv.org", // Exact window name- limit: 30+ "variants": [+ {+ "title": string,+ "filters": {+ "query": string | undefined,+ "contentType": "all" | "ocr" | "audio",+ "appName": string | undefined,+ "windowName": string | undefined,+ "startDate": ISO date string | undefined,+ "endDate": ISO date string | undefined,+ "limit": number | undefined+ }+ },+ // exactly 2 more variations required+ ]}-Search Filter Parameters:-- query: Text to search for across content types-- contentType: "all" | "ocr" | "audio" | "ui" | "audio+ui" | "ocr+ui" | "audio+ocr"-- startDate & endDate: ISO timestamp for time range-- appName: Exact application name (e.g., "Chrome", "Code")-- windowName: Exact window title (e.g., "Gmail", "arXiv.org", or browser tab name)-- limit: Max number of results (default 100)-- speakerIds: Filter audio by specific speakers--Generation Strategy:-1. Analyze the user's query for:- - Keywords (e.g., "meeting", "code", "email", do not use spaces or multiple words). Have a bias for no keywords to prevent filtering out all content.- - Time context (today, last week, specific date)- - Content type hints (meeting β audio, code β ocr)- - App/window context (exact names, no wildcards, do not use spaces, keep empty if wants to select all)- - Length requirements (short snippets vs full content)--2. Generate 3 variations:- - Broad: Wider time range, multiple content types- - Focused: Specific content type, exact window/app name- - Balanced: Medium scope with optimal filters--Return exactly 3 JSON objects in an array with no additional text.`,+database content types:+1. screen recording (ocr)+ - all visible text from screens (may contain OCR errors)+ - includes app_name, window_name+ - best for: names, emails, urls, code, docs, chat messages+ - IMPORTANT: names/people are found in OCR (chat windows, emails, docs)+ - prefer empty query + app filters (e.g., Slack, Gmail, Chrome)++2. audio recording+ - transcribed speech from mic+ - best for: spoken discussions, meeting topics, action items+ - use query for single keywords only (no spaces!)+ - example: "roadmap" (good), "project timeline" (bad)+ - example: "sprint" (good), "daily standup" (bad)++key guidelines:+- CRITICAL: query must be single word without spaces+- current time is ${currentDate} - use for relative dates+- names/identifiers β use OCR content type (no query, just app filters)+- spoken topics β use audio content type with single-word query+- app/window names must be exact (e.g., "Chrome", "Gmail", "Slack")+- no wildcards or partial matches+- limit should be reasonable (10-200)+- dates must be valid ISO strings++search patterns:+- finding person "john" β use OCR type + apps like Slack/Gmail/Chrome (no query)+- meeting about roadmap β use audio type + query="roadmap"+- code review β use OCR type + app filter for IDE (no query)+- email from sarah β use OCR type + Gmail app filter (no query)+- slack chat β use OCR type + Slack app filter (no query)++generate these 3 variations:+1. broad:+ - wider time range+ - multiple content types+ - minimal filtering+ - empty query for OCR content++2. focused:+ - specific content type+ - exact app/window names+ - narrower time range+ - single-word query only if audio++3. balanced:+ - medium scope+ - optimal filter combination+ - most likely to match user intent+ - remember: single-word queries only++validation:+- must return exactly 3 variations+- query must be single word without spaces+- all dates must be valid ISO strings+- content types must match allowed values+- app/window names should be realistic+- limits should be reasonable numbers++do not include any explanation or additional text in the response - only the json object.`,},{role: "user",content: prompt,},],- response_format: zodResponseFormat(- z.array(SearchFilterSchema).length(3),- "search_filters"- ),+ response_format: { type: "json_object" },});- const variants = completion.choices[0].message.parsed;+ console.log(completion.choices[0].message.content);++ const { variants } = JSON.parse(+ completion.choices[0].message.content || "[]"+ ) as { variants: SearchFilterVariant[] };if (variants) {const now = new Date();const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000);@@ -216,17 +208,23 @@ Return exactly 3 JSON objects in an array with no additional text.`,setFilterVariants(variants.map((filters, i) => ({filters: {- ...filters,- startDate: filters.startDate- ? new Date(filters.startDate).toString() === "Invalid Date"+ query: filters.filters.query || "",+ contentType: filters.filters.contentType || "all",+ appName: filters.filters.appName || "",+ windowName: filters.filters.windowName || "",+ startDate: filters.filters.startDate+ ? new Date(filters.filters.startDate).toString() ===+ "Invalid Date"? yesterday- : new Date(filters.startDate)+ : new Date(filters.filters.startDate): undefined,- endDate: filters.endDate- ? new Date(filters.endDate).toString() === "Invalid Date"+ endDate: filters.filters.endDate+ ? new Date(filters.filters.endDate).toString() ===+ "Invalid Date"? now- : new Date(filters.endDate)+ : new Date(filters.filters.endDate): undefined,+ limit: filters.filters.limit || 100,},description: `variant ${i + 1}`,title: filters.title || `variant ${i + 1}`,@@ -234,7 +232,7 @@ Return exactly 3 JSON objects in an array with no additional text.`,);}} catch (error: any) {- console.error("error generating filters:", error);+ console.warn("error generating filters:", error);toast({title: "error",description: "failed to generate search filters",@@ -243,7 +241,21 @@ Return exactly 3 JSON objects in an array with no additional text.`,} finally {setIsLoading(false);}- };+ }, [prompt, settings]);++ React.useEffect(() => {+ if (!open) return;++ const handleKeyDown = (e: KeyboardEvent) => {+ if (e.key === "Enter" && !isLoading) {+ e.preventDefault();+ handleGenerateFilters();+ }+ };++ document.addEventListener("keydown", handleKeyDown);+ return () => document.removeEventListener("keydown", handleKeyDown);+ }, [open, isLoading, handleGenerateFilters]);return (<>@@ -291,34 +303,36 @@ Return exactly 3 JSON objects in an array with no additional text.`,<CommandDialog open={open} onOpenChange={setOpen}><SheetTitle></SheetTitle><motion.div- className="flex items-center justify-center gap-2 p-4"+ className="flex flex-col items-center justify-center gap-2 p-4"initial={{ opacity: 0, y: 10 }}animate={{ opacity: 1, y: 0 }}transition={{ duration: 0.2 }}>- <TooltipProvider>- <Tooltip>- <TooltipTrigger>- <Bot className="h-4 w-4 text-muted-foreground" />- </TooltipTrigger>- <TooltipContent side="left">- <p className="text-xs">using {settings.aiModel}</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- <CommandInput- className="w-full max-w-xl"- placeholder="describe what you want to search for..."- value={prompt}- onValueChange={setPrompt}- disabled={isLoading}- onKeyDown={(e) => {- if (e.key === "Enter" && !isLoading) {- e.preventDefault();- handleGenerateFilters();- }- }}- />+ <div className="flex items-center justify-center gap-2 w-full">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger>+ <Bot className="h-4 w-4 text-muted-foreground" />+ </TooltipTrigger>+ <TooltipContent side="left">+ <p className="text-xs">using {settings.aiModel}</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <CommandInput+ className="w-full max-w-xl"+ placeholder="describe what you want to search for..."+ value={prompt}+ onValueChange={setPrompt}+ disabled={isLoading}+ />+ </div>+ <div className="flex items-center gap-1 text-xs text-muted-foreground">+ <kbd className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium">+ enter+ </kbd>+ <span>to generate filters</span>+ </div></motion.div>{!isLoading && filterVariants.length === 0 && (@@ -341,7 +355,9 @@ Return exactly 3 JSON objects in an array with no additional text.`,<Badgevariant="secondary"className="cursor-pointer hover:bg-muted"- onClick={() => setPrompt("what did i discuss with john recently?")}+ onClick={() =>+ setPrompt("what did i discuss with john recently?")+ }>what did i discuss with john recently?</Badge>@@ -434,6 +450,10 @@ Return exactly 3 JSON objects in an array with no additional text.`,))}</div>)}++ <div className="p-4 text-xs text-center text-muted-foreground mt-auto">+ usually only works with openai model - check your ai settings+ </div></CommandDialog></>);diff --git a/pipes/search/src/components/ui/icons.tsx b/pipes/search/src/components/ui/icons.tsxindex a118e449b..191baf82e 100644--- a/pipes/search/src/components/ui/icons.tsx+++ b/pipes/search/src/components/ui/icons.tsx@@ -123,6 +123,46 @@ function IconClaude({ className, ...props }: React.ComponentProps<"svg">) {);}+// ... existing code ...++function IconGemini({ className, ...props }: React.ComponentProps<"svg">) {+ const id = React.useId();++ return (+ <svg+ height="1em"+ style={{ flex: "none", lineHeight: "1" }}+ viewBox="0 0 24 24"+ width="1em"+ xmlns="http://www.w3.org/2000/svg"+ className={cn("size-4", className)}+ {...props}+ >+ <title>Gemini</title>+ <defs>+ <linearGradient+ id={`gemini-gradient-${id}`}+ x1="0%"+ x2="68.73%"+ y1="100%"+ y2="30.395%"+ >+ <stop offset="0%" stopColor="#1C7DFF" />+ <stop offset="52.021%" stopColor="#1C69FF" />+ <stop offset="100%" stopColor="#F0DCD6" />+ </linearGradient>+ </defs>+ <path+ d="M12 24A14.304 14.304 0 000 12 14.304 14.304 0 0012 0a14.305 14.305 0 0012 12 14.305 14.305 0 00-12 12"+ fill={`url(#gemini-gradient-${id})`}+ fillRule="nonzero"+ />+ </svg>+ );+}++// ... existing code ...+function IconVercel({ className, ...props }: React.ComponentProps<"svg">) {return (<svg@@ -610,4 +650,5 @@ export {IconLlama,IconCode,IconClaude,+ IconGemini,};diff --git a/screenpipe-actions/ai-proxy/src/providers/openai.ts b/screenpipe-actions/ai-proxy/src/providers/openai.tsindex fe9cf4d8e..3c2d60a69 100644--- a/screenpipe-actions/ai-proxy/src/providers/openai.ts+++ b/screenpipe-actions/ai-proxy/src/providers/openai.ts@@ -21,7 +21,19 @@ export class OpenAIProvider implements AIProvider {messages,temperature: body.temperature,stream: false,- response_format: body.response_format?.type === 'json_object' ? { type: 'json_object' } : undefined,+ response_format:+ body.response_format?.type === 'json_object'+ ? { type: 'json_object' }+ : body.response_format?.type === 'json_schema'+ ? {+ type: 'json_schema',+ json_schema: {+ schema: body.response_format.schema!,+ name: body.response_format.name || 'default',+ strict: true,+ },+ }+ : undefined,tools: body.tools as ChatCompletionCreateParams['tools'],tool_choice: body.tool_choice as ChatCompletionCreateParams['tool_choice'],};@@ -38,7 +50,19 @@ export class OpenAIProvider implements AIProvider {messages: this.formatMessages(body.messages),temperature: body.temperature,stream: true,- response_format: body.response_format?.type === 'json_object' ? { type: 'json_object' } : undefined,+ response_format:+ body.response_format?.type === 'json_object'+ ? { type: 'json_object' }+ : body.response_format?.type === 'json_schema'+ ? {+ type: 'json_schema',+ json_schema: {+ schema: body.response_format.schema!,+ name: body.response_format.name || 'default',+ strict: true,+ },+ }+ : undefined,tools: body.tools as ChatCompletionCreateParams['tools'],});diff --git a/screenpipe-actions/ai-proxy/src/types.ts b/screenpipe-actions/ai-proxy/src/types.tsindex 202039dee..123557927 100644--- a/screenpipe-actions/ai-proxy/src/types.ts+++ b/screenpipe-actions/ai-proxy/src/types.ts@@ -75,8 +75,9 @@ export interface RequestBody {}export interface ResponseFormat {- type: 'text' | 'json_object';+ type: 'text' | 'json_object' | 'json_schema';schema?: Record<string, any>;+ name?: string;}export interface ImageContent {