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(chat): add persistent chat history with search and conversation management
Louis Beaumont3b9fc4af20bd
diff --git a/screenpipe-app-tauri/components/global-chat.tsx b/screenpipe-app-tauri/components/global-chat.tsxindex 07dd03d82..1eb7e4c24 100644--- a/screenpipe-app-tauri/components/global-chat.tsx+++ b/screenpipe-app-tauri/components/global-chat.tsx@@ -8,9 +8,9 @@ import { Dialog, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Button } from "@/components/ui/button";import { CustomDialogContent } from "@/components/rewind/custom-dialog-content";-import { useSettings } from "@/lib/hooks/use-settings";+import { useSettings, ChatMessage, ChatConversation } from "@/lib/hooks/use-settings";import { cn } from "@/lib/utils";-import { Loader2, Send, Square, User, X, Settings, ExternalLink, Video, Plus, Zap } from "lucide-react";+import { Loader2, Send, Square, User, X, Settings, ExternalLink, Video, Plus, Zap, History, Search, Trash2, ChevronLeft } from "lucide-react";import { toast } from "@/components/ui/use-toast";import { parseInt } from "lodash";import { motion, AnimatePresence } from "framer-motion";@@ -515,11 +515,12 @@ interface Message {id: string;role: "user" | "assistant";content: string;+ timestamp: number;}export function GlobalChat() {const [open, setOpen] = useState(false);- const { settings } = useSettings();+ const { settings, updateSettings, isSettingsLoaded } = useSettings();const pathname = usePathname();const { isMac } = usePlatform();const { selectionRange, setSelectionRange } = useTimelineSelection();@@ -553,6 +554,11 @@ export function GlobalChat() {const [upgradeReason, setUpgradeReason] = useState<"daily_limit" | "model_not_allowed">("daily_limit");const [upgradeResetsAt, setUpgradeResetsAt] = useState<string | undefined>();+ // Chat history state+ const [conversationId, setConversationId] = useState<string | null>(null);+ const [showHistory, setShowHistory] = useState(false);+ const [historySearch, setHistorySearch] = useState("");+const appMentionSuggestions = React.useMemo(() => buildAppMentionSuggestions(appItems, APP_SUGGESTION_LIMIT),[appItems]@@ -739,6 +745,174 @@ export function GlobalChat() {// eslint-disable-next-line react-hooks/exhaustive-deps}, [isOnTimeline, isExporting, selectionRange]);+ // Load active conversation from settings on mount+ useEffect(() => {+ if (!isSettingsLoaded) return;++ const history = settings.chatHistory;+ if (history?.activeConversationId && history.historyEnabled !== false) {+ const activeConv = history.conversations.find(+ c => c.id === history.activeConversationId+ );+ if (activeConv && activeConv.messages.length > 0) {+ setMessages(activeConv.messages.map(m => ({+ id: m.id,+ role: m.role,+ content: m.content,+ timestamp: m.timestamp,+ })));+ setConversationId(activeConv.id);+ }+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [isSettingsLoaded]);++ // Save conversation to settings+ const saveConversation = async (msgs: Message[]) => {+ if (!settings.chatHistory?.historyEnabled) return;+ if (msgs.length === 0) return;++ const history = settings.chatHistory || { conversations: [], activeConversationId: null, historyEnabled: true };+ const convId = conversationId || crypto.randomUUID();++ const existingIndex = history.conversations.findIndex(c => c.id === convId);+ // Use first user message for title, truncated to 50 chars+ const firstUserMsg = msgs.find(m => m.role === "user");+ const title = firstUserMsg?.content.slice(0, 50) || "New Chat";++ const conversation: ChatConversation = {+ id: convId,+ title,+ messages: msgs.slice(-100).map(m => ({+ id: m.id,+ role: m.role,+ content: m.content,+ timestamp: m.timestamp,+ })),+ createdAt: existingIndex >= 0 ? history.conversations[existingIndex].createdAt : Date.now(),+ updatedAt: Date.now(),+ };++ let newConversations = [...history.conversations];+ if (existingIndex >= 0) {+ newConversations[existingIndex] = conversation;+ } else {+ // Add new conversation at the beginning, limit to 50+ newConversations = [conversation, ...newConversations].slice(0, 50);+ }++ await updateSettings({+ chatHistory: {+ ...history,+ conversations: newConversations,+ activeConversationId: convId,+ }+ });++ if (!conversationId) {+ setConversationId(convId);+ }+ };++ // Delete a conversation+ const deleteConversation = async (convId: string) => {+ const history = settings.chatHistory;+ if (!history) return;++ const newConversations = history.conversations.filter(c => c.id !== convId);+ const newActiveId = history.activeConversationId === convId ? null : history.activeConversationId;++ await updateSettings({+ chatHistory: {+ ...history,+ conversations: newConversations,+ activeConversationId: newActiveId,+ }+ });++ // If we deleted the current conversation, clear the chat+ if (conversationId === convId) {+ setMessages([]);+ setConversationId(null);+ }+ };++ // Load a specific conversation+ const loadConversation = (conv: ChatConversation) => {+ setMessages(conv.messages.map(m => ({+ id: m.id,+ role: m.role,+ content: m.content,+ timestamp: m.timestamp,+ })));+ setConversationId(conv.id);+ setShowHistory(false);++ // Update active conversation+ if (settings.chatHistory) {+ updateSettings({+ chatHistory: {+ ...settings.chatHistory,+ activeConversationId: conv.id,+ }+ });+ }+ };++ // Start a new conversation+ const startNewConversation = () => {+ setMessages([]);+ setConversationId(null);+ setInput("");+ setShowHistory(false);+ };++ // Filter conversations by search+ const filteredConversations = React.useMemo(() => {+ const convs = settings.chatHistory?.conversations || [];+ if (!historySearch.trim()) return convs;++ const search = historySearch.toLowerCase();+ return convs.filter(c =>+ c.title.toLowerCase().includes(search) ||+ c.messages.some(m => m.content.toLowerCase().includes(search))+ );+ }, [settings.chatHistory?.conversations, historySearch]);++ // Group conversations by date+ const groupedConversations = React.useMemo(() => {+ const groups: { label: string; conversations: ChatConversation[] }[] = [];+ const now = new Date();+ const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());+ const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);+ const lastWeek = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);++ const todayConvs: ChatConversation[] = [];+ const yesterdayConvs: ChatConversation[] = [];+ const lastWeekConvs: ChatConversation[] = [];+ const olderConvs: ChatConversation[] = [];++ for (const conv of filteredConversations) {+ const convDate = new Date(conv.updatedAt);+ if (convDate >= today) {+ todayConvs.push(conv);+ } else if (convDate >= yesterday) {+ yesterdayConvs.push(conv);+ } else if (convDate >= lastWeek) {+ lastWeekConvs.push(conv);+ } else {+ olderConvs.push(conv);+ }+ }++ if (todayConvs.length > 0) groups.push({ label: "Today", conversations: todayConvs });+ if (yesterdayConvs.length > 0) groups.push({ label: "Yesterday", conversations: yesterdayConvs });+ if (lastWeekConvs.length > 0) groups.push({ label: "Last 7 Days", conversations: lastWeekConvs });+ if (olderConvs.length > 0) groups.push({ label: "Older", conversations: olderConvs });++ return groups;+ }, [filteredConversations]);+// Fetch speakers dynamically when filter changesuseEffect(() => {if (!mentionFilter || mentionFilter.length < 1) {@@ -1093,6 +1267,7 @@ export function GlobalChat() {id: Date.now().toString(),role: "user",content: displayMessage,+ timestamp: Date.now(),};const assistantMessageId = (Date.now() + 1).toString();@@ -1156,7 +1331,7 @@ export function GlobalChat() {// Add placeholder for streaming responsesetMessages((prev) => [...prev,- { id: assistantMessageId, role: "assistant", content: "" },+ { id: assistantMessageId, role: "assistant", content: "", timestamp: Date.now() },]);let accumulatedText = "";@@ -1600,6 +1775,7 @@ export function GlobalChat() {id: Date.now().toString(),role: "assistant",content: `Error: ${errorMessage}`,+ timestamp: Date.now(),},];});@@ -1607,6 +1783,16 @@ export function GlobalChat() {setIsLoading(false);setIsStreaming(false);abortControllerRef.current = null;++ // Save conversation after state updates+ setTimeout(() => {+ setMessages((currentMsgs) => {+ if (currentMsgs.length > 0) {+ saveConversation(currentMsgs);+ }+ return currentMsgs;+ });+ }, 100);}}@@ -1697,13 +1883,20 @@ export function GlobalChat() {<h2 className="font-semibold text-sm tracking-tight">Pipe AI</h2><p className="text-[10px] text-muted-foreground font-mono uppercase tracking-wider">Screen Activity Assistant</p></div>+ <Button+ variant={showHistory ? "secondary" : "ghost"}+ size="sm"+ onClick={() => setShowHistory(!showHistory)}+ className="h-7 px-2 gap-1 text-xs"+ title="Chat history"+ >+ <History size={14} />+ <span className="hidden sm:inline">History</span>+ </Button><Buttonvariant="outline"size="sm"- onClick={() => {- setMessages([]);- setInput("");- }}+ onClick={startNewConversation}className="h-7 px-2 gap-1 text-xs"title="New chat">@@ -1715,8 +1908,100 @@ export function GlobalChat() {</kbd></div>- {/* Messages - with subtle pattern background */}- <div className="relative flex-1 overflow-y-auto p-4 space-y-4">+ {/* Main content area with optional history sidebar */}+ <div className="flex-1 flex overflow-hidden">+ {/* History Sidebar */}+ <AnimatePresence>+ {showHistory && (+ <motion.div+ initial={{ width: 0, opacity: 0 }}+ animate={{ width: 280, opacity: 1 }}+ exit={{ width: 0, opacity: 0 }}+ transition={{ duration: 0.2 }}+ className="border-r border-border/50 bg-muted/30 flex flex-col overflow-hidden"+ >+ {/* History Header */}+ <div className="p-3 border-b border-border/50 space-y-2">+ <div className="flex items-center justify-between">+ <span className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Chat History</span>+ <Button+ variant="ghost"+ size="sm"+ onClick={() => setShowHistory(false)}+ className="h-6 w-6 p-0"+ >+ <ChevronLeft size={14} />+ </Button>+ </div>+ {/* Search */}+ <div className="relative">+ <Search className="absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />+ <Input+ placeholder="Search conversations..."+ value={historySearch}+ onChange={(e) => setHistorySearch(e.target.value)}+ className="h-8 pl-8 text-xs bg-background/50"+ />+ </div>+ </div>++ {/* Conversations List */}+ <div className="flex-1 overflow-y-auto p-2 space-y-3">+ {groupedConversations.length === 0 ? (+ <div className="flex flex-col items-center justify-center py-8 text-center">+ <History className="h-8 w-8 text-muted-foreground/50 mb-2" />+ <p className="text-xs text-muted-foreground">+ {historySearch ? "No matching conversations" : "No chat history yet"}+ </p>+ </div>+ ) : (+ groupedConversations.map((group) => (+ <div key={group.label} className="space-y-1">+ <p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider px-2 py-1">+ {group.label}+ </p>+ {group.conversations.map((conv) => (+ <div+ key={conv.id}+ className={cn(+ "group flex items-center gap-2 px-2 py-2 rounded-lg cursor-pointer transition-colors",+ conv.id === conversationId+ ? "bg-foreground/10"+ : "hover:bg-foreground/5"+ )}+ onClick={() => loadConversation(conv)}+ >+ <div className="flex-1 min-w-0">+ <p className="text-xs font-medium truncate">+ {conv.title}+ </p>+ <p className="text-[10px] text-muted-foreground">+ {conv.messages.length} messages+ </p>+ </div>+ <Button+ variant="ghost"+ size="sm"+ onClick={(e) => {+ e.stopPropagation();+ deleteConversation(conv.id);+ }}+ className="h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive"+ >+ <Trash2 size={12} />+ </Button>+ </div>+ ))}+ </div>+ ))+ )}+ </div>+ </motion.div>+ )}+ </AnimatePresence>++ {/* Messages - with subtle pattern background */}+ <div className="relative flex-1 overflow-y-auto p-4 space-y-4">{/* Subtle geometric background pattern */}<div className="absolute inset-0 opacity-[0.02] pointer-events-none" style={{backgroundImage: `url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23000' stroke-width='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E")`,@@ -1957,6 +2242,7 @@ export function GlobalChat() {)}<div ref={messagesEndRef} /></div>+ </div> {/* End of main content area with history sidebar */}{/* AI Preset Selector & Input - refined styling */}<div className="relative border-t border-border/50 bg-gradient-to-t from-muted/20 to-transparent">diff --git a/screenpipe-app-tauri/components/standalone-chat.tsx b/screenpipe-app-tauri/components/standalone-chat.tsxindex 0fb3cb434..2d59d2222 100644--- a/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/screenpipe-app-tauri/components/standalone-chat.tsx@@ -5,9 +5,9 @@ import { useState, useRef, useEffect, useCallback } from "react";import { listen } from "@tauri-apps/api/event";import { Input } from "@/components/ui/input";import { Button } from "@/components/ui/button";-import { useSettings } from "@/lib/hooks/use-settings";+import { useSettings, ChatMessage, ChatConversation } from "@/lib/hooks/use-settings";import { cn } from "@/lib/utils";-import { Loader2, Send, Square, User, Settings, ExternalLink, X, ImageIcon, Zap } from "lucide-react";+import { Loader2, Send, Square, User, Settings, ExternalLink, X, ImageIcon, Zap, History, Search, Trash2, ChevronLeft, Plus } from "lucide-react";import { toast } from "@/components/ui/use-toast";import { motion, AnimatePresence } from "framer-motion";import { PipeAIIcon, PipeAIIconLarge } from "@/components/pipe-ai-icon";@@ -137,10 +137,11 @@ interface Message {id: string;role: "user" | "assistant";content: string;+ timestamp: number;}export function StandaloneChat() {- const { settings } = useSettings();+ const { settings, updateSettings, isSettingsLoaded } = useSettings();const { isMac } = usePlatform();const { items: appItems } = useSqlAutocomplete("app");@@ -168,6 +169,11 @@ export function StandaloneChat() {const [isDragging, setIsDragging] = useState(false);const dragCounterRef = useRef(0);+ // Chat history state+ const [conversationId, setConversationId] = useState<string | null>(null);+ const [showHistory, setShowHistory] = useState(false);+ const [historySearch, setHistorySearch] = useState("");+// Process an image file to base64const processImageFile = useCallback((file: File) => {if (!file.type.startsWith("image/")) return;@@ -179,6 +185,171 @@ export function StandaloneChat() {reader.readAsDataURL(file);}, []);+ // Load active conversation from settings on mount+ useEffect(() => {+ if (!isSettingsLoaded) return;++ const history = settings.chatHistory;+ if (history?.activeConversationId && history.historyEnabled !== false) {+ const activeConv = history.conversations.find(+ c => c.id === history.activeConversationId+ );+ if (activeConv && activeConv.messages.length > 0) {+ setMessages(activeConv.messages.map(m => ({+ id: m.id,+ role: m.role,+ content: m.content,+ timestamp: m.timestamp,+ })));+ setConversationId(activeConv.id);+ }+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [isSettingsLoaded]);++ // Save conversation to settings+ const saveConversation = async (msgs: Message[]) => {+ if (!settings.chatHistory?.historyEnabled) return;+ if (msgs.length === 0) return;++ const history = settings.chatHistory || { conversations: [], activeConversationId: null, historyEnabled: true };+ const convId = conversationId || crypto.randomUUID();++ const existingIndex = history.conversations.findIndex(c => c.id === convId);+ const firstUserMsg = msgs.find(m => m.role === "user");+ const title = firstUserMsg?.content.slice(0, 50) || "New Chat";++ const conversation: ChatConversation = {+ id: convId,+ title,+ messages: msgs.slice(-100).map(m => ({+ id: m.id,+ role: m.role,+ content: m.content,+ timestamp: m.timestamp,+ })),+ createdAt: existingIndex >= 0 ? history.conversations[existingIndex].createdAt : Date.now(),+ updatedAt: Date.now(),+ };++ let newConversations = [...history.conversations];+ if (existingIndex >= 0) {+ newConversations[existingIndex] = conversation;+ } else {+ newConversations = [conversation, ...newConversations].slice(0, 50);+ }++ await updateSettings({+ chatHistory: {+ ...history,+ conversations: newConversations,+ activeConversationId: convId,+ }+ });++ if (!conversationId) {+ setConversationId(convId);+ }+ };++ // Delete a conversation+ const deleteConversation = async (convId: string) => {+ const history = settings.chatHistory;+ if (!history) return;++ const newConversations = history.conversations.filter(c => c.id !== convId);+ const newActiveId = history.activeConversationId === convId ? null : history.activeConversationId;++ await updateSettings({+ chatHistory: {+ ...history,+ conversations: newConversations,+ activeConversationId: newActiveId,+ }+ });++ if (conversationId === convId) {+ setMessages([]);+ setConversationId(null);+ }+ };++ // Load a specific conversation+ const loadConversation = (conv: ChatConversation) => {+ setMessages(conv.messages.map(m => ({+ id: m.id,+ role: m.role,+ content: m.content,+ timestamp: m.timestamp,+ })));+ setConversationId(conv.id);+ setShowHistory(false);++ if (settings.chatHistory) {+ updateSettings({+ chatHistory: {+ ...settings.chatHistory,+ activeConversationId: conv.id,+ }+ });+ }+ };++ // Start a new conversation+ const startNewConversation = () => {+ setMessages([]);+ setConversationId(null);+ setInput("");+ setShowHistory(false);+ setPastedImage(null);+ };++ // Filter conversations by search+ const filteredConversations = React.useMemo(() => {+ const convs = settings.chatHistory?.conversations || [];+ if (!historySearch.trim()) return convs;++ const search = historySearch.toLowerCase();+ return convs.filter(c =>+ c.title.toLowerCase().includes(search) ||+ c.messages.some(m => m.content.toLowerCase().includes(search))+ );+ }, [settings.chatHistory?.conversations, historySearch]);++ // Group conversations by date+ const groupedConversations = React.useMemo(() => {+ const groups: { label: string; conversations: ChatConversation[] }[] = [];+ const now = new Date();+ const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());+ const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);+ const lastWeek = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);++ const todayConvs: ChatConversation[] = [];+ const yesterdayConvs: ChatConversation[] = [];+ const lastWeekConvs: ChatConversation[] = [];+ const olderConvs: ChatConversation[] = [];++ for (const conv of filteredConversations) {+ const convDate = new Date(conv.updatedAt);+ if (convDate >= today) {+ todayConvs.push(conv);+ } else if (convDate >= yesterday) {+ yesterdayConvs.push(conv);+ } else if (convDate >= lastWeek) {+ lastWeekConvs.push(conv);+ } else {+ olderConvs.push(conv);+ }+ }++ if (todayConvs.length > 0) groups.push({ label: "Today", conversations: todayConvs });+ if (yesterdayConvs.length > 0) groups.push({ label: "Yesterday", conversations: yesterdayConvs });+ if (lastWeekConvs.length > 0) groups.push({ label: "Last 7 Days", conversations: lastWeekConvs });+ if (olderConvs.length > 0) groups.push({ label: "Older", conversations: olderConvs });++ return groups;+ }, [filteredConversations]);+// Handle drag events for image dropconst handleDragEnter = useCallback((e: React.DragEvent) => {e.preventDefault();@@ -625,6 +796,7 @@ export function StandaloneChat() {id: Date.now().toString(),role: "user",content: displayMessage,+ timestamp: Date.now(),};const assistantMessageId = (Date.now() + 1).toString();@@ -752,7 +924,7 @@ export function StandaloneChat() {setMessages((prev) => [...prev,- { id: assistantMessageId, role: "assistant", content: "" },+ { id: assistantMessageId, role: "assistant", content: "", timestamp: Date.now() },]);let accumulatedText = "";@@ -930,6 +1102,7 @@ export function StandaloneChat() {id: Date.now().toString(),role: "assistant",content: `Error: ${errorMessage}`,+ timestamp: Date.now(),},];});@@ -937,6 +1110,16 @@ export function StandaloneChat() {setIsLoading(false);setIsStreaming(false);abortControllerRef.current = null;++ // Save conversation after state updates+ setTimeout(() => {+ setMessages((currentMsgs) => {+ if (currentMsgs.length > 0) {+ saveConversation(currentMsgs);+ }+ return currentMsgs;+ });+ }, 100);}}@@ -984,13 +1167,131 @@ export function StandaloneChat() {<h2 className="font-semibold text-sm tracking-tight">Pipe AI</h2><p className="text-[10px] text-muted-foreground font-mono uppercase tracking-wider">Screen Activity Assistant</p></div>+ <Button+ variant={showHistory ? "secondary" : "ghost"}+ size="sm"+ onClick={(e) => {+ e.stopPropagation();+ setShowHistory(!showHistory);+ }}+ className="h-7 px-2 gap-1 text-xs"+ title="Chat history"+ >+ <History size={14} />+ <span className="hidden sm:inline">History</span>+ </Button>+ <Button+ variant="outline"+ size="sm"+ onClick={(e) => {+ e.stopPropagation();+ startNewConversation();+ }}+ className="h-7 px-2 gap-1 text-xs"+ title="New chat"+ >+ <Plus size={14} />+ <span className="hidden sm:inline">New</span>+ </Button><kbd className="hidden sm:inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-mono text-muted-foreground bg-muted/50 border border-border/50 rounded">{isMac ? "⌘⌥" : "Alt+"}L</kbd></div>- {/* Messages */}- <div className="relative flex-1 overflow-y-auto p-4 space-y-4">+ {/* Main content area with optional history sidebar */}+ <div className="flex-1 flex overflow-hidden">+ {/* History Sidebar */}+ <AnimatePresence>+ {showHistory && (+ <motion.div+ initial={{ width: 0, opacity: 0 }}+ animate={{ width: 280, opacity: 1 }}+ exit={{ width: 0, opacity: 0 }}+ transition={{ duration: 0.2 }}+ className="border-r border-border/50 bg-muted/30 flex flex-col overflow-hidden"+ >+ {/* History Header */}+ <div className="p-3 border-b border-border/50 space-y-2">+ <div className="flex items-center justify-between">+ <span className="text-xs font-medium text-muted-foreground uppercase tracking-wider">Chat History</span>+ <Button+ variant="ghost"+ size="sm"+ onClick={() => setShowHistory(false)}+ className="h-6 w-6 p-0"+ >+ <ChevronLeft size={14} />+ </Button>+ </div>+ {/* Search */}+ <div className="relative">+ <Search className="absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />+ <Input+ placeholder="Search conversations..."+ value={historySearch}+ onChange={(e) => setHistorySearch(e.target.value)}+ className="h-8 pl-8 text-xs bg-background/50"+ />+ </div>+ </div>++ {/* Conversations List */}+ <div className="flex-1 overflow-y-auto p-2 space-y-3">+ {groupedConversations.length === 0 ? (+ <div className="flex flex-col items-center justify-center py-8 text-center">+ <History className="h-8 w-8 text-muted-foreground/50 mb-2" />+ <p className="text-xs text-muted-foreground">+ {historySearch ? "No matching conversations" : "No chat history yet"}+ </p>+ </div>+ ) : (+ groupedConversations.map((group) => (+ <div key={group.label} className="space-y-1">+ <p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider px-2 py-1">+ {group.label}+ </p>+ {group.conversations.map((conv) => (+ <div+ key={conv.id}+ className={cn(+ "group flex items-center gap-2 px-2 py-2 rounded-lg cursor-pointer transition-colors",+ conv.id === conversationId+ ? "bg-foreground/10"+ : "hover:bg-foreground/5"+ )}+ onClick={() => loadConversation(conv)}+ >+ <div className="flex-1 min-w-0">+ <p className="text-xs font-medium truncate">+ {conv.title}+ </p>+ <p className="text-[10px] text-muted-foreground">+ {conv.messages.length} messages+ </p>+ </div>+ <Button+ variant="ghost"+ size="sm"+ onClick={(e) => {+ e.stopPropagation();+ deleteConversation(conv.id);+ }}+ className="h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive"+ >+ <Trash2 size={12} />+ </Button>+ </div>+ ))}+ </div>+ ))+ )}+ </div>+ </motion.div>+ )}+ </AnimatePresence>++ {/* Messages */}+ <div className="relative flex-1 overflow-y-auto p-4 space-y-4">{messages.length === 0 && disabledReason && (<div className="relative flex flex-col items-center justify-center py-12 space-y-4"><div className={cn(@@ -1156,6 +1457,7 @@ export function StandaloneChat() {)}<div ref={messagesEndRef} /></div>+ </div> {/* End of main content area with history sidebar */}{/* Input */}<div className="relative border-t border-border/50 bg-gradient-to-t from-muted/20 to-transparent">diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex 49c285c1d..ffa5851f2 100644--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -54,11 +54,34 @@ export type AIPreset = {export type UpdateChannel = "stable" | "beta";+// Chat history types+export interface ChatMessage {+ id: string;+ role: "user" | "assistant";+ content: string;+ timestamp: number;+}++export interface ChatConversation {+ id: string;+ title: string;+ messages: ChatMessage[];+ createdAt: number;+ updatedAt: number;+}++export interface ChatHistoryStore {+ conversations: ChatConversation[];+ activeConversationId: string | null;+ historyEnabled: boolean;+}+// Extend SettingsStore with deviceId (for AI free tier tracking)// This is added here until the Rust types are regeneratedexport type Settings = SettingsStore & {deviceId?: string;updateChannel?: UpdateChannel;+ chatHistory?: ChatHistoryStore;}export const DEFAULT_PROMPT = `Rules:@@ -192,6 +215,11 @@ let DEFAULT_SETTINGS: Settings = {useAllMonitors: true,enableRealtimeVision: true,showShortcutOverlay: true,+ chatHistory: {+ conversations: [],+ activeConversationId: null,+ historyEnabled: true,+ },};export function createDefaultSettingsObject(): Settings {@@ -257,6 +285,16 @@ function createSettingsStore() {needsUpdate = true;}+ // Migration: Add chat history for existing users+ if (!settings.chatHistory) {+ settings.chatHistory = {+ conversations: [],+ activeConversationId: null,+ historyEnabled: true,+ };+ needsUpdate = true;+ }+// Save migrations if neededif (needsUpdate) {await store.set("settings", settings);diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lockindex 9831b1371..192304ac5 100755--- a/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -5629,7 +5629,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"[[package]]name = "screenpipe-app"-version = "2.0.128"+version = "2.0.152"dependencies = ["anyhow","async-stream",