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

feat(chat): title + actions menu in panel header

Louis Beaumontd04a0375de82
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index cfba5dda0..8b1b77fa5 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -11,7 +11,7 @@ import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from "@/components/ui/tooltip";
import { useSettings, ChatMessage, ChatConversation } from "@/lib/hooks/use-settings";
import { cn } from "@/lib/utils";
-import { Loader2, Send, Square, User, Settings, ExternalLink, X, ImageIcon, History, Search, Trash2, ChevronLeft, ChevronRight, ChevronDown, ChevronUp, Plus, Copy, Check, Clock, Paperclip, Filter, RefreshCw, GitBranch, MoreHorizontal, Pencil, Shield, ShieldCheck } from "lucide-react";
+import { Loader2, Send, Square, User, Settings, ExternalLink, X, ImageIcon, History, Search, Trash2, ChevronLeft, ChevronRight, ChevronDown, ChevronUp, Plus, Copy, Check, Clock, Paperclip, Filter, RefreshCw, GitBranch, MoreHorizontal, Pencil, Pin, Shield, ShieldCheck } from "lucide-react";
import { SchedulePromptDialog } from "@/components/chat/schedule-prompt-dialog";
import { toast } from "@/components/ui/use-toast";
import { motion, AnimatePresence } from "framer-motion";
@@ -1053,6 +1053,174 @@ function CollapsibleUserMessage({ label, fullContent }: { label: string; fullCon
);
}
+/**
+ * Title + actions for the current chat. Click → menu with Rename
+ * (inline edit), Pin, Delete. Renders nothing for empty chats (no user
+ * message yet) — there's no useful title and the actions are no-ops
+ * for something that doesn't exist on disk.
+ */
+function ChatTitleMenu({
+ conversationId,
+ messages,
+ renameConversation,
+ deleteConversation,
+ startNewConversation,
+}: {
+ conversationId: string | null;
+ messages: Message[];
+ renameConversation: (id: string, title: string) => Promise<void> | void;
+ deleteConversation: (id: string) => Promise<void> | void;
+ startNewConversation: (id?: string) => Promise<void> | void;
+}) {
+ const [open, setOpen] = useState(false);
+ const [renaming, setRenaming] = useState(false);
+ const [draft, setDraft] = useState("");
+ const inputRef = useRef<HTMLInputElement | null>(null);
+
+ // Title source order:
+ // 1. The session's title from the chat-store (in-memory, freshest;
+ // reflects user renames immediately).
+ // 2. The first user message, truncated. Matches the auto-derive
+ // logic in saveConversation so what the menu shows is what
+ // will end up on disk.
+ // Hide the menu entirely when neither source has anything — the
+ // chat is brand new and the actions don't apply yet.
+ const storeTitle = useChatStore((s) =>
+ conversationId ? s.sessions[conversationId]?.title : undefined
+ );
+ const session = useChatStore((s) =>
+ conversationId ? s.sessions[conversationId] : undefined
+ );
+ const isPinned = session?.pinned ?? false;
+ const firstUserMsg = messages.find((m) => m.role === "user");
+ const derivedTitle = firstUserMsg?.content?.slice(0, 50);
+ const title =
+ storeTitle && storeTitle !== "new chat" && storeTitle !== "untitled"
+ ? storeTitle
+ : derivedTitle || "";
+
+ // No conversation id OR no real content → don't render. The "+ New"
+ // button on the right is enough; no point showing actions for a
+ // nothing-chat.
+ if (!conversationId || !title) return null;
+
+ const handleStartRename = () => {
+ setDraft(title);
+ setRenaming(true);
+ setOpen(false);
+ // Focus on next tick once the input is in the DOM.
+ setTimeout(() => inputRef.current?.focus(), 0);
+ };
+ const commitRename = async () => {
+ const next = draft.trim();
+ setRenaming(false);
+ if (!next || next === title) return;
+ try {
+ await renameConversation(conversationId, next);
+ // Mirror to the in-memory store so the sidebar reflects the
+ // change without waiting for the next disk hydration cycle.
+ useChatStore.getState().actions.patch(conversationId, { title: next });
+ } catch (e) {
+ console.warn("[chat] rename failed:", e);
+ }
+ };
+ const handleTogglePin = async () => {
+ setOpen(false);
+ const next = !isPinned;
+ useChatStore.getState().actions.togglePinned(conversationId);
+ try {
+ const { updateConversationFlags } = await import("@/lib/chat-storage");
+ await updateConversationFlags(conversationId, { pinned: next });
+ } catch {
+ // best-effort persistence
+ }
+ };
+ const handleDelete = async () => {
+ setOpen(false);
+ if (!confirm("Delete this chat? This cannot be undone.")) return;
+ try {
+ await deleteConversation(conversationId);
+ useChatStore.getState().actions.drop(conversationId);
+ // Land the user on a fresh chat — the panel was rendering the
+ // one we just deleted.
+ await startNewConversation();
+ } catch (e) {
+ console.warn("[chat] delete failed:", e);
+ }
+ };
+
+ if (renaming) {
+ return (
+ <input
+ ref={inputRef}
+ value={draft}
+ onChange={(e) => setDraft(e.target.value)}
+ onMouseDown={(e) => e.stopPropagation()}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ void commitRename();
+ } else if (e.key === "Escape") {
+ e.preventDefault();
+ setRenaming(false);
+ }
+ }}
+ onBlur={() => void commitRename()}
+ className="relative z-10 h-7 px-2 max-w-[260px] text-xs font-medium bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-foreground/30"
+ />
+ );
+ }
+
+ return (
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <button
+ type="button"
+ onMouseDown={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.stopPropagation();
+ setOpen((o) => !o);
+ }}
+ className="relative z-10 inline-flex items-center gap-1 max-w-[260px] h-7 px-2 rounded-md text-xs font-medium text-foreground hover:bg-muted/50 transition-colors"
+ title="Chat options"
+ >
+ <span className="truncate">{title}</span>
+ <ChevronDown className="h-3 w-3 shrink-0 text-muted-foreground/70" />
+ </button>
+ </PopoverTrigger>
+ <PopoverContent
+ className="w-44 p-1"
+ align="start"
+ side="bottom"
+ onMouseDown={(e) => e.stopPropagation()}
+ >
+ <button
+ className="w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded-md hover:bg-muted text-left"
+ onClick={handleStartRename}
+ >
+ <Pencil className="h-3.5 w-3.5 shrink-0" />
+ Rename
+ </button>
+ <button
+ className="w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded-md hover:bg-muted text-left"
+ onClick={() => void handleTogglePin()}
+ >
+ <Pin className="h-3.5 w-3.5 shrink-0" />
+ {isPinned ? "Unpin" : "Pin"}
+ </button>
+ <div className="my-1 border-t border-border" />
+ <button
+ className="w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded-md hover:bg-muted text-destructive text-left"
+ onClick={() => void handleDelete()}
+ >
+ <Trash2 className="h-3.5 w-3.5 shrink-0" />
+ Delete
+ </button>
+ </PopoverContent>
+ </Popover>
+ );
+}
+
export function StandaloneChat({
className,
hideInlineHistory,
@@ -3611,6 +3779,18 @@ export function StandaloneChat({
<History size={14} />
</Button>
)}
+ {/* Chat title + actions menu. Sits left-aligned (after the
+ history toggle) so the New / shortcut chips can stay on
+ the right. Suppressed for empty chats (no user message
+ yet) — there's no useful title to show and rename/delete
+ are meaningless for something that doesn't exist on disk. */}
+ <ChatTitleMenu
+ conversationId={conversationId}
+ messages={messages}
+ renameConversation={renameConversation}
+ deleteConversation={deleteConversation}
+ startNewConversation={startNewConversation}
+ />
<div className="flex-1" />
<Button
variant="default"
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index a3a6ee9b9..5e10d956f 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.4.77"
+version = "2.4.78"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""