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

simplify search

Louis Beaumontc88cc3670b3b
diff --git a/pipes/search/bun.lockb b/pipes/search/bun.lockb
index d7c6d75f0..026e332c2 100755
Binary files a/pipes/search/bun.lockb and b/pipes/search/bun.lockb differ
diff --git a/pipes/search/package.json b/pipes/search/package.json
index 69faa8a52..7b5f37a85 100644
--- a/pipes/search/package.json
+++ b/pipes/search/package.json
@@ -1,6 +1,6 @@
{
"name": "search",
- "version": "0.1.18",
+ "version": "0.1.22",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
@@ -23,8 +23,8 @@
"@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-toast": "^1.2.3",
"@radix-ui/react-tooltip": "^1.1.5",
- "@screenpipe/browser": "^0.1.33",
- "@screenpipe/js": "^1.0.12",
+ "@screenpipe/browser": "^0.1.35",
+ "@screenpipe/js": "^1.0.16",
"@shadcn/ui": "^0.0.4",
"@tanstack/react-query": "^5.62.7",
"@types/js-levenshtein": "^1.1.3",
diff --git a/pipes/search/src/components/search-chat.tsx b/pipes/search/src/components/search-chat.tsx
index 2c17c49d9..76ebfeee0 100644
--- a/pipes/search/src/components/search-chat.tsx
+++ b/pipes/search/src/components/search-chat.tsx
@@ -40,6 +40,7 @@ import {
ChevronsUpDown,
Bot,
Settings,
+ Copy,
} from "lucide-react";
import { useToast } from "@/lib/use-toast";
import { AnimatePresence, motion } from "framer-motion";
@@ -102,6 +103,10 @@ import {
} from "@/components/ui/popover";
import { useSettings } from "@/lib/hooks/use-settings";
import { SearchFilterGenerator } from "./search-filter-generator";
+import {
+ MultiSelectCombobox,
+ type BaseOption,
+} from "@/components/ui/multi-select-combobox";
interface Agent {
id: string;
@@ -273,9 +278,6 @@ export function SearchChat() {
new Set()
);
const [similarityThreshold, setSimilarityThreshold] = useState(1);
- const [hoveredResult, setHoveredResult] = useState<number | null>(null);
-
- const [isCurlDialogOpen, setIsCurlDialogOpen] = useState(false);
const [isStreaming, setIsStreaming] = useState(false);
const abortControllerRef = useRef<AbortController | null>(null);
@@ -292,6 +294,23 @@ export function SearchChat() {
const [isQueryParamsDialogOpen, setIsQueryParamsDialogOpen] = useState(false);
// Add state for individual content types
+ const [selectedContentTypes, setSelectedContentTypes] = useState<string[]>(
+ []
+ );
+
+ // Define content type options
+ const contentTypeOptions: BaseOption[] = [
+ { label: "Speech", value: "audio" },
+ { label: "Screen UI", value: "ui" },
+ { label: "Screen Capture", value: "ocr" },
+ ];
+
+ // Define content type descriptions for tooltips
+ const contentTypeDescriptions: Record<string, string> = {
+ audio: "audio transcripts",
+ ui: "text emitted directly from the source code of the desktop applications",
+ ocr: "recognized text from screenshots taken every 5s by default",
+ };
const [selectedTypes, setSelectedTypes] = useState({
ocr: false,
audio: false,
@@ -307,13 +326,12 @@ export function SearchChat() {
const [frameName, setFrameName] = useState<string>("");
+ // Add this state for browser URL
+ const [browserUrl, setBrowserUrl] = useState("");
+
useEffect(() => {
if (Object.keys(selectedSpeakers).length > 0) {
- setSelectedTypes({
- ocr: false,
- ui: false,
- audio: true,
- });
+ setSelectedContentTypes(["audio"]);
setContentType("audio");
}
}, [selectedSpeakers]);
@@ -400,44 +418,66 @@ export function SearchChat() {
};
// Update content type when checkboxes change
- const handleContentTypeChange = (type: "ocr" | "audio" | "ui") => {
- const newTypes = { ...selectedTypes, [type]: !selectedTypes[type] };
- setSelectedTypes(newTypes);
+ const handleContentTypeChange = (values: string[]) => {
+ setSelectedContentTypes(values);
- if (Object.keys(selectedSpeakers).length > 0) {
- setSelectedTypes({
- ocr: false,
- ui: false,
- audio: true,
- });
- setContentType("audio");
- }
-
- // Convert checkbox state to content type
- if (!newTypes.ocr && !newTypes.audio && !newTypes.ui) {
- setContentType("all"); // fallback to all if nothing selected
- } else if (newTypes.audio && newTypes.ui && !newTypes.ocr) {
+ // Convert selected values to content type
+ if (values.length === 0) {
+ setContentType("all");
+ } else if (values.length === 3) {
+ setContentType("all");
+ } else if (
+ values.includes("audio") &&
+ values.includes("ui") &&
+ !values.includes("ocr")
+ ) {
setContentType("audio+ui");
- } else if (newTypes.ocr && newTypes.ui && !newTypes.audio) {
+ } else if (
+ values.includes("ocr") &&
+ values.includes("ui") &&
+ !values.includes("audio")
+ ) {
setContentType("ocr+ui");
- } else if (newTypes.audio && newTypes.ocr && !newTypes.ui) {
+ } else if (
+ values.includes("audio") &&
+ values.includes("ocr") &&
+ !values.includes("ui")
+ ) {
setContentType("audio+ocr");
- } else if (newTypes.audio) {
+ } else if (values.includes("audio")) {
setContentType("audio");
- } else if (newTypes.ocr) {
+ } else if (values.includes("ocr")) {
setContentType("ocr");
- } else if (newTypes.ui) {
- setContentType("ui"); // This was missing - single UI type
+ } else if (values.includes("ui")) {
+ setContentType("ui");
} else {
setContentType("all");
}
+
+ // Update selectedTypes for backward compatibility
+ setSelectedTypes({
+ ocr: values.includes("ocr"),
+ audio: values.includes("audio"),
+ ui: values.includes("ui"),
+ });
};
const handleContentTypeFromFilter = (contentType: string) => {
// Update content type
setContentType(contentType);
- // Update checkbox states based on content type
+ // Update selected content types based on content type
+ const newSelectedTypes: string[] = [];
+ if (contentType === "all") {
+ // Keep empty to indicate all
+ } else {
+ if (contentType.includes("ocr")) newSelectedTypes.push("ocr");
+ if (contentType.includes("audio")) newSelectedTypes.push("audio");
+ if (contentType.includes("ui")) newSelectedTypes.push("ui");
+ }
+ setSelectedContentTypes(newSelectedTypes);
+
+ // Update checkbox states for backward compatibility
setSelectedTypes({
ocr: contentType.includes("ocr") || contentType === "all",
audio: contentType.includes("audio") || contentType === "all",
@@ -527,6 +567,7 @@ export function SearchChat() {
q: query,
app_name: appName,
window_name: windowName,
+ browser_url: browserUrl,
include_frames: includeFrames ? "true" : undefined,
};
@@ -827,6 +868,11 @@ export function SearchChat() {
setSimilarityThreshold(1); // Reset similarity threshold to 1
try {
+ // if browserUrl contains special characters like :, /, etc, wrap in double quotes
+ // bcs it's FTS
+ const bUrl = browserUrl.includes(":") ? `"${browserUrl}"` : browserUrl;
+ const wName = windowName.includes(":") ? `"${windowName}"` : windowName;
+ const aName = appName.includes(":") ? `"${appName}"` : appName;
const searchParams = {
q: query || undefined,
contentType: overrides.contentType || contentType,
@@ -837,6 +883,7 @@ export function SearchChat() {
endTime: endDate.toISOString(),
appName: overrides.appName || appName || undefined,
windowName: overrides.windowName || windowName || undefined,
+ browserUrl: bUrl || undefined,
includeFrames: includeFrames,
minLength: overrides.minLength || minLength,
maxLength: maxLength,
@@ -1078,7 +1125,6 @@ export function SearchChat() {
startTime={item.content.startTime}
endTime={item.content.endTime}
speaker={item.content.speaker}
-
/>
</div>
) : (
@@ -1117,6 +1163,43 @@ export function SearchChat() {
</Badge>
</div>
)}
+ {item.type === "OCR" && item.content.browserUrl && (
+ <div className="flex items-center gap-1">
+ <span className="text-xs text-muted-foreground">url:</span>
+ <div className="flex items-center">
+ <Badge
+ className="text-xs cursor-pointer "
+ title={item.content.browserUrl}
+ onClick={() =>
+ window.open(
+ item.content.browserUrl,
+ "_blank",
+ "noreferrer"
+ )
+ }
+ >
+ {new URL(item.content.browserUrl).hostname}
+ </Badge>
+ <Button
+ variant="outline"
+ size="icon"
+ className="h-5 w-5 ml-0.5"
+ onClick={(e) => {
+ e.stopPropagation();
+ navigator.clipboard.writeText(item.content.browserUrl!);
+ toast({
+ title: "copied",
+ description: "url copied to clipboard",
+ duration: 2000,
+ });
+ }}
+ title="copy url"
+ >
+ <Copy className="h-3 w-3" />
+ </Button>
+ </div>
+ </div>
+ )}
{item.type === "OCR" && item.content.windowName && (
<div className="flex items-center gap-1">
<span className="text-xs text-muted-foreground">window:</span>
@@ -1246,100 +1329,21 @@ export function SearchChat() {
/>
</div>
{/* Content Type Checkboxes and Code Button */}
- <div className="flex items-center justify-center mb-4">
- <div className="flex items-center justify-between gap-2">
- <div className="flex items-center space-x-4">
- <div className="flex items-center space-x-1">
- <Checkbox
- id="audio-type"
- checked={selectedTypes.audio}
- onCheckedChange={() => handleContentTypeChange("audio")}
- className="h-4 w-4"
- />
-
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Label htmlFor="audio-type" className="text-xs">
- speech
- </Label>
- </TooltipTrigger>
- <TooltipContent>
- <p>audio transcripts</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- {currentPlatform === "macos" && (
- <div className="flex items-center space-x-1">
- <Checkbox
- id="ui-type"
- checked={selectedTypes.ui}
- onCheckedChange={() => handleContentTypeChange("ui")}
- className="h-4 w-4"
- />
-
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Label htmlFor="ui-type" className="text-xs">
- screen UI
- </Label>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- text emitted directly from the source code of the
- desktop applications
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- )}
- <div className="flex items-center space-x-1">
- <Checkbox
- id="ocr-type"
- checked={selectedTypes.ocr}
- onCheckedChange={() => handleContentTypeChange("ocr")}
- className="h-4 w-4"
- />
-
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Label htmlFor="ocr-type" className="text-xs">
- screen capture
- </Label>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- recognized text from screenshots taken every 5s by default
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- </div>
- </div>
- </div>
-
- {/* Existing search bar and other controls */}
- <div className="flex items-center gap-4 mb-4">
- {/* Keyword search - smaller width */}
- <Input
- type="text"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- handleSearch(0);
- }
- }}
- placeholder="keyword search, you may leave it blank"
- className="w-[350px]"
- autoCorrect="off"
- autoComplete="off"
- />
+ <div className="flex items-center justify-center mb-4 gap-4">
+ {/* Remove MultiSelectCombobox from here */}
+
+ {/* Add browser URL input */}
+ {currentPlatform === "macos" && (
+ <SqlAutocompleteInput
+ id="browser-url"
+ type="url"
+ value={browserUrl}
+ onChange={setBrowserUrl}
+ placeholder="filter by browser URL"
+ className="w-[350px]"
+ icon={<Search className="h-4 w-4" />}
+ />
+ )}
{/* Window name filter - increased width */}
<SqlAutocompleteInput
@@ -1348,7 +1352,7 @@ export function SearchChat() {
value={windowName}
onChange={setWindowName}
placeholder="filter by window"
- className="w-[300px]"
+ className="w-[350px]"
icon={<Layout className="h-4 w-4" />}
/>
@@ -1418,49 +1422,8 @@ export function SearchChat() {
</TooltipProvider>
</div>
- <div className="flex flex-wrap items-center gap-4 mb-4">
- <div className="flex-grow space-y-2">
- <div className="flex items-center space-x-2">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Label htmlFor="start-date">start date</Label>
- </TooltipTrigger>
- <TooltipContent>
- <p>select the start date to search for content</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- <DateTimePicker
- date={startDate}
- setDate={setStartDate}
- className="w-full"
- />
- </div>
-
- <div className="flex-grow space-y-2">
- <div className="flex items-center space-x-2">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Label htmlFor="end-date">end date</Label>
- </TooltipTrigger>
- <TooltipContent>
- <p>select the end date to search for content</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- <DateTimePicker
- date={endDate}
- setDate={setEndDate}
- className="w-full"
- />
- </div>
- </div>
-
- <div className="flex mt-4 space-x-2 justify-center">
+ {/* Quick time filter badges */}
+ <div className="flex mt-2 mb-4 space-x-2 justify-center">
<Badge
variant="outline"
className="cursor-pointer hover:bg-secondary"
@@ -1545,6 +1508,137 @@ export function SearchChat() {
</Dialog>
</div>
+ {/* Move content type selection here */}
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="content-type" className="text-right">
+ content type
+ </Label>
+ <div className="col-span-3">
+ <MultiSelectCombobox
+ label="content type"
+ options={contentTypeOptions}
+ value={selectedContentTypes}
+ onChange={handleContentTypeChange}
+ placeholder="Filter by content type..."
+ renderItem={(option) => (
+ <div className="flex items-center justify-between w-full">
+ <span>{option.label}</span>
+ <span className="text-xs text-muted-foreground items-end">
+ {contentTypeDescriptions[option.value]}
+ </span>
+ </div>
+ )}
+ renderSelectedItem={(values) => (
+ <div className="flex gap-1 items-center">
+ {values.length === 0 ? (
+ <span>All content types</span>
+ ) : (
+ <>
+ {values.map((value) => {
+ const option = contentTypeOptions.find(
+ (opt) => opt.value === value
+ );
+ return option ? (
+ <Badge
+ key={value}
+ variant="secondary"
+ className="gap-1 px-1.5"
+ >
+ {option.label}
+ </Badge>
+ ) : null;
+ })}
+ </>
+ )}
+ </div>
+ )}
+ />
+ </div>
+ </div>
+
+ {/* Add keyword search field */}
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="keyword-search" className="text-right">
+ keyword search
+ </Label>
+ <div className="col-span-3 flex items-center">
+ <Input
+ id="keyword-search"
+ type="text"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder="search for specific keywords"
+ className="flex-grow"
+ autoCorrect="off"
+ autoComplete="off"
+ />
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircle className="h-4 w-4 text-gray-400 ml-2 cursor-help" />
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>search for specific keywords in all content</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ </div>
+
+ {/* Add browser URL field in advanced settings too */}
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="browser-url" className="text-right">
+ browser URL
+ </Label>
+ <div className="col-span-3 flex items-center">
+ <Input
+ id="browser-url"
+ type="text"
+ value={browserUrl}
+ onChange={(e) => setBrowserUrl(e.target.value)}
+ placeholder="filter by browser URL"
+ className="flex-grow"
+ />
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircle className="h-4 w-4 text-gray-400 ml-2 cursor-help" />
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>filter results by specific browser URLs</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ </div>
+
+ {/* Add date pickers here */}
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="start-date" className="text-right">
+ start date
+ </Label>
+ <div className="col-span-3">
+ <DateTimePicker
+ date={startDate}
+ setDate={setStartDate}
+ className="w-full"
+ />
+ </div>
+ </div>
+
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="end-date" className="text-right">
+ end date
+ </Label>
+ <div className="col-span-3">
+ <DateTimePicker
+ date={endDate}
+ setDate={setEndDate}
+ className="w-full"
+ />
+ </div>
+ </div>
+
{/* Rest of the advanced settings content */}
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="app-name" className="text-right">
@@ -1572,6 +1666,7 @@ export function SearchChat() {
</TooltipProvider>
</div>
</div>
+
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="min-length" className="text-right">
min length
@@ -1831,15 +1926,7 @@ export function SearchChat() {
<Button
variant="outline"
size="sm"
- onClick={() => {
- setSimilarityThreshold(similarityThreshold === 0.5 ? 1 : 0.5);
- if (similarityThreshold === 0.5) {
- setSelectedResults(
- new Set(results.map((_, index) => index))
- );
- setSelectAll(true);
- }
- }}
+ onClick={() => {}}
disabled={isFiltering}
className="flex items-center gap-2 disabled:opacity-100"
>
diff --git a/pipes/search/src/components/sql-autocomplete-input.tsx b/pipes/search/src/components/sql-autocomplete-input.tsx
index 55807bebf..d04ad1212 100644
--- a/pipes/search/src/components/sql-autocomplete-input.tsx
+++ b/pipes/search/src/components/sql-autocomplete-input.tsx
@@ -10,7 +10,7 @@ interface SqlAutocompleteInputProps {
placeholder: string;
value: string;
onChange: (value: string) => void;
- type: "app" | "window";
+ type: "app" | "window" | "url";
icon?: React.ReactNode;
className?: string;
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
@@ -128,14 +128,14 @@ export function SqlAutocompleteInput({
.filter((item) =>
item.name.toLowerCase().includes(inputValue.toLowerCase())
)
- .map((item: any) => (
+ .map((item: any, index: number) => (
<Command.Item
- key={item.name}
+ key={item.name + index}
value={item.name}
onSelect={handleSelect}
className="px-4 py-2 hover:bg-gray-100 cursor-pointer border-b border-gray-200 last:border-b-0"
>
- {item.name} ({item.count})
+ {item.name}
</Command.Item>
))
)}
diff --git a/pipes/search/src/components/ui/multi-select-combobox.tsx b/pipes/search/src/components/ui/multi-select-combobox.tsx
new file mode 100644
index 000000000..903683f3d
--- /dev/null
+++ b/pipes/search/src/components/ui/multi-select-combobox.tsx
@@ -0,0 +1,212 @@
+import React, { useState } from "react";
+
+// Third-party component imports
+import { Check, ChevronsUpDown, LoaderCircle, X } from "lucide-react";
+
+// Local UI component imports
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from "@/components/ui/command";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+
+// Utility imports
+import { cn } from "@/lib/utils";
+
+/**
+ * Base interface for option items in the multi-select combobox
+ * @property label - Display text for the option
+ * @property value - Unique identifier for the option
+ */
+export interface BaseOption {
+ label: string;
+ value: string;
+}
+
+/**
+ * Generic type for extending BaseOption with additional properties
+ */
+export type Option<T extends BaseOption = BaseOption> = T;
+
+/**
+ * Props interface for the MultiSelectCombobox component
+ * @template T - Type extending BaseOption
+ */
+interface Props<T extends BaseOption> {
+ /** Label for the combobox */
+ label: string;
+ /** Custom render function for individual options */
+ renderItem: (option: T) => React.ReactNode;
+ /** Custom render function for selected items display */
+ renderSelectedItem: (value: string[]) => React.ReactNode;
+ /** Array of available options */
+ options: T[];
+ /** Array of selected values */
+ value: string[];
+ /** Callback function when selection changes */
+ onChange: (value: string[]) => void;
+ /** Optional placeholder text for search input */
+ placeholder?: string;
+
+ isLoading?: Boolean;
+}
+
+/**
+ * A customizable multi-select combobox component with type safety
+ * @template T - Type extending BaseOption
+ */
+export const MultiSelectCombobox = <T extends BaseOption>({
+ label,
+ renderItem,
+ renderSelectedItem,
+ options,
+ value,
+ onChange,
+ placeholder,
+ isLoading,
+}: Props<T>) => {
+ // State for controlling popover visibility
+ const [open, setOpen] = useState(false);
+
+ /**
+ * Handles the selection/deselection of an option
+ * @param currentValue - The value to toggle
+ */
+ const handleChange = (currentValue: string) => {
+ onChange(
+ value.includes(currentValue)
+ ? value.filter((val) => val !== currentValue)
+ : [...value, currentValue],
+ );
+ };
+
+ /**
+ * Clears all selected values
+ */
+ const handleClear = (e: React.MouseEvent) => {
+ e.stopPropagation();
+ onChange([]);
+ };
+
+ return (
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <div
+ role="combobox"
+ aria-expanded={open}
+ aria-haspopup="listbox"
+ aria-controls="multi-select-options"
+ aria-label={`Select ${label}`}
+ tabIndex={0}
+ className="flex h-10 min-w-[200px] cursor-pointer items-center justify-start gap-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2"
+ onClick={() => setOpen(!open)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ setOpen(!open);
+ }
+ }}
+ >
+ {/* Icon and label section */}
+ {
+ //<ListFilter
+ // className="size-4 shrink-0 text-muted-foreground"
+ // aria-hidden="true"
+ ///>
+ }
+
+ {isLoading && (
+ <LoaderCircle
+ className={cn("size-4 shrink-0 text-muted-foreground hidden", {
+ "block animate-spin": isLoading,
+ })}
+ aria-hidden="true"
+ />
+ )}
+
+ {
+ // value.length > 0 && (
+ // <span className="text-muted-foreground">{label}</span>
+ //)
+ }
+
+ {/* Selected items display */}
+ <div className="flex-1 overflow-hidden h-full text-muted-foreground">
+ {value.length > 0
+ ? renderSelectedItem(value)
+ : `Filter by ${label}...`}
+ </div>
+
+ {/* Control buttons */}
+ <span className="z-10 ml-auto flex items-center gap-2">
+ {value.length > 0 && (
+ <button
+ type="button"
+ aria-label="Clear selection"
+ className="z-10 rounded-sm opacity-50 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-300"
+ onClick={handleClear}
+ >
+ <X className="size-4 shrink-0" />
+ </button>
+ )}
+ <ChevronsUpDown
+ className="size-4 shrink-0 opacity-50"
+ aria-hidden="true"
+ />
+ </span>
+ </div>
+ </PopoverTrigger>
+
+ {/* Dropdown content */}
+ <PopoverContent
+ className="w-[--radix-popover-trigger-width] p-0"
+ id="multi-select-options"
+ >
+ <Command>
+ <CommandInput
+ placeholder={placeholder || `Search ${label}...`}
+ aria-label={`Search ${label}`}
+ />
+ <CommandList>
+ <CommandEmpty>No {label} found.</CommandEmpty>
+ <CommandGroup>
+ {options.map((option) => (
+ <CommandItem
+ key={option.value}
+ value={option.label}
+ onSelect={() => handleChange(option.value)}
+ aria-selected={value.includes(option.value)}
+ className={cn({
+ "bg-accent text-accent-foreground": value.includes(
+ option.value,
+ ),
+ })}
+ >
+ {
+ //<Check
+ // className={cn(
+ // "mr-2 h-4 w-4",
+ // value.includes(option.value)
+ // ? "opacity-100"
+ // : "opacity-0",
+ // )}
+ // aria-hidden="true"
+ ///>
+ }
+ {renderItem(option)}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ );
+};
diff --git a/pipes/search/src/lib/hooks/use-sql-autocomplete.tsx b/pipes/search/src/lib/hooks/use-sql-autocomplete.tsx
index 7db3de855..0b8b7e4bb 100644
--- a/pipes/search/src/lib/hooks/use-sql-autocomplete.tsx
+++ b/pipes/search/src/lib/hooks/use-sql-autocomplete.tsx
@@ -10,7 +10,7 @@ const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
const cache: Record<string, { data: AutocompleteItem[]; timestamp: number }> =
{};
-export function useSqlAutocomplete(type: "app" | "window") {
+export function useSqlAutocomplete(type: "app" | "window" | "url") {
const [items, setItems] = useState<AutocompleteItem[]>([]);
const [isLoading, setIsLoading] = useState(false);
@@ -21,17 +21,34 @@ export function useSqlAutocomplete(type: "app" | "window") {
if (cachedData && Date.now() - cachedData.timestamp < CACHE_DURATION) {
setItems(cachedData.data);
} else {
- const query = `
- SELECT ${
- type === "app" ? "ocr.app_name" : "ocr.window_name"
- } as name, COUNT(*) as count
- FROM ocr_text ocr
- JOIN frames f ON ocr.frame_id = f.id
- WHERE f.timestamp > datetime('now', '-7 days')
- GROUP BY ${type === "app" ? "ocr.app_name" : "ocr.window_name"}
- ORDER BY count DESC
- LIMIT 100
- `;
+ let query = "";
+
+ // Select the appropriate query based on type
+ if (type === "url") {
+ query = `
+ SELECT browser_url as name, COUNT(*) as count
+ FROM frames f
+ WHERE f.timestamp > datetime('now', '-7 days')
+ AND browser_url IS NOT NULL
+ AND browser_url != ''
+ GROUP BY browser_url
+ ORDER BY count DESC
+ LIMIT 100
+ `;
+ } else {
+ query = `
+ SELECT ${
+ type === "app" ? "ocr.app_name" : "ocr.window_name"
+ } as name, COUNT(*) as count
+ FROM ocr_text ocr
+ JOIN frames f ON ocr.frame_id = f.id
+ WHERE f.timestamp > datetime('now', '-7 days')
+ GROUP BY ${type === "app" ? "ocr.app_name" : "ocr.window_name"}
+ ORDER BY count DESC
+ LIMIT 100
+ `;
+ }
+
const response = await fetch("http://localhost:3030/raw_sql", {
method: "POST",
headers: {
diff --git a/screenpipe-js/common/types.ts b/screenpipe-js/common/types.ts
index bd4430872..7e7a9c469 100644
--- a/screenpipe-js/common/types.ts
+++ b/screenpipe-js/common/types.ts
@@ -74,6 +74,7 @@ export interface OCRContent {
frame?: string;
frameName?: string;
browserUrl?: string;
+ focused?: boolean;
}
/**