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(ui): add collapsible search history sidebar (#606)
David Anyatonwu2f5ce39b2865
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.ymlindex 89b49c8dc..90efffa57 100644--- a/.github/workflows/release-app.yml+++ b/.github/workflows/release-app.yml@@ -54,7 +54,7 @@ jobs:target: aarch64-apple-darwintauri-args: "--target aarch64-apple-darwin"- platform: "macos-latest" # for Intel based macs.- args: "--target x86_64-apple-darwin --features metal,beta"+ args: "--target x86_64-apple-darwin --features metal,beta,mkl"target: x86_64-apple-darwintauri-args: "--target x86_64-apple-darwin"- platform: "ubuntu-22.04" # Ubuntu x86_64@@ -267,6 +267,7 @@ jobs:CARGO_PROFILE_RELEASE_CODEGEN_UNITS: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && '16' || matrix.platform == 'ubuntu-22.04' && '1' || '16' }}# Enable incremental compilation for WindowsCARGO_INCREMENTAL: ${{ matrix.args == '--target x86_64-pc-windows-msvc' && '1' || '0' }}+RUSTFLAGS: "-A warnings"with:args: ${{ matrix.tauri-args }}diff --git a/examples/typescript/archive/vercel-ai-chatbot/components/header.tsx b/examples/typescript/archive/vercel-ai-chatbot/components/header.tsxindex 3b41a04a4..593defb50 100644--- a/examples/typescript/archive/vercel-ai-chatbot/components/header.tsx+++ b/examples/typescript/archive/vercel-ai-chatbot/components/header.tsx@@ -23,7 +23,7 @@ async function UserOrLogin() {{session?.user ? (<><SidebarMobile>- <ChatHistory userId={session.user.id} />+ {/* <ChatHistory userId={session.user.id} /> */}</SidebarMobile><SidebarToggle /></>diff --git a/screenpipe-app-tauri/.gitignore b/screenpipe-app-tauri/.gitignoreindex f63a29cb7..df7f78aa4 100644--- a/screenpipe-app-tauri/.gitignore+++ b/screenpipe-app-tauri/.gitignore@@ -41,6 +41,7 @@ next-env.d.tsffmpeg**src-tauri/screenpipe**src-tauri/tesseract*+*src-tauri/deno*+*src-tauri/ollama**src-tauri/bun**src-tauri/ollama*-diff --git a/screenpipe-app-tauri/app/globals.css b/screenpipe-app-tauri/app/globals.cssindex 73dad61b1..c58facc73 100644--- a/screenpipe-app-tauri/app/globals.css+++ b/screenpipe-app-tauri/app/globals.css@@ -43,6 +43,22 @@--color-4: 195 100% 63%;--color-5: 90 100% 63%;++ --sidebar-background: 0 0% 98%;++ --sidebar-foreground: 240 5.3% 26.1%;++ --sidebar-primary: 240 5.9% 10%;++ --sidebar-primary-foreground: 0 0% 98%;++ --sidebar-accent: 240 4.8% 95.9%;++ --sidebar-accent-foreground: 240 5.9% 10%;++ --sidebar-border: 220 13% 91%;++ --sidebar-ring: 217.2 91.2% 59.8%;}.dark {@@ -78,6 +94,14 @@--color-3: 210 100% 63%;--color-4: 195 100% 63%;--color-5: 90 100% 63%;+ --sidebar-background: 240 5.9% 10%;+ --sidebar-foreground: 240 4.8% 95.9%;+ --sidebar-primary: 224.3 76.3% 48%;+ --sidebar-primary-foreground: 0 0% 100%;+ --sidebar-accent: 240 3.7% 15.9%;+ --sidebar-accent-foreground: 240 4.8% 95.9%;+ --sidebar-border: 240 3.7% 15.9%;+ --sidebar-ring: 217.2 91.2% 59.8%;}}diff --git a/screenpipe-app-tauri/app/page.tsx b/screenpipe-app-tauri/app/page.tsxindex d24cab048..fa0a17a5c 100644--- a/screenpipe-app-tauri/app/page.tsx+++ b/screenpipe-app-tauri/app/page.tsx@@ -26,6 +26,11 @@ import { Separator } from "@/components/ui/separator";import Onboarding from "@/components/onboarding";import { useOnboarding } from "@/lib/hooks/use-onboarding";import { registerShortcuts } from "@/lib/shortcuts";+import { AppSidebar } from "@/components/app-sidebar";+import { SidebarProvider, SidebarInset, SidebarTrigger } from "@/components/ui/sidebar";+import { useSearchHistory } from "@/lib/hooks/use-search-history";+import { Button } from "@/components/ui/button";+import { Plus } from "lucide-react";export default function Home() {const { settings } = useSettings();@@ -33,6 +38,16 @@ export default function Home() {const { toast } = useToast();const { showOnboarding, setShowOnboarding } = useOnboarding();+ const {+ searches,+ currentSearchId,+ setCurrentSearchId,+ addSearch,+ deleteSearch,+ isCollapsed,+ toggleCollapse+ } = useSearchHistory();+useEffect(() => {registerShortcuts({showScreenpipeShortcut: settings.showScreenpipeShortcut,@@ -45,62 +60,93 @@ export default function Home() {}}, [settings.userId, posthog]);+ const handleNewSearch = () => {+ setCurrentSearchId(null);+ location.reload();+ // Add any other reset logic you need+ };+return (- <main className="flex min-h-screen flex-col items-center">- <NotificationHandler />- {showOnboarding && <Onboarding />}- {/* <UpdateNotification checkIntervalHours={3} /> */}- {/* <ScreenpipeInstanceChecker /> */}- <Header />- <div className="my-4" />- {settings.isLoading ? (- <div className="flex flex-col items-center justify-center h-full space-y-4">- <Skeleton className="w-[200px] h-[24px] rounded-full" />- <Skeleton className="w-[300px] h-[20px] rounded-full" />- <div className="grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl">- {[...Array(5)].map((_, index) => (- <Card key={index}>- <CardContent className="p-4">- <Skeleton className="w-full h-[40px]" />+ <SidebarProvider defaultOpen={false}>+ {settings.aiUrl && (+ <AppSidebar+ searches={searches}+ currentSearchId={currentSearchId}+ onSelectSearch={setCurrentSearchId}+ onDeleteSearch={deleteSearch}+ />+ )}+ <SidebarInset>+ <div className="flex flex-col items-center flex-1">+ <div className="fixed top-4 left-4 z-50 flex items-center gap-2">+ <SidebarTrigger className="h-8 w-8" />+ <Button+ variant="ghost"+ size="icon"+ onClick={handleNewSearch}+ className="h-8 w-8"+ >+ <Plus className="h-4 w-4" />+ </Button>+ </div>+ <NotificationHandler />+ {showOnboarding && <Onboarding />}+ <Header />+ <div className="my-4" />+ {settings.isLoading ? (+ <div className="flex flex-col items-center justify-center h-full space-y-4">+ <Skeleton className="w-[200px] h-[24px] rounded-full" />+ <Skeleton className="w-[300px] h-[20px] rounded-full" />+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl">+ {[...Array(5)].map((_, index) => (+ <Card key={index}>+ <CardContent className="p-4">+ <Skeleton className="w-full h-[40px]" />+ </CardContent>+ </Card>+ ))}+ </div>+ </div>+ ) : settings.aiUrl ? (+ <>+ <h1 className="text-2xl font-bold text-center mb-12">+ where pixels become magic+ </h1>+ <SearchChat+ currentSearchId={currentSearchId}+ onAddSearch={addSearch}+ searches={searches}+ />+ </>+ ) : (+ <div className="flex flex-col items-center justify-center h-[calc(80vh-200px)]">+ <Card className="w-[600px]">+ <CardHeader>+ <CardTitle>Welcome to Screenpipe playground</CardTitle>+ <CardDescription>+ Make sure to set your AI provider settings to ask questions+ about your data.+ <br />+ <br />+ <div className="aspect-w-16 aspect-h-9">+ <iframe+ src="https://www.youtube.com/embed/u2GfjvEY6tk"+ title="Onboarding Video"+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"+ allowFullScreen+ className="w-full h-[300px] rounded-lg shadow-lg"+ ></iframe>+ </div>+ </CardDescription>+ </CardHeader>+ <CardContent>+ <Settings /></CardContent></Card>- ))}- </div>- </div>- ) : settings.aiUrl ? (- <>- <h1 className="text-2xl font-bold text-center mb-12">- where pixels become magic- </h1>- <SearchChat />- </>- ) : (- <div className="flex flex-col items-center justify-center h-[calc(80vh-200px)]">- <Card className="w-[600px]">- <CardHeader>- <CardTitle>Welcome to Screenpipe playground</CardTitle>- <CardDescription>- Make sure to set your AI provider settings to ask questions- about your data.- <br />- <br />- <div className="aspect-w-16 aspect-h-9">- <iframe- src="https://www.youtube.com/embed/u2GfjvEY6tk"- title="Onboarding Video"- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"- allowFullScreen- className="w-full h-[300px] rounded-lg shadow-lg"- ></iframe>- </div>- </CardDescription>- </CardHeader>- <CardContent>- <Settings />- </CardContent>- </Card>+ </div>+ )}</div>- )}- </main>+ </SidebarInset>+ </SidebarProvider>);-}+}\ No newline at end of filediff --git a/screenpipe-app-tauri/components/app-sidebar.tsx b/screenpipe-app-tauri/components/app-sidebar.tsxnew file mode 100644index 000000000..7b7154172--- /dev/null+++ b/screenpipe-app-tauri/components/app-sidebar.tsx@@ -0,0 +1,102 @@+import { History, Trash2 } from "lucide-react"+import { formatDistanceToNow } from "date-fns"+import {+ Sidebar,+ SidebarContent,+ SidebarGroup,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuAction,+} from "@/components/ui/sidebar"+import { ScrollArea } from "@/components/ui/scroll-area"+import { SearchHistory } from "@/lib/types/history"+import { cn } from "@/lib/utils"++interface AppSidebarProps {+ searches?: SearchHistory[]+ currentSearchId?: string | null+ onSelectSearch?: (id: string) => void+ onDeleteSearch?: (id: string) => void+}++export function AppSidebar({+ searches = [],+ currentSearchId,+ onSelectSearch,+ onDeleteSearch,+}: AppSidebarProps) {+ return (+ <Sidebar className="border-r bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">+ <SidebarContent className="pt-12">+ <ScrollArea className="h-[calc(100vh-4rem)]">+ <SidebarGroup>+ <SidebarGroupLabel className="px-4 py-2 text-xs font-medium text-muted-foreground/70">+ search history+ </SidebarGroupLabel>+ <SidebarGroupContent>+ <SidebarMenu className="space-y-0.5 px-2">+ {searches.length === 0 ? (+ <div className="px-4 py-2 text-sm text-muted-foreground">+ no searches yet+ </div>+ ) : (+ searches.map((search) => (+ <SidebarMenuItem+ key={search.id}+ className={cn(+ "group relative",+ "after:absolute after:bottom-0 after:left-3 after:right-3 after:h-px after:bg-border",+ "last:after:hidden" // Hide border on last item+ )}+ >+ <SidebarMenuButton+ isActive={currentSearchId === search.id}+ onClick={() => onSelectSearch?.(search.id)}+ tooltip={search.query || "untitled search"}+ className={cn(+ "relative w-full px-3 py-7 text-sm outline-none transition-colors",+ "hover:bg-accent/40 group/button",+ currentSearchId === search.id && "bg-accent/50"+ )}+ >+ <div className="flex flex-col gap-1 min-w-0 pr-8"> {/* Added right padding for delete icon */}+ <span className="truncate font-medium">+ {search.query || "untitled search"}+ </span>+ <span className="text-[11px] text-muted-foreground/80 truncate">+ {formatDistanceToNow(new Date(search.timestamp), {+ addSuffix: true,+ })}+ </span>+ </div>+ <SidebarMenuAction+ onClick={(e) => {+ e.stopPropagation()+ onDeleteSearch?.(search.id)+ }}+ showOnHover+ className={cn(+ "absolute right-3 top-1/2 -translate-y-1/2",+ "opacity-0 transition-all duration-200",+ "group-hover/button:opacity-100",+ "hover:bg-background/80 hover:text-destructive",+ "h-7 w-7 rounded-md flex items-center justify-center"+ )}+ >+ <Trash2 className="h-4 w-4" />+ </SidebarMenuAction>+ </SidebarMenuButton>+ </SidebarMenuItem>+ ))+ )}+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ </ScrollArea>+ </SidebarContent>+ </Sidebar>+ )+}\ No newline at end of filediff --git a/screenpipe-app-tauri/components/chat-message-v2.tsx b/screenpipe-app-tauri/components/chat-message-v2.tsxindex 4b5f78d98..2dee23299 100644--- a/screenpipe-app-tauri/components/chat-message-v2.tsx+++ b/screenpipe-app-tauri/components/chat-message-v2.tsx@@ -20,9 +20,13 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {const hasMP4File = (content: string) =>content.trim().toLowerCase().includes(".mp4");+ if (!message?.content?.trim()) {+ return null;+ }+return (<div- className={cn("group relative mb-4 flex items-start w-full")}+ className={cn("group relative mb-4 flex items-start w-full")}{...props}><divdiff --git a/screenpipe-app-tauri/components/header.tsx b/screenpipe-app-tauri/components/header.tsxindex c60d3c03d..625dd46ed 100644--- a/screenpipe-app-tauri/components/header.tsx+++ b/screenpipe-app-tauri/components/header.tsx@@ -119,7 +119,7 @@ export default function Header() {) : (<><div className="absolute left-8 top-4">- <TooltipProvider>+ {/* <TooltipProvider><Tooltip><TooltipTrigger asChild><Button@@ -136,7 +136,7 @@ export default function Header() {<p>New chat</p></TooltipContent></Tooltip>- </TooltipProvider>+ </TooltipProvider> */}</div><div className="relative z-[-1] flex flex-col items-center"><div className="relative flex flex-col items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px] gap-4">diff --git a/screenpipe-app-tauri/components/search-chat.tsx b/screenpipe-app-tauri/components/search-chat.tsxindex 496faa33b..5d78a1ee8 100644--- a/screenpipe-app-tauri/components/search-chat.tsx+++ b/screenpipe-app-tauri/components/search-chat.tsx@@ -79,6 +79,18 @@ import { ExampleSearch, ExampleSearchCards } from "./example-search-cards";import { useDebounce } from "@/lib/hooks/use-debounce";import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";import { useHealthCheck } from "@/lib/hooks/use-health-check";+import { SearchHistory } from "@/lib/types/history";++++interface SearchChatProps {+ currentSearchId: string | null;+ onAddSearch: (searchParams: any, results: any[]) => Promise<string>;+ searches: SearchHistory[];+}++export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchChatProps) {+interface Agent {id: string;@@ -149,7 +161,6 @@ const AGENTS: Agent[] = [},];-export function SearchChat() {// Search stateconst { health } = useHealthCheck();const [query, setQuery] = useState("");@@ -430,7 +441,10 @@ export function SearchChat() {role: "user" as const,content: floatingInput,};- setChatMessages((prevMessages) => [...prevMessages, userMessage]);+ setChatMessages((prevMessages) => [+ ...prevMessages,+ { id: generateId(), role: "assistant", content: "" },+ ]);setFloatingInput("");setIsAiLoading(true);@@ -496,8 +510,8 @@ export function SearchChat() {let fullResponse = "";// @ts-ignoresetChatMessages((prevMessages) => [- ...prevMessages,- { role: "assistant", content: "" },+ ...prevMessages.slice(0, -1),+ { id: generateId(), role: "assistant", content: fullResponse },]);setIsUserScrolling(false);@@ -510,7 +524,7 @@ export function SearchChat() {// @ts-ignoresetChatMessages((prevMessages) => [...prevMessages.slice(0, -1),- { role: "assistant", content: fullResponse },+ { id: generateId(), role: "assistant", content: fullResponse },]);scrollToBottom();}@@ -565,20 +579,21 @@ export function SearchChat() {});try {- const response = await queryScreenpipe({+ const searchParams = {q: query || undefined,content_type: overrides.contentType || contentType,limit: overrides.limit || limit,offset: newOffset,- start_time:- overrides.startDate?.toISOString() || startDate.toISOString(),+ start_time: overrides.startDate?.toISOString() || startDate.toISOString(),end_time: endDate.toISOString(),app_name: overrides.appName || appName || undefined,window_name: overrides.windowName || windowName || undefined,include_frames: includeFrames,min_length: overrides.minLength || minLength,max_length: maxLength,- });+ };++ const response = await queryScreenpipe(searchParams);if (!response || !Array.isArray(response.data)) {throw new Error("invalid response data");@@ -586,6 +601,9 @@ export function SearchChat() {setResults(response.data);setTotalResults(response.pagination.total);++ // Save search to history+ await onAddSearch(searchParams, response.data);} catch (error) {console.error("search error:", error);toast({@@ -810,6 +828,41 @@ export function SearchChat() {));};+ // Add effect to restore search when currentSearchId changes+ useEffect(() => {+ if (currentSearchId) {+ const selectedSearch = searches.find(s => s.id === currentSearchId);+ if (selectedSearch) {+ // Restore search parameters+ setQuery(selectedSearch.searchParams.q || '');+ setContentType(selectedSearch.searchParams.content_type);+ setLimit(selectedSearch.searchParams.limit);+ setStartDate(new Date(selectedSearch.searchParams.start_time));+ setEndDate(new Date(selectedSearch.searchParams.end_time));+ setAppName(selectedSearch.searchParams.app_name || '');+ setWindowName(selectedSearch.searchParams.window_name || '');+ setIncludeFrames(selectedSearch.searchParams.include_frames);+ setMinLength(selectedSearch.searchParams.min_length);+ setMaxLength(selectedSearch.searchParams.max_length);++ // Restore results+ setResults(selectedSearch.results);+ setTotalResults(selectedSearch.results.length);+ setHasSearched(true);+ setShowExamples(false);++ // Restore messages if any+ if (selectedSearch.messages) {+ setChatMessages(selectedSearch.messages.map(msg => ({+ id: msg.id,+ role: msg.type === 'ai' ? 'assistant' : 'user',+ content: msg.content+ })));+ }+ }+ }+ }, [currentSearchId, searches]);+return (<div className="w-full max-w-4xl mx-auto p-4 mt-12"><div className="flex flex-wrap items-center gap-4 mb-4">@@ -1364,13 +1417,17 @@ export function SearchChat() {{results.length > 0 && <Separator className="my-8" />}- {/* Display chat messages */}- <div className="flex flex-col items-start flex-1 max-w-2xl gap-8 px-4 mx-auto ">- {chatMessages.map((msg, index) => (- <ChatMessage key={index} message={msg} />- ))}- {isAiLoading && spinner}- </div>+ {/* Display chat messages - Update this section */}+ {(chatMessages.length > 0 || isAiLoading) && (+ <>+ <div className="flex flex-col items-start flex-1 max-w-2xl gap-8 px-4 mx-auto">+ {chatMessages.map((msg, index) => (+ <ChatMessage key={index} message={msg} />+ ))}+ {isAiLoading && spinner}+ </div>+ </>+ )}{/* Scroll to Bottom Button */}{showScrollButton && (diff --git a/screenpipe-app-tauri/components/search-history-sidebar.tsx b/screenpipe-app-tauri/components/search-history-sidebar.tsxnew file mode 100644index 000000000..f5feceeab--- /dev/null+++ b/screenpipe-app-tauri/components/search-history-sidebar.tsx@@ -0,0 +1,122 @@+import { Button } from "@/components/ui/button";+import { ScrollArea } from "@/components/ui/scroll-area";+import { cn } from "@/lib/utils";+import { Plus, Trash2, History } from "lucide-react";+import { formatDistanceToNow } from "date-fns";+import { SearchHistory } from "@/lib/types/history";+++interface SearchHistorySidebarProps {+ searches: SearchHistory[];+ currentSearchId: string | null;+ onSelectSearch: (id: string) => void;+ onDeleteSearch: (id: string) => void;+ isCollapsed: boolean;+ onToggleCollapse: () => void;+ onNewSearch?: () => void;+}++export default function SearchHistorySidebar({+ searches,+ currentSearchId,+ onSelectSearch,+ onDeleteSearch,+ isCollapsed,+ onToggleCollapse,+ onNewSearch,+}: SearchHistorySidebarProps) {+ return (+ <>+ {/* Top left icons */}+ <div className="fixed top-4 left-4 z-50 flex items-center gap-2">+ <Button+ variant="ghost"+ size="icon"+ onClick={onToggleCollapse}+ className="h-8 w-8"+ >+ <History className="h-4 w-4" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={onNewSearch}+ className="h-8 w-8"+ >+ <Plus className="h-4 w-4" />+ </Button>+ </div>++ {/* Sidebar */}+ <div+ className={cn(+ "fixed left-0 top-0 h-screen transition-all duration-300 bg-background border-r z-40",+ isCollapsed ? "-translate-x-full md:translate-x-0 md:w-[50px]" : "translate-x-0 w-[300px]",+ "pt-16" // Add padding top to account for the icons+ )}+ >+ <div className="flex h-full flex-col">+ {/* Header */}+ {!isCollapsed && (+ <div className="px-4 py-2 border-b">+ <h2 className="text-sm font-medium">search history</h2>+ </div>+ )}++ {/* Search history list */}+ {!isCollapsed && (+ <ScrollArea className="flex-1">+ <div className="space-y-2 p-2">+ {searches.map((search) => (+ <div+ key={search.id}+ className={cn(+ "group flex items-center justify-between rounded-lg px-2 py-2 hover:bg-accent hover:text-accent-foreground cursor-pointer",+ currentSearchId === search.id && "bg-accent"+ )}+ onClick={() => onSelectSearch(search.id)}+ >+ <div className="flex-1 truncate">+ <p className="text-sm font-medium truncate">+ {search.query || "untitled search"}+ </p>+ <p className="text-xs text-muted-foreground">+ {formatDistanceToNow(new Date(search.timestamp), {+ addSuffix: true,+ })}+ </p>+ {search.messages.length > 1 && (+ <p className="text-xs text-muted-foreground mt-1">+ {search.messages.length} messages+ </p>+ )}+ </div>+ <Button+ variant="ghost"+ size="icon"+ className="opacity-0 group-hover:opacity-100 h-8 w-8"+ onClick={(e) => {+ e.stopPropagation();+ onDeleteSearch(search.id);+ }}+ >+ <Trash2 className="h-4 w-4" />+ </Button>+ </div>+ ))}+ </div>+ </ScrollArea>+ )}+ </div>+ </div>++ {/* Backdrop for mobile */}+ {!isCollapsed && (+ <div+ className="fixed inset-0 bg-background/80 backdrop-blur-sm z-30 md:hidden"+ onClick={onToggleCollapse}+ />+ )}+ </>+ );+}\ No newline at end of filediff --git a/screenpipe-app-tauri/components/ui/sidebar.tsx b/screenpipe-app-tauri/components/ui/sidebar.tsxnew file mode 100644index 000000000..eeb2d7aeb--- /dev/null+++ b/screenpipe-app-tauri/components/ui/sidebar.tsx@@ -0,0 +1,763 @@+"use client"++import * as React from "react"+import { Slot } from "@radix-ui/react-slot"+import { VariantProps, cva } from "class-variance-authority"+import { PanelLeft } from "lucide-react"++import { useIsMobile } from "@/hooks/use-mobile"+import { cn } from "@/lib/utils"+import { Button } from "@/components/ui/button"+import { Input } from "@/components/ui/input"+import { Separator } from "@/components/ui/separator"+import { Sheet, SheetContent } from "@/components/ui/sheet"+import { Skeleton } from "@/components/ui/skeleton"+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip"++const SIDEBAR_COOKIE_NAME = "sidebar:state"+const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7+const SIDEBAR_WIDTH = "16rem"+const SIDEBAR_WIDTH_MOBILE = "18rem"+const SIDEBAR_WIDTH_ICON = "3rem"+const SIDEBAR_KEYBOARD_SHORTCUT = "b"++type SidebarContext = {+ state: "expanded" | "collapsed"+ open: boolean+ setOpen: (open: boolean) => void+ openMobile: boolean+ setOpenMobile: (open: boolean) => void+ isMobile: boolean+ toggleSidebar: () => void+}++const SidebarContext = React.createContext<SidebarContext | null>(null)++function useSidebar() {+ const context = React.useContext(SidebarContext)+ if (!context) {+ throw new Error("useSidebar must be used within a SidebarProvider.")+ }++ return context+}++const SidebarProvider = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ defaultOpen?: boolean+ open?: boolean+ onOpenChange?: (open: boolean) => void+ }+>(+ (+ {+ defaultOpen = true,+ open: openProp,+ onOpenChange: setOpenProp,+ className,+ style,+ children,+ ...props+ },+ ref+ ) => {+ const isMobile = useIsMobile()+ const [openMobile, setOpenMobile] = React.useState(false)++ // This is the internal state of the sidebar.+ // We use openProp and setOpenProp for control from outside the component.+ const [_open, _setOpen] = React.useState(defaultOpen)+ const open = openProp ?? _open+ const setOpen = React.useCallback(+ (value: boolean | ((value: boolean) => boolean)) => {+ const openState = typeof value === "function" ? value(open) : value+ if (setOpenProp) {+ setOpenProp(openState)+ } else {+ _setOpen(openState)+ }++ // This sets the cookie to keep the sidebar state.+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`+ },+ [setOpenProp, open]+ )++ // Helper to toggle the sidebar.+ const toggleSidebar = React.useCallback(() => {+ return isMobile+ ? setOpenMobile((open) => !open)+ : setOpen((open) => !open)+ }, [isMobile, setOpen, setOpenMobile])++ // Adds a keyboard shortcut to toggle the sidebar.+ React.useEffect(() => {+ const handleKeyDown = (event: KeyboardEvent) => {+ if (+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&+ (event.metaKey || event.ctrlKey)+ ) {+ event.preventDefault()+ toggleSidebar()+ }+ }++ window.addEventListener("keydown", handleKeyDown)+ return () => window.removeEventListener("keydown", handleKeyDown)+ }, [toggleSidebar])++ // We add a state so that we can do data-state="expanded" or "collapsed".+ // This makes it easier to style the sidebar with Tailwind classes.+ const state = open ? "expanded" : "collapsed"++ const contextValue = React.useMemo<SidebarContext>(+ () => ({+ state,+ open,+ setOpen,+ isMobile,+ openMobile,+ setOpenMobile,+ toggleSidebar,+ }),+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]+ )++ return (+ <SidebarContext.Provider value={contextValue}>+ <TooltipProvider delayDuration={0}>+ <div+ style={+ {+ "--sidebar-width": SIDEBAR_WIDTH,+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,+ ...style,+ } as React.CSSProperties+ }+ className={cn(+ "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",+ className+ )}+ ref={ref}+ {...props}+ >+ {children}+ </div>+ </TooltipProvider>+ </SidebarContext.Provider>+ )+ }+)+SidebarProvider.displayName = "SidebarProvider"++const Sidebar = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ side?: "left" | "right"+ variant?: "sidebar" | "floating" | "inset"+ collapsible?: "offcanvas" | "icon" | "none"+ }+>(+ (+ {+ side = "left",+ variant = "sidebar",+ collapsible = "offcanvas",+ className,+ children,+ ...props+ },+ ref+ ) => {+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()++ if (collapsible === "none") {+ return (+ <div+ className={cn(+ "flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",+ className+ )}+ ref={ref}+ {...props}+ >+ {children}+ </div>+ )+ }++ if (isMobile) {+ return (+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>+ <SheetContent+ data-sidebar="sidebar"+ data-mobile="true"+ className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"+ style={+ {+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,+ } as React.CSSProperties+ }+ side={side}+ >+ <div className="flex h-full w-full flex-col">{children}</div>+ </SheetContent>+ </Sheet>+ )+ }++ return (+ <div+ ref={ref}+ className="group peer hidden md:block text-sidebar-foreground"+ data-state={state}+ data-collapsible={state === "collapsed" ? collapsible : ""}+ data-variant={variant}+ data-side={side}+ >+ {/* This is what handles the sidebar gap on desktop */}+ <div+ className={cn(+ "duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear",+ "group-data-[collapsible=offcanvas]:w-0",+ "group-data-[side=right]:rotate-180",+ variant === "floating" || variant === "inset"+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"+ )}+ />+ <div+ className={cn(+ "duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",+ side === "left"+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",+ // Adjust the padding for floating and inset variants.+ variant === "floating" || variant === "inset"+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",+ className+ )}+ {...props}+ >+ <div+ data-sidebar="sidebar"+ className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"+ >+ {children}+ </div>+ </div>+ </div>+ )+ }+)+Sidebar.displayName = "Sidebar"++const SidebarTrigger = React.forwardRef<+ React.ElementRef<typeof Button>,+ React.ComponentProps<typeof Button>+>(({ className, onClick, ...props }, ref) => {+ const { toggleSidebar } = useSidebar()++ return (+ <Button+ ref={ref}+ data-sidebar="trigger"+ variant="ghost"+ size="icon"+ className={cn("h-7 w-7", className)}+ onClick={(event) => {+ onClick?.(event)+ toggleSidebar()+ }}+ {...props}+ >+ <PanelLeft />+ <span className="sr-only">Toggle Sidebar</span>+ </Button>+ )+})+SidebarTrigger.displayName = "SidebarTrigger"++const SidebarRail = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button">+>(({ className, ...props }, ref) => {+ const { toggleSidebar } = useSidebar()++ return (+ <button+ ref={ref}+ data-sidebar="rail"+ aria-label="Toggle Sidebar"+ tabIndex={-1}+ onClick={toggleSidebar}+ title="Toggle Sidebar"+ className={cn(+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex",+ "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",+ className+ )}+ {...props}+ />+ )+})+SidebarRail.displayName = "SidebarRail"++const SidebarInset = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"main">+>(({ className, ...props }, ref) => {+ return (+ <main+ ref={ref}+ className={cn(+ "relative flex min-h-svh flex-1 flex-col bg-background",+ "peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",+ className+ )}+ {...props}+ />+ )+})+SidebarInset.displayName = "SidebarInset"++const SidebarInput = React.forwardRef<+ React.ElementRef<typeof Input>,+ React.ComponentProps<typeof Input>+>(({ className, ...props }, ref) => {+ return (+ <Input+ ref={ref}+ data-sidebar="input"+ className={cn(+ "h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",+ className+ )}+ {...props}+ />+ )+})+SidebarInput.displayName = "SidebarInput"++const SidebarHeader = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="header"+ className={cn("flex flex-col gap-2 p-2", className)}+ {...props}+ />+ )+})+SidebarHeader.displayName = "SidebarHeader"++const SidebarFooter = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="footer"+ className={cn("flex flex-col gap-2 p-2", className)}+ {...props}+ />+ )+})+SidebarFooter.displayName = "SidebarFooter"++const SidebarSeparator = React.forwardRef<+ React.ElementRef<typeof Separator>,+ React.ComponentProps<typeof Separator>+>(({ className, ...props }, ref) => {+ return (+ <Separator+ ref={ref}+ data-sidebar="separator"+ className={cn("mx-2 w-auto bg-sidebar-border", className)}+ {...props}+ />+ )+})+SidebarSeparator.displayName = "SidebarSeparator"++const SidebarContent = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="content"+ className={cn(+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",+ className+ )}+ {...props}+ />+ )+})+SidebarContent.displayName = "SidebarContent"++const SidebarGroup = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="group"+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}+ {...props}+ />+ )+})+SidebarGroup.displayName = "SidebarGroup"++const SidebarGroupLabel = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & { asChild?: boolean }+>(({ className, asChild = false, ...props }, ref) => {+ const Comp = asChild ? Slot : "div"++ return (+ <Comp+ ref={ref}+ data-sidebar="group-label"+ className={cn(+ "duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",+ className+ )}+ {...props}+ />+ )+})+SidebarGroupLabel.displayName = "SidebarGroupLabel"++const SidebarGroupAction = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button"> & { asChild?: boolean }+>(({ className, asChild = false, ...props }, ref) => {+ const Comp = asChild ? Slot : "button"++ return (+ <Comp+ ref={ref}+ data-sidebar="group-action"+ className={cn(+ "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",+ // Increases the hit area of the button on mobile.+ "after:absolute after:-inset-2 after:md:hidden",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+ )+})+SidebarGroupAction.displayName = "SidebarGroupAction"++const SidebarGroupContent = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ data-sidebar="group-content"+ className={cn("w-full text-sm", className)}+ {...props}+ />+))+SidebarGroupContent.displayName = "SidebarGroupContent"++const SidebarMenu = React.forwardRef<+ HTMLUListElement,+ React.ComponentProps<"ul">+>(({ className, ...props }, ref) => (+ <ul+ ref={ref}+ data-sidebar="menu"+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}+ {...props}+ />+))+SidebarMenu.displayName = "SidebarMenu"++const SidebarMenuItem = React.forwardRef<+ HTMLLIElement,+ React.ComponentProps<"li">+>(({ className, ...props }, ref) => (+ <li+ ref={ref}+ data-sidebar="menu-item"+ className={cn("group/menu-item relative", className)}+ {...props}+ />+))+SidebarMenuItem.displayName = "SidebarMenuItem"++const sidebarMenuButtonVariants = cva(+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",+ {+ variants: {+ variant: {+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",+ outline:+ "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",+ },+ size: {+ default: "h-8 text-sm",+ sm: "h-7 text-xs",+ lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",+ },+ },+ defaultVariants: {+ variant: "default",+ size: "default",+ },+ }+)++const SidebarMenuButton = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button"> & {+ asChild?: boolean+ isActive?: boolean+ tooltip?: string | React.ComponentProps<typeof TooltipContent>+ } & VariantProps<typeof sidebarMenuButtonVariants>+>(+ (+ {+ asChild = false,+ isActive = false,+ variant = "default",+ size = "default",+ tooltip,+ className,+ ...props+ },+ ref+ ) => {+ const Comp = asChild ? Slot : "button"+ const { isMobile, state } = useSidebar()++ const button = (+ <Comp+ ref={ref}+ data-sidebar="menu-button"+ data-size={size}+ data-active={isActive}+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}+ {...props}+ />+ )++ if (!tooltip) {+ return button+ }++ if (typeof tooltip === "string") {+ tooltip = {+ children: tooltip,+ }+ }++ return (+ <Tooltip>+ <TooltipTrigger asChild>{button}</TooltipTrigger>+ <TooltipContent+ side="right"+ align="center"+ hidden={state !== "collapsed" || isMobile}+ {...tooltip}+ />+ </Tooltip>+ )+ }+)+SidebarMenuButton.displayName = "SidebarMenuButton"++const SidebarMenuAction = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button"> & {+ asChild?: boolean+ showOnHover?: boolean+ }+>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {+ const Comp = asChild ? Slot : "button"++ return (+ <Comp+ ref={ref}+ data-sidebar="menu-action"+ className={cn(+ "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",+ // Increases the hit area of the button on mobile.+ "after:absolute after:-inset-2 after:md:hidden",+ "peer-data-[size=sm]/menu-button:top-1",+ "peer-data-[size=default]/menu-button:top-1.5",+ "peer-data-[size=lg]/menu-button:top-2.5",+ "group-data-[collapsible=icon]:hidden",+ showOnHover &&+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",+ className+ )}+ {...props}+ />+ )+})+SidebarMenuAction.displayName = "SidebarMenuAction"++const SidebarMenuBadge = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ data-sidebar="menu-badge"+ className={cn(+ "absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none",+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",+ "peer-data-[size=sm]/menu-button:top-1",+ "peer-data-[size=default]/menu-button:top-1.5",+ "peer-data-[size=lg]/menu-button:top-2.5",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+))+SidebarMenuBadge.displayName = "SidebarMenuBadge"++const SidebarMenuSkeleton = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ showIcon?: boolean+ }+>(({ className, showIcon = false, ...props }, ref) => {+ // Random width between 50 to 90%.+ const width = React.useMemo(() => {+ return `${Math.floor(Math.random() * 40) + 50}%`+ }, [])++ return (+ <div+ ref={ref}+ data-sidebar="menu-skeleton"+ className={cn("rounded-md h-8 flex gap-2 px-2 items-center", className)}+ {...props}+ >+ {showIcon && (+ <Skeleton+ className="size-4 rounded-md"+ data-sidebar="menu-skeleton-icon"+ />+ )}+ <Skeleton+ className="h-4 flex-1 max-w-[--skeleton-width]"+ data-sidebar="menu-skeleton-text"+ style={+ {+ "--skeleton-width": width,+ } as React.CSSProperties+ }+ />+ </div>+ )+})+SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton"++const SidebarMenuSub = React.forwardRef<+ HTMLUListElement,+ React.ComponentProps<"ul">+>(({ className, ...props }, ref) => (+ <ul+ ref={ref}+ data-sidebar="menu-sub"+ className={cn(+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+))+SidebarMenuSub.displayName = "SidebarMenuSub"++const SidebarMenuSubItem = React.forwardRef<+ HTMLLIElement,+ React.ComponentProps<"li">+>(({ ...props }, ref) => <li ref={ref} {...props} />)+SidebarMenuSubItem.displayName = "SidebarMenuSubItem"++const SidebarMenuSubButton = React.forwardRef<+ HTMLAnchorElement,+ React.ComponentProps<"a"> & {+ asChild?: boolean+ size?: "sm" | "md"+ isActive?: boolean+ }+>(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {+ const Comp = asChild ? Slot : "a"++ return (+ <Comp+ ref={ref}+ data-sidebar="menu-sub-button"+ data-size={size}+ data-active={isActive}+ className={cn(+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",+ size === "sm" && "text-xs",+ size === "md" && "text-sm",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+ )+})+SidebarMenuSubButton.displayName = "SidebarMenuSubButton"++export {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupAction,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarHeader,+ SidebarInput,+ SidebarInset,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuBadge,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuSkeleton,+ SidebarMenuSub,+ SidebarMenuSubButton,+ SidebarMenuSubItem,+ SidebarProvider,+ SidebarRail,+ SidebarSeparator,+ SidebarTrigger,+ useSidebar,+}diff --git a/screenpipe-app-tauri/hooks/use-mobile.tsx b/screenpipe-app-tauri/hooks/use-mobile.tsxnew file mode 100644index 000000000..2b0fe1dfe--- /dev/null+++ b/screenpipe-app-tauri/hooks/use-mobile.tsx@@ -0,0 +1,19 @@+import * as React from "react"++const MOBILE_BREAKPOINT = 768++export function useIsMobile() {+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)++ React.useEffect(() => {+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)+ const onChange = () => {+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)+ }+ mql.addEventListener("change", onChange)+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)+ return () => mql.removeEventListener("change", onChange)+ }, [])++ return !!isMobile+}diff --git a/screenpipe-app-tauri/lib/hooks/use-conversation-history.tsx b/screenpipe-app-tauri/lib/hooks/use-conversation-history.tsxnew file mode 100644index 000000000..c9c401577--- /dev/null+++ b/screenpipe-app-tauri/lib/hooks/use-conversation-history.tsx@@ -0,0 +1,104 @@+import { useEffect, useState } from 'react';+import localforage from 'localforage';+import { Conversation } from '../types/history';++const HISTORY_KEY = 'screenpipe-conversation-history';++export function useConversationHistory() {+ const [conversations, setConversations] = useState<Conversation[]>([]);+ const [currentConversationId, setCurrentConversationId] = useState<string | null>(null);+ const [isLoading, setIsLoading] = useState(true);++ useEffect(() => {+ loadConversations();+ }, []);++ const loadConversations = async () => {+ try {+ const stored = await localforage.getItem<Conversation[]>(HISTORY_KEY);+ setConversations(stored || []);+ } catch (error) {+ console.error('failed to load conversations:', error);+ }+ setIsLoading(false);+ };++ const saveConversations = async (updated: Conversation[]) => {+ try {+ await localforage.setItem(HISTORY_KEY, updated);+ setConversations(updated);+ } catch (error) {+ console.error('failed to save conversations:', error);+ }+ };++ const addMessage = async (+ conversationId: string | null,+ type: 'search' | 'ai',+ content: string,+ searchQuery?: any+ ) => {+ const timestamp = new Date().toISOString();+ const messageId = crypto.randomUUID();++ if (!conversationId) {+ // create new conversation+ const newConversation: Conversation = {+ id: crypto.randomUUID(),+ title: content.slice(0, 30) + (content.length > 30 ? '...' : ''),+ createdAt: timestamp,+ lastUpdatedAt: timestamp,+ messages: [{+ id: messageId,+ type,+ content,+ timestamp,+ searchQuery+ }]+ };++ const updated = [newConversation, ...conversations];+ await saveConversations(updated);+ setCurrentConversationId(newConversation.id);+ return newConversation.id;+ }++ // add to existing conversation+ const updated = conversations.map(conv => {+ if (conv.id === conversationId) {+ return {+ ...conv,+ lastUpdatedAt: timestamp,+ messages: [...conv.messages, {+ id: messageId,+ type,+ content,+ timestamp,+ searchQuery+ }]+ };+ }+ return conv;+ });++ await saveConversations(updated);+ return conversationId;+ };++ const deleteConversation = async (id: string) => {+ const updated = conversations.filter(c => c.id !== id);+ await saveConversations(updated);+ if (currentConversationId === id) {+ setCurrentConversationId(null);+ }+ };++ return {+ conversations,+ currentConversationId,+ setCurrentConversationId,+ addMessage,+ deleteConversation,+ isLoading+ };+}\ No newline at end of filediff --git a/screenpipe-app-tauri/lib/hooks/use-search-history.tsx b/screenpipe-app-tauri/lib/hooks/use-search-history.tsxnew file mode 100644index 000000000..cdc0a1918--- /dev/null+++ b/screenpipe-app-tauri/lib/hooks/use-search-history.tsx@@ -0,0 +1,100 @@+import { useEffect, useState } from 'react';+import localforage from 'localforage';+import { SearchHistory } from '../types/history';++const HISTORY_KEY = 'screenpipe-search-history';++export function useSearchHistory() {+ const [searches, setSearches] = useState<SearchHistory[]>([]);+ const [currentSearchId, setCurrentSearchId] = useState<string | null>(null);+ const [isLoading, setIsLoading] = useState(true);+ const [isCollapsed, setIsCollapsed] = useState(true);++ useEffect(() => {+ loadSearches();+ }, []);++ const loadSearches = async () => {+ try {+ const stored = await localforage.getItem<SearchHistory[]>(HISTORY_KEY);+ setSearches(stored || []);+ } catch (error) {+ console.error('failed to load search history:', error);+ }+ setIsLoading(false);+ };++ const saveSearches = async (updated: SearchHistory[]) => {+ try {+ await localforage.setItem(HISTORY_KEY, updated);+ setSearches(updated);+ } catch (error) {+ console.error('failed to save search history:', error);+ }+ };++ const addSearch = async (searchParams: any, results: any[]) => {+ const timestamp = new Date().toISOString();+ const newSearch: SearchHistory = {+ id: crypto.randomUUID(),+ query: searchParams.q || '',+ timestamp,+ searchParams,+ results,+ messages: [{+ id: crypto.randomUUID(),+ type: 'search' as const,+ content: searchParams.q || '',+ timestamp+ }]+ };++ const updated = [newSearch, ...searches];+ await saveSearches(updated);+ setCurrentSearchId(newSearch.id);+ return newSearch.id;+ };++ const addAIResponse = async (searchId: string, response: string) => {+ const timestamp = new Date().toISOString();+ const updated = searches.map(search => {+ if (search.id === searchId) {+ return {+ ...search,+ messages: [...search.messages, {+ id: crypto.randomUUID(),+ type: 'ai' as const,+ content: response,+ timestamp+ }]+ };+ }+ return search;+ });+ await saveSearches(updated);+ };++ const deleteSearch = async (id: string) => {+ const updated = searches.filter(s => s.id !== id);+ await saveSearches(updated);+ if (currentSearchId === id) {+ setCurrentSearchId(null);+ }+ };++ const toggleCollapse = () => {+ setIsCollapsed(!isCollapsed);+ };++ return {+ searches,+ currentSearchId,+ setCurrentSearchId,+ addSearch,+ addAIResponse,+ deleteSearch,+ isLoading,+ isCollapsed,+ toggleCollapse+ };+}\ No newline at end of filediff --git a/screenpipe-app-tauri/lib/types/history.ts b/screenpipe-app-tauri/lib/types/history.tsnew file mode 100644index 000000000..fdbb60dc2--- /dev/null+++ b/screenpipe-app-tauri/lib/types/history.ts@@ -0,0 +1,25 @@+export interface SearchHistory {+ id: string;+ query: string;+ timestamp: string;+ searchParams: {+ q?: string;+ content_type: string;+ limit: number;+ offset: number;+ start_time: string;+ end_time: string;+ app_name?: string;+ window_name?: string;+ include_frames: boolean;+ min_length: number;+ max_length: number;+ };+ results: any[];+ messages: {+ id: string;+ type: 'search' | 'ai';+ content: string;+ timestamp: string;+ }[];+}\ No newline at end of filediff --git a/screenpipe-app-tauri/package.json b/screenpipe-app-tauri/package.jsonindex cc38464f7..d586ff510 100644--- a/screenpipe-app-tauri/package.json+++ b/screenpipe-app-tauri/package.json@@ -26,7 +26,7 @@"@radix-ui/react-avatar": "^1.1.0","@radix-ui/react-checkbox": "^1.1.1","@radix-ui/react-collapsible": "^1.1.0",- "@radix-ui/react-dialog": "^1.1.1",+ "@radix-ui/react-dialog": "^1.1.2","@radix-ui/react-dropdown-menu": "^2.1.1","@radix-ui/react-icons": "^1.3.0","@radix-ui/react-label": "^2.1.0",@@ -40,7 +40,7 @@"@radix-ui/react-switch": "^1.1.0","@radix-ui/react-tabs": "^1.1.0","@radix-ui/react-toast": "^1.2.1",- "@radix-ui/react-tooltip": "^1.1.2",+ "@radix-ui/react-tooltip": "^1.1.3","@tauri-apps/api": "^2.0.0","@tauri-apps/plugin-cli": "2.0.0","@tauri-apps/plugin-dialog": "2.0.0",diff --git a/screenpipe-app-tauri/src-tauri/src/updates.rs b/screenpipe-app-tauri/src-tauri/src/updates.rsindex 21735a3f8..67548c395 100644--- a/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -169,4 +169,4 @@ pub fn start_update_check(});Ok(updates_manager)-}+}\ No newline at end of filediff --git a/screenpipe-app-tauri/tailwind.config.ts b/screenpipe-app-tauri/tailwind.config.tsindex f1eec4e6b..4088bfe16 100644--- a/screenpipe-app-tauri/tailwind.config.ts+++ b/screenpipe-app-tauri/tailwind.config.ts@@ -9,108 +9,119 @@ module.exports = {],prefix: "",theme: {- container: {- center: "true",- padding: "2rem",- screens: {- "2xl": "1400px",- },- },- extend: {- fontFamily: {- sans: ["var(--font-geist-sans)"],- mono: ["var(--font-geist-mono)"],- },- colors: {- border: "hsl(var(--border))",- input: "hsl(var(--input))",- ring: "hsl(var(--ring))",- background: "hsl(var(--background))",- foreground: "hsl(var(--foreground))",- primary: {- DEFAULT: "hsl(var(--primary))",- foreground: "hsl(var(--primary-foreground))",- },- secondary: {- DEFAULT: "hsl(var(--secondary))",- foreground: "hsl(var(--secondary-foreground))",- },- destructive: {- DEFAULT: "hsl(var(--destructive))",- foreground: "hsl(var(--destructive-foreground))",- },- muted: {- DEFAULT: "hsl(var(--muted))",- foreground: "hsl(var(--muted-foreground))",- },- accent: {- DEFAULT: "hsl(var(--accent))",- foreground: "hsl(var(--accent-foreground))",- },- popover: {- DEFAULT: "hsl(var(--popover))",- foreground: "hsl(var(--popover-foreground))",- },- card: {- DEFAULT: "hsl(var(--card))",- foreground: "hsl(var(--card-foreground))",- },- "color-1": "hsl(var(--color-1))",- "color-2": "hsl(var(--color-2))",- "color-3": "hsl(var(--color-3))",- "color-4": "hsl(var(--color-4))",- "color-5": "hsl(var(--color-5))",- },- borderRadius: {- lg: "var(--radius)",- md: "calc(var(--radius) - 2px)",- sm: "calc(var(--radius) - 4px)",- },- keyframes: {- blink: {- "0%, 100%": { opacity: "1" },- "50%": { opacity: "0" },- },- "accordion-down": {- from: {- height: "0",- },- to: {- height: "var(--radix-accordion-content-height)",- },- },- "accordion-up": {- from: {- height: "var(--radix-accordion-content-height)",- },- to: {- height: "0",- },- },- pulse: {- "0%, 100%": {- opacity: "1",- },- "50%": {- opacity: ".5",- },- },- rainbow: {- "0%": {- "background-position": "0%",- },- "100%": {- "background-position": "200%",- },- },- },- animation: {- "accordion-down": "accordion-down 0.2s ease-out",- "accordion-up": "accordion-up 0.2s ease-out",- pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",- rainbow: "rainbow var(--speed, 2s) infinite linear",- },- },+ container: {+ center: "true",+ padding: "2rem",+ screens: {+ "2xl": "1400px",+ },+ },+ extend: {+ fontFamily: {+ sans: ["var(--font-geist-sans)"],+ mono: ["var(--font-geist-mono)"],+ },+ colors: {+ border: "hsl(var(--border))",+ input: "hsl(var(--input))",+ ring: "hsl(var(--ring))",+ background: "hsl(var(--background))",+ foreground: "hsl(var(--foreground))",+ primary: {+ DEFAULT: "hsl(var(--primary))",+ foreground: "hsl(var(--primary-foreground))",+ },+ secondary: {+ DEFAULT: "hsl(var(--secondary))",+ foreground: "hsl(var(--secondary-foreground))",+ },+ destructive: {+ DEFAULT: "hsl(var(--destructive))",+ foreground: "hsl(var(--destructive-foreground))",+ },+ muted: {+ DEFAULT: "hsl(var(--muted))",+ foreground: "hsl(var(--muted-foreground))",+ },+ accent: {+ DEFAULT: "hsl(var(--accent))",+ foreground: "hsl(var(--accent-foreground))",+ },+ popover: {+ DEFAULT: "hsl(var(--popover))",+ foreground: "hsl(var(--popover-foreground))",+ },+ card: {+ DEFAULT: "hsl(var(--card))",+ foreground: "hsl(var(--card-foreground))",+ },+ "color-1": "hsl(var(--color-1))",+ "color-2": "hsl(var(--color-2))",+ "color-3": "hsl(var(--color-3))",+ "color-4": "hsl(var(--color-4))",+ "color-5": "hsl(var(--color-5))",+ sidebar: {+ DEFAULT: "hsl(var(--sidebar-background))",+ foreground: "hsl(var(--sidebar-foreground))",+ primary: "hsl(var(--sidebar-primary))",+ "primary-foreground": "hsl(var(--sidebar-primary-foreground))",+ accent: "hsl(var(--sidebar-accent))",+ "accent-foreground": "hsl(var(--sidebar-accent-foreground))",+ border: "hsl(var(--sidebar-border))",+ ring: "hsl(var(--sidebar-ring))",+ },+ },+ borderRadius: {+ lg: "var(--radius)",+ md: "calc(var(--radius) - 2px)",+ sm: "calc(var(--radius) - 4px)",+ },+ keyframes: {+ blink: {+ "0%, 100%": { opacity: "1" },+ "50%": { opacity: "0" },+ },+ "accordion-down": {+ from: {+ height: "0",+ },+ to: {+ height: "var(--radix-accordion-content-height)",+ },+ },+ "accordion-up": {+ from: {+ height: "var(--radix-accordion-content-height)",+ },+ to: {+ height: "0",+ },+ },+ pulse: {+ "0%, 100%": {+ opacity: "1",+ },+ "50%": {+ opacity: ".5",+ },+ },+ rainbow: {+ "0%": {+ "background-position": "0%",+ },+ "100%": {+ "background-position": "200%",+ },+ },+ },+ animation: {+ "accordion-down": "accordion-down 0.2s ease-out",+ "accordion-up": "accordion-up 0.2s ease-out",+ pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",+ rainbow: "rainbow var(--speed, 2s) infinite linear",+ },+ }+},plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],};