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
fix(chat-sidebar): unread state, + inline with header, drop team promo, mid-stream new chat
Louis Beaumont5d05996cdfa0
diff --git a/apps/screenpipe-app-tauri/app/home/page.tsx b/apps/screenpipe-app-tauri/app/home/page.tsxindex 7585e3d9b..15568a2d5 100644--- a/apps/screenpipe-app-tauri/app/home/page.tsx+++ b/apps/screenpipe-app-tauri/app/home/page.tsx@@ -537,33 +537,6 @@ function HomeContent() {<div className="flex-1" />)}- {/* Team promo card — hidden when user already has a team, sidebar collapsed, or enterprise */}- {!teamState.team && !sidebarCollapsed && !isSectionHidden("team") && !teamPromoDismissed && (- <div className={cn("mx-1 mb-3 p-3 border relative group", isTranslucent ? "vibrant-card-border" : "border-border bg-card")}>- <button- onClick={() => {- setTeamPromoDismissed(true);- localStorage.setItem("team-promo-dismissed", "true");- }}- className={cn("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity", isTranslucent ? "vibrant-nav-item" : "text-muted-foreground hover:text-foreground")}- >- <X className="h-3.5 w-3.5" />- </button>- <h3 className={cn("text-sm font-medium", isTranslucent ? "vibrant-heading" : "text-foreground")}>- Add your team to screenpipe- </h3>- <p className={cn("text-xs mt-1", isTranslucent ? "vibrant-sidebar-fg-muted" : "text-muted-foreground")}>- Push pipe configs and content filters to all members.- </p>- <button- onClick={() => openSettings("team")}- className={cn("mt-2.5 px-3 py-1.5 text-xs font-medium border transition-colors duration-150", isTranslucent ? "vibrant-btn-border" : "border-border bg-background hover:bg-foreground hover:text-background")}- >- ADD YOUR TEAM- </button>- </div>- )}-{/* Bottom items */}<div className={cn("space-y-0.5 border-t pt-2", isTranslucent ? "vibrant-sidebar-border" : "border-border")}>{/* Team link — hide invite promo in enterprise (unless team exists) */}diff --git a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx b/apps/screenpipe-app-tauri/components/chat-sidebar.tsxindex da95ff3c7..33f4a4dc3 100644--- a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx+++ b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx@@ -95,7 +95,9 @@ export function ChatSidebar({ className }: ChatSidebarProps) {const id = crypto.randomUUID();// Optimistically add the row so the sidebar feels responsive even if// standalone-chat takes a tick to react. The router will pick up the- // session if/when Pi starts emitting events for it.+ // session if/when Pi starts emitting events for it. Critically, this+ // runs even when another session is mid-stream — multi-tab is the+ // whole point, so + new chat must be clickable at all times.actions.upsert({id,title: "new chat",@@ -104,6 +106,7 @@ export function ChatSidebar({ className }: ChatSidebarProps) {messageCount: 0,updatedAt: Date.now(),pinned: false,+ unread: false,});actions.setCurrent(id);// chat-load-conversation with an unknown id is treated by@@ -134,6 +137,7 @@ export function ChatSidebar({ className }: ChatSidebarProps) {messageCount: 0,updatedAt: Date.now(),pinned: false,+ unread: false,});actions.setCurrent(fresh);emit("chat-load-conversation", { conversationId: fresh });@@ -169,20 +173,6 @@ export function ChatSidebar({ className }: ChatSidebarProps) {className={cn("flex flex-col h-full min-h-0 text-sm", className)}data-testid="chat-sidebar">- <div className="px-2 pt-2 pb-1 shrink-0">- <button- onClick={handleNew}- className={cn(- "w-full flex items-center gap-2 px-2 py-1.5 rounded-md",- "text-foreground hover:bg-muted/50 transition-colors",- "text-sm font-medium"- )}- data-testid="chat-sidebar-new"- >- <Plus className="h-4 w-4" /> new chat- </button>- </div>-<div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden">{pinned.length > 0 && (<Section title="pinned">@@ -199,10 +189,25 @@ export function ChatSidebar({ className }: ChatSidebarProps) {</Section>)}- <Section title="recents">+ <Section+ title="recents"+ action={+ <button+ onClick={handleNew}+ className={cn(+ "p-1 rounded hover:bg-muted/60 transition-colors",+ "text-muted-foreground hover:text-foreground"+ )}+ title="new chat"+ data-testid="chat-sidebar-new"+ >+ <Plus className="h-3.5 w-3.5" />+ </button>+ }+ >{recents.length === 0 && pinned.length === 0 ? (<div className="px-3 py-2 text-xs text-muted-foreground/70 italic">- no chats yet — start one above+ no chats yet — click + to start</div>) : recents.length === 0 ? (<div className="px-3 py-2 text-xs text-muted-foreground/70 italic">@@ -228,15 +233,20 @@ export function ChatSidebar({ className }: ChatSidebarProps) {function Section({title,+ action,children,}: {title: string;+ action?: React.ReactNode;children: React.ReactNode;}) {return (<div className="mb-2">- <div className="px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/60">- {title}+ <div className="px-3 py-1.5 flex items-center justify-between">+ <span className="text-[10px] uppercase tracking-wider text-muted-foreground/60">+ {title}+ </span>+ {action}</div><div className="flex flex-col">{children}</div></div>@@ -277,7 +287,20 @@ function ChatRow({title={isError && session.lastError ? session.lastError : undefined}><div className="flex items-center gap-1.5 min-w-0">- <span className="truncate flex-1 text-sm">+ <span+ className={cn(+ "truncate flex-1 text-sm",+ // Email-style: unread rows are bold + foreground; once+ // viewed, fade back to normal weight + muted color. The+ // store atomically clears unread when the user makes the+ // session current (see chat-store setCurrent).+ session.unread && !isCurrent+ ? "font-semibold text-foreground"+ : isCurrent+ ? "text-foreground"+ : "text-foreground/80"+ )}+ >{session.title || "untitled"}</span>{isLive && (diff --git a/apps/screenpipe-app-tauri/lib/stores/chat-store.ts b/apps/screenpipe-app-tauri/lib/stores/chat-store.tsindex 2c42f3499..36e75fe38 100644--- a/apps/screenpipe-app-tauri/lib/stores/chat-store.ts+++ b/apps/screenpipe-app-tauri/lib/stores/chat-store.ts@@ -46,6 +46,12 @@ export interface SessionRecord {updatedAt: number;/** User pinned this conversation to the top of the sidebar. */pinned: boolean;+ /** True when there's new assistant activity (delta or completion) that+ * the user hasn't seen yet. Set by the event router when content lands+ * for a session that is NOT the currently-viewed one; cleared the+ * instant the user makes that session current. Sidebar renders unread+ * rows in bold, like an email inbox. */+ unread: boolean;}interface ChatStoreState {@@ -65,10 +71,16 @@ interface ChatStoreActions {/** Remove a session from the store (does not stop the Pi process or* delete from disk — caller does that). */drop: (id: string) => void;- /** Mark a session as currently in front. */+ /** Mark a session as currently in front. Implicitly clears its unread+ * flag — viewing the chat counts as reading it. */setCurrent: (id: string | null) => void;/** Toggle the pinned state. */togglePinned: (id: string) => void;+ /** Mark a session as having new unseen assistant activity. The router+ * calls this when content lands for a session other than the current+ * one. No-op if the session id is the current one (you can't be+ * unread for the chat you're looking at). */+ markUnread: (id: string) => void;}export type ChatStore = ChatStoreState & { actions: ChatStoreActions };@@ -124,7 +136,23 @@ export const useChatStore = create<ChatStore>((set) => ({};}),- setCurrent: (id) => set({ currentId: id }),+ setCurrent: (id) =>+ set((s) => {+ // Viewing a session counts as reading it — clear the unread flag+ // for the new current. Same atomic update so the row's unread+ // state can't transiently flicker between the setCurrent call and+ // a follow-up markRead call.+ if (id && s.sessions[id]?.unread) {+ return {+ currentId: id,+ sessions: {+ ...s.sessions,+ [id]: { ...s.sessions[id], unread: false },+ },+ };+ }+ return { currentId: id };+ }),togglePinned: (id) =>set((s) => {@@ -137,6 +165,17 @@ export const useChatStore = create<ChatStore>((set) => ({},};}),++ markUnread: (id) =>+ set((s) => {+ const existing = s.sessions[id];+ if (!existing) return {};+ if (s.currentId === id) return {}; // can't be unread for the current view+ if (existing.unread) return {}; // already unread, avoid re-render churn+ return {+ sessions: { ...s.sessions, [id]: { ...existing, unread: true } },+ };+ }),},}));diff --git a/apps/screenpipe-app-tauri/lib/stores/pi-event-router.ts b/apps/screenpipe-app-tauri/lib/stores/pi-event-router.tsindex 7dee8a498..713337483 100644--- a/apps/screenpipe-app-tauri/lib/stores/pi-event-router.ts+++ b/apps/screenpipe-app-tauri/lib/stores/pi-event-router.ts@@ -170,6 +170,10 @@ async function handlePiEvent(payload: PiEventPayload) {messageCount: 0,updatedAt: Date.now(),pinned: false,+ // First-touch session is unread unless the user is already viewing+ // it (this is also how external triggers — chat-prefill, pipe+ // events — surface in the sidebar).+ unread: store.currentId !== sid,});if (snippet) previewLastEmittedAt.set(sid, Date.now());return;@@ -209,6 +213,12 @@ async function handlePiEvent(payload: PiEventPayload) {}store.actions.patch(sid, patch);++ // Mark as unread if real assistant content arrived for a session that+ // is NOT the currently-viewed one. The store's markUnread is a no-op+ // when sid === currentId, so this is safe to call unconditionally on+ // any event that produced a snippet.+ if (snippet) store.actions.markUnread(sid);}function handleSessionEvicted(payload: PiSessionEvictedPayload) {@@ -255,10 +265,12 @@ async function hydrate() {id: m.id,title: m.title || "untitled",preview: "",- status: "idle",+ status: "idle" as const,messageCount: m.messageCount,updatedAt: m.updatedAt,pinned: m.pinned,+ // History reload doesn't count as new activity — start clean.+ unread: false,}));useChatStore.getState().actions.hydrateFromDisk(records);} catch {diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 5fbee2c72..00739083f 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.56"+version = "2.4.57"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""