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(sidebar): collapse pipe sessions into single automations group (#4899)
Harsh Kumarfa943d1a5cd6
diff --git a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx b/apps/screenpipe-app-tauri/components/chat-sidebar.tsxindex 114c056e1..d198c913d 100644--- a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx+++ b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx@@ -44,6 +44,7 @@ import {MoreVertical,Pencil,FolderOpen,+ Timer,} from "lucide-react";import { usePlatform } from "@/lib/hooks/use-platform";import { emit, listen } from "@tauri-apps/api/event";@@ -108,9 +109,15 @@ import {recurringPipeGroupKeys,sessionGroupKey,type SidebarItem,+ type SidebarRecentsSection,validateSidebarGroupName,} from "@/lib/utils/chat-sidebar-grouping";+/** Max top-level rows shown across recents + pipes. */+const SIDEBAR_CAP = 15;+/** Minimum slots reserved for pipes when pipe sessions exist. */+const PIPES_MIN_SLOTS = 5;+interface ChatSidebarProps {className?: string;onViewAll?: () => void;@@ -142,6 +149,7 @@ function useCollapsedPref(key: string, defaultValue = false) {function useVisibleChatSections(): {pinned: SessionRecord[];recents: SessionRecord[];+ pipes: SessionRecord[];archived: SessionRecord[];} {const sessions = useOrderedSessions();@@ -149,6 +157,7 @@ function useVisibleChatSections(): {return useMemo(() => {const pinned: SessionRecord[] = [];const recents: SessionRecord[] = [];+ const pipes: SessionRecord[] = [];const archived: SessionRecord[] = [];for (const s of sessions) {// Hide drafts (no user message sent yet)@@ -158,9 +167,15 @@ function useVisibleChatSections(): {archived.push(s);continue;}- (s.pinned ? pinned : recents).push(s);+ if (s.pinned) {+ pinned.push(s);+ } else if (s.kind === "pipe-run" || s.kind === "pipe-watch") {+ pipes.push(s);+ } else {+ recents.push(s);+ }}- return { pinned, recents, archived };+ return { pinned, recents, pipes, archived };}, [sessions]);}@@ -397,12 +412,38 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {};}, [actions]);- const { pinned, recents, archived } = useVisibleChatSections();+ const { pinned, recents, pipes, archived } = useVisibleChatSections();const groupedSections = useMemo(() => buildSidebarRecentsSections(recents, Number.POSITIVE_INFINITY),[recents],);+ const pipeGroupedSections = useMemo(+ () => buildSidebarRecentsSections(pipes, Number.POSITIVE_INFINITY),+ [pipes],+ );+ // Flatten pipe grouped sections into a single items list for rendering+ const pipeItems = useMemo(+ () => pipeGroupedSections.flatMap((section) => section.items),+ [pipeGroupedSections],+ );++ const [pipesCollapsed, setPipesCollapsed] = useCollapsedPref(+ "screenpipe:pipes-collapsed",+ true+ );++ // Auto-expand the pipes section when the current session is a pipe run+ // so the highlighted row is visible. Only depends on currentId and the+ // pipes list — reads collapse state imperatively to avoid re-fire loops.+ useEffect(() => {+ if (!currentId) return;+ if (pipes.some((s) => s.id === currentId)) {+ setPipesCollapsed(false);+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [currentId, pipes]);+// Expand/collapse state for manual recents subsections (e.g. OTHER,// named sidebar groups). Stored separately from pipe auto-groups so the// two hierarchy levels can collapse independently.@@ -530,8 +571,8 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {// auto pipe-groups the user actually sees in the sidebar. Moving a chat// into a pipe-group's name folds it into that same group.const existingGroups = useMemo(- () => listMoveTargetGroups([...pinned, ...recents]),- [pinned, recents],+ () => listMoveTargetGroups([...pinned, ...recents, ...pipes]),+ [pinned, recents, pipes],);const [deletingSessionId, setDeletingSessionId] = useState<string | null>(null);@@ -552,10 +593,28 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {);const openAllCollapsed = recentsCollapsed && (archived.length === 0 || archivedCollapsed);- const recentsLoading = !diskHydrated && recents.length === 0;+ const recentsLoading = !diskHydrated && recents.length === 0 && pipes.length === 0;++ // When pipes exist, recents cap at (SIDEBAR_CAP - PIPES_MIN_SLOTS),+ // reserving at least PIPES_MIN_SLOTS for pipes. If recents use+ // fewer slots, pipes get the surplus.+ const recentsCap = pipes.length > 0+ ? SIDEBAR_CAP - PIPES_MIN_SLOTS+ : SIDEBAR_CAP;const visibleGroupedSections = useMemo(- () => applySidebarRecentsCap(groupedSections, collapsedRecentsSections, 15),- [groupedSections, collapsedRecentsSections],+ () => applySidebarRecentsCap(groupedSections, collapsedRecentsSections, recentsCap),+ [groupedSections, collapsedRecentsSections, recentsCap],+ );+ const recentsRowCount = useMemo(+ () => visibleGroupedSections.reduce((sum, s) => sum + s.items.length, 0),+ [visibleGroupedSections],+ );+ const pipesCap = pipes.length > 0+ ? Math.max(0, SIDEBAR_CAP - recentsRowCount)+ : 0;+ const visiblePipeItems = useMemo(+ () => pipeItems.slice(0, pipesCap),+ [pipeItems, pipesCap],);const handleSelect = (id: string) => {@@ -733,7 +792,7 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {}}><div className="flex flex-col gap-1">- <div className="min-h-0 flex flex-col flex-1">+ <div className="min-h-0 flex flex-col">{pinned.length > 0 && (<div className="shrink-0"><Section@@ -764,7 +823,7 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {</div>)}- <div className="group/recents min-h-0 flex flex-col flex-1">+ <div className="group/recents min-h-0 flex flex-col"><Sectiontitle="recents"collapsed={recentsCollapsed}@@ -808,89 +867,88 @@ export function ChatSidebar({ className, onViewAll }: ChatSidebarProps) {<Skeleton key={i} className="h-6 w-full rounded-md" />))}</div>- ) : recents.length === 0 ? (+ ) : recents.length === 0 && pipes.length === 0 ? (<div className="px-2.5 py-2 text-xs text-muted-foreground/70 italic">{pinned.length === 0 ? "no chats yet — click + to start" : "no recent chats"}</div>) : (- visibleGroupedSections.map((section, index) => (- <div- key={section.key}- className={cn(index > 0 && "mt-1")}- data-testid={`chat-sidebar-group-${section.title || "all"}`}- >- {section.title && (- <button- type="button"- onClick={() => toggleRecentsSectionCollapsed(section.key)}- className={cn(- "group/subsection w-full px-2.5 pt-1 pb-0.5 flex items-center gap-2 text-left rounded-sm",- "hover:bg-muted/10 transition-colors"- )}- aria-expanded={!collapsedRecentsSections.has(section.key)}- >- <span className="text-[10px] uppercase tracking-wider text-muted-foreground/60 flex-1">- {section.title}- </span>- {collapsedRecentsSections.has(section.key) ? (- <ChevronRight- className="h-3 w-3 shrink-0 text-muted-foreground/55"- aria-hidden- />- ) : (- <ChevronDown- className="h-3 w-3 shrink-0 text-muted-foreground/55"- aria-hidden- />- )}- </button>- )}- {!collapsedRecentsSections.has(section.key) && section.items.map((item) =>- item.kind === "single" ? (- <SidebarChatRow- key={item.session.id}- session={item.session}- isCurrent={item.session.id === currentId}- queuedCount={queueDepths.get(item.session.id) ?? 0}- onSelect={handleSelect}- onArchive={handleArchive}- onUnarchive={handleUnarchive}- onDeleteRequest={setDeletingSessionId}- onTogglePin={handleTogglePin}- onRenameRequest={handleRenameRequest}- onMoveToGroup={handleMoveToGroup}- onNewGroupRequest={setNewGroupSessionId}- existingGroups={existingGroups}- openConversationMenuId={openConversationMenuId}- setOpenConversationMenuId={setOpenConversationMenuId}- />- ) : (- <PipeGroupRow- key={item.key}- item={item}- expanded={expandedGroups.has(item.key)}- onToggleExpand={() => toggleGroupExpanded(item.key)}- currentId={currentId}- queueDepths={queueDepths}- onSelect={handleSelect}- onArchive={handleArchive}- onUnarchive={handleUnarchive}- onDeleteRequest={setDeletingSessionId}- onTogglePin={handleTogglePin}- onRenameRequest={handleRenameRequest}- onMoveToGroup={handleMoveToGroup}- onNewGroupRequest={setNewGroupSessionId}- existingGroups={existingGroups}- openConversationMenuId={openConversationMenuId}- setOpenConversationMenuId={setOpenConversationMenuId}- />- ),- )}- </div>- ))+ <RecentsBody+ sections={visibleGroupedSections}+ collapsedSections={collapsedRecentsSections}+ toggleSectionCollapsed={toggleRecentsSectionCollapsed}+ expandedGroups={expandedGroups}+ toggleGroupExpanded={toggleGroupExpanded}+ currentId={currentId}+ queueDepths={queueDepths}+ onSelect={handleSelect}+ onArchive={handleArchive}+ onUnarchive={handleUnarchive}+ onDeleteRequest={setDeletingSessionId}+ onTogglePin={handleTogglePin}+ onRenameRequest={handleRenameRequest}+ onMoveToGroup={handleMoveToGroup}+ onNewGroupRequest={setNewGroupSessionId}+ existingGroups={existingGroups}+ openConversationMenuId={openConversationMenuId}+ setOpenConversationMenuId={setOpenConversationMenuId}+ />)}</Section></div>++ {pipes.length > 0 && pipesCap > 0 && (+ <div className="group/pipes min-h-0 flex flex-col shrink-0">+ <Section+ title="pipes"+ collapsed={pipesCollapsed}+ onCollapsedChange={setPipesCollapsed}+ headerAction={+ <Timer className="h-3 w-3 text-muted-foreground/60" aria-hidden />+ }+ bodyClassName=""+ >+ {visiblePipeItems.map((item) =>+ item.kind === "single" ? (+ <SidebarChatRow+ key={item.session.id}+ session={item.session}+ isCurrent={item.session.id === currentId}+ queuedCount={queueDepths.get(item.session.id) ?? 0}+ onSelect={handleSelect}+ onArchive={handleArchive}+ onUnarchive={handleUnarchive}+ onDeleteRequest={setDeletingSessionId}+ onTogglePin={handleTogglePin}+ onRenameRequest={handleRenameRequest}+ insideGroup+ openConversationMenuId={openConversationMenuId}+ setOpenConversationMenuId={setOpenConversationMenuId}+ />+ ) : (+ <PipeGroupRow+ key={item.key}+ item={item}+ expanded={expandedGroups.has(item.key)}+ onToggleExpand={() => toggleGroupExpanded(item.key)}+ currentId={currentId}+ queueDepths={queueDepths}+ onSelect={handleSelect}+ onArchive={handleArchive}+ onUnarchive={handleUnarchive}+ onDeleteRequest={setDeletingSessionId}+ onTogglePin={handleTogglePin}+ onRenameRequest={handleRenameRequest}+ onMoveToGroup={handleMoveToGroup}+ onNewGroupRequest={setNewGroupSessionId}+ existingGroups={existingGroups}+ openConversationMenuId={openConversationMenuId}+ setOpenConversationMenuId={setOpenConversationMenuId}+ />+ ),+ )}+ </Section>+ </div>+ )}</div></div>@@ -1367,6 +1425,128 @@ function Section({);}+/**+ * Renders recents items (no pipe sessions — those live in the separate+ * "pipes" Section). Handles subsection headers and collapse state.+ */+function RecentsBody({+ sections,+ collapsedSections,+ toggleSectionCollapsed,+ expandedGroups,+ toggleGroupExpanded,+ currentId,+ queueDepths,+ onSelect,+ onArchive,+ onUnarchive,+ onDeleteRequest,+ onTogglePin,+ onRenameRequest,+ onMoveToGroup,+ onNewGroupRequest,+ existingGroups,+ openConversationMenuId,+ setOpenConversationMenuId,+}: {+ sections: SidebarRecentsSection[];+ collapsedSections: ReadonlySet<string>;+ toggleSectionCollapsed: (key: string) => void;+ expandedGroups: ReadonlySet<string>;+ toggleGroupExpanded: (key: string) => void;+ currentId: string | null;+ queueDepths: Map<string, number>;+ onSelect: (id: string) => void;+ onArchive: (id: string) => Promise<void> | void;+ onUnarchive: (id: string) => Promise<void> | void;+ onDeleteRequest: (id: string | null) => void;+ onTogglePin: (id: string) => Promise<void> | void;+ onRenameRequest: (id: string) => void;+ onMoveToGroup: (id: string, group: string | undefined) => void;+ onNewGroupRequest: (id: string) => void;+ existingGroups: string[];+ openConversationMenuId: string | null;+ setOpenConversationMenuId: (id: string | null) => void;+}) {+ const renderItem = (item: SidebarItem) =>+ item.kind === "single" ? (+ <SidebarChatRow+ key={item.session.id}+ session={item.session}+ isCurrent={item.session.id === currentId}+ queuedCount={queueDepths.get(item.session.id) ?? 0}+ onSelect={onSelect}+ onArchive={onArchive}+ onUnarchive={onUnarchive}+ onDeleteRequest={onDeleteRequest}+ onTogglePin={onTogglePin}+ onRenameRequest={onRenameRequest}+ onMoveToGroup={onMoveToGroup}+ onNewGroupRequest={onNewGroupRequest}+ existingGroups={existingGroups}+ openConversationMenuId={openConversationMenuId}+ setOpenConversationMenuId={setOpenConversationMenuId}+ />+ ) : (+ <PipeGroupRow+ key={item.key}+ item={item}+ expanded={expandedGroups.has(item.key)}+ onToggleExpand={() => toggleGroupExpanded(item.key)}+ currentId={currentId}+ queueDepths={queueDepths}+ onSelect={onSelect}+ onArchive={onArchive}+ onUnarchive={onUnarchive}+ onDeleteRequest={onDeleteRequest}+ onTogglePin={onTogglePin}+ onRenameRequest={onRenameRequest}+ onMoveToGroup={onMoveToGroup}+ onNewGroupRequest={onNewGroupRequest}+ existingGroups={existingGroups}+ openConversationMenuId={openConversationMenuId}+ setOpenConversationMenuId={setOpenConversationMenuId}+ />+ );++ return (+ <>+ {sections.map((section, si) => {+ const isCollapsed = collapsedSections.has(section.key);+ return (+ <div+ key={section.key}+ className={cn(si > 0 && "mt-1")}+ data-testid={`chat-sidebar-group-${section.title || "all"}`}+ >+ {section.title && (+ <button+ type="button"+ onClick={() => toggleSectionCollapsed(section.key)}+ className={cn(+ "group/subsection w-full px-2.5 pt-1 pb-0.5 flex items-center gap-2 text-left rounded-sm",+ "hover:bg-muted/10 transition-colors"+ )}+ aria-expanded={!isCollapsed}+ >+ <span className="text-[10px] uppercase tracking-wider text-muted-foreground/60 flex-1">+ {section.title}+ </span>+ {isCollapsed ? (+ <ChevronRight className="h-3 w-3 shrink-0 text-muted-foreground/55" aria-hidden />+ ) : (+ <ChevronDown className="h-3 w-3 shrink-0 text-muted-foreground/55" aria-hidden />+ )}+ </button>+ )}+ {!isCollapsed && section.items.map(renderItem)}+ </div>+ );+ })}+ </>+ );+}+/*** Expandable row for a pipe auto-group. Shows the pipe name, a count* badge, and a chevron. Clicking toggles expansion to reveal individual@@ -1453,6 +1633,7 @@ function PipeGroupRow({onMoveToGroup={onMoveToGroup}onNewGroupRequest={onNewGroupRequest}existingGroups={existingGroups}+ insideGroupopenConversationMenuId={openConversationMenuId}setOpenConversationMenuId={setOpenConversationMenuId}/>@@ -1479,6 +1660,7 @@ interface ChatRowProps {onNewGroupRequest?: (id: string) => void;existingGroups?: string[];showActions?: boolean;+ insideGroup?: boolean;openConversationMenuId?: string | null;setOpenConversationMenuId?: (id: string | null) => void;}@@ -1748,6 +1930,7 @@ export function SidebarChatRow({onNewGroupRequest,existingGroups,showActions = true,+ insideGroup = false,openConversationMenuId,setOpenConversationMenuId,}: ChatRowProps) {@@ -1817,6 +2000,9 @@ export function SidebarChatRow({onSelect(session.id);}}>+ {!insideGroup && (session.kind === "pipe-run" || session.kind === "pipe-watch") && (+ <Timer className="h-3 w-3 shrink-0 text-muted-foreground/60" aria-hidden />+ )}<spanclassName={cn("truncate flex-1 text-xs font-normal",diff --git a/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx b/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsxindex f549cf7a3..146fc04eb 100644--- a/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx+++ b/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx@@ -5,7 +5,7 @@import React, { useCallback, useEffect, useMemo, useState } from "react";import { emit, listen } from "@tauri-apps/api/event";-import { Archive, CheckSquare, FolderOpen, Loader2, MessageSquare, MoreVertical, Pin, Plus, Search, Trash2, Undo2, X } from "lucide-react";+import { Archive, CheckSquare, FolderOpen, Loader2, MessageSquare, MoreVertical, Pin, Plus, Search, Timer, Trash2, Undo2, X } from "lucide-react";import { cn } from "@/lib/utils";import { usePlatform } from "@/lib/hooks/use-platform";import { isInjectedTitle } from "@/lib/chat-utils";@@ -375,17 +375,20 @@ export function ChatHistoryView({>{/* Column 1: Icon (default) / Checkbox (hover or selected) */}<div className="h-5 w-5 flex items-center justify-center relative">- {/* Chat icon — hidden on hover (unless selected via selection mode) */}- <MessageSquare- className={cn(- "h-4 w-4 absolute inset-0 m-auto transition-opacity duration-75",- conv.hidden ? "text-muted-foreground/45" : "text-muted-foreground/70",- showCheckbox- ? "opacity-0 invisible"- : "opacity-100 visible group-hover:opacity-0 group-hover:invisible"- )}- aria-hidden- />+ {/* Chat icon (or Timer for pipe sessions) — hidden on hover (unless selected via selection mode) */}+ {React.createElement(+ conv.kind === "pipe-run" || conv.kind === "pipe-watch" ? Timer : MessageSquare,+ {+ className: cn(+ "h-4 w-4 absolute inset-0 m-auto transition-opacity duration-75",+ conv.hidden ? "text-muted-foreground/45" : "text-muted-foreground/70",+ showCheckbox+ ? "opacity-0 invisible"+ : "opacity-100 visible group-hover:opacity-0 group-hover:invisible"+ ),+ "aria-hidden": true,+ },+ )}{/* Checkbox — visible on hover or when selected */}<divclassName={cn(diff --git a/apps/screenpipe-app-tauri/lib/utils/chat-sidebar-grouping.ts b/apps/screenpipe-app-tauri/lib/utils/chat-sidebar-grouping.tsindex 1cd4d5602..0790023fb 100644--- a/apps/screenpipe-app-tauri/lib/utils/chat-sidebar-grouping.ts+++ b/apps/screenpipe-app-tauri/lib/utils/chat-sidebar-grouping.ts@@ -23,6 +23,8 @@ const RESERVED_SIDEBAR_GROUP_NAMES = new Set(["other","upcoming","archived",+ "pipes",+ "automations",]);export interface SidebarGroupNameValidationOptions {