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

Update chat history view UI (#3927)

Harsh Kumard218c35bfafc
diff --git a/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx b/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx
index b1b86f40c..2b71e71b1 100644
--- a/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/chat-history-view.tsx
@@ -11,7 +11,6 @@ import { isConversationHistorySyncPrompt } from "@/lib/chat-utils";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { toast } from "@/components/ui/use-toast";
import {
DropdownMenu,
@@ -42,9 +41,9 @@ type HistoryTab = "active" | "archived" | "all";
const HISTORY_PAGE_SIZE = 30;
const TABS: ReadonlyArray<{ value: HistoryTab; label: string }> = [
- { value: "active", label: "active" },
- { value: "archived", label: "archived" },
- { value: "all", label: "all" },
+ { value: "active", label: "Active" },
+ { value: "archived", label: "Archived" },
+ { value: "all", label: "All" },
];
export function ChatHistoryView({
@@ -56,12 +55,8 @@ export function ChatHistoryView({
onNewChat: () => void;
onSelectConversation: (conversationId: string) => void;
}) {
- // Shared layout primitives so the bulk bar and rows align.
- const ROW_GUTTER_CLASS = "w-7 shrink-0 flex items-center justify-center";
- const ROW_GRID_CLASS = "grid grid-cols-[20px_1fr_64px_28px] items-center gap-3 min-w-0";
const [tab, setTab] = useState<HistoryTab>("active");
const [query, setQuery] = useState("");
- const [searchOpen, setSearchOpen] = useState(false);
const [loading, setLoading] = useState(true);
const [loadingMore, setLoadingMore] = useState(false);
const [hasMore, setHasMore] = useState(false);
@@ -73,7 +68,6 @@ export function ChatHistoryView({
const [openMenuId, setOpenMenuId] = useState<string | null>(null);
const [bulkPending, setBulkPending] = useState<null | "archiving" | "restoring" | "deleting">(null);
const [rowPendingIds, setRowPendingIds] = useState<Set<string>>(() => new Set());
- const searchWrapRef = React.useRef<HTMLDivElement | null>(null);
const searchInputRef = React.useRef<HTMLInputElement | null>(null);
const scrollContainerRef = React.useRef<HTMLDivElement | null>(null);
const sentinelRef = React.useRef<HTMLDivElement | null>(null);
@@ -158,25 +152,6 @@ export function ChatHistoryView({
return () => observer.disconnect();
}, [hasMore, loading, loadingMore, load]);
- useEffect(() => {
- if (!searchOpen) return;
- const id = requestAnimationFrame(() => searchInputRef.current?.focus());
- return () => cancelAnimationFrame(id);
- }, [searchOpen]);
-
- useEffect(() => {
- if (!searchOpen) return;
- const opts = { capture: true } as const;
- const onPointerDown = (e: PointerEvent) => {
- const wrap = searchWrapRef.current;
- if (!wrap) return;
- if (wrap.contains(e.target as Node)) return;
- if (query.trim() === "") setSearchOpen(false);
- };
- window.addEventListener("pointerdown", onPointerDown, opts);
- return () => window.removeEventListener("pointerdown", onPointerDown, opts);
- }, [query, searchOpen]);
-
// Selection is intentionally ephemeral: clear on tab switch, search changes, or leaving the view.
useEffect(() => {
setSelectedIds(new Set());
@@ -328,15 +303,38 @@ export function ChatHistoryView({
const selected = selectedIds.has(conv.id);
const selectionMode = selectedIds.size > 0;
const rowPending = rowPendingIds.has(conv.id);
+ const showCheckbox = selectionMode || selected;
return (
- <div className="group flex items-center gap-3">
- <div className={ROW_GUTTER_CLASS}>
+ <div
+ role="button"
+ tabIndex={0}
+ onClick={() => onSelectConversation(conv.id)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") onSelectConversation(conv.id);
+ }}
+ className={cn(
+ "group grid grid-cols-[20px_1fr_auto] items-center gap-3 px-3 py-3 cursor-pointer select-none transition-colors min-w-0",
+ selected ? "bg-muted/20" : "hover:bg-muted/25"
+ )}
+ >
+ {/* 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
+ />
+ {/* Checkbox — visible on hover or when selected */}
<div
className={cn(
- // Avoid stale "ghost" checkboxes when moving quickly between rows:
- // use visibility toggling (not just opacity) and keep hover-only.
- "transition-opacity duration-75",
- selectionMode || selected
+ "absolute inset-0 m-auto flex items-center justify-center transition-opacity duration-75",
+ showCheckbox
? "opacity-100 visible pointer-events-auto"
: "opacity-0 invisible pointer-events-none group-hover:opacity-100 group-hover:visible group-hover:pointer-events-auto"
)}
@@ -350,184 +348,173 @@ export function ChatHistoryView({
</div>
</div>
- <div
- role="button"
- tabIndex={0}
- onClick={() => onSelectConversation(conv.id)}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") onSelectConversation(conv.id);
- }}
- className={cn(
- "flex-1 min-w-0 rounded-md px-3 py-2 cursor-pointer select-none transition-colors",
- selected ? "bg-muted/20" : "hover:bg-muted/25"
- )}
- >
- <div className={ROW_GRID_CLASS}>
- <div className="h-4 w-4 flex items-center justify-center" aria-hidden>
- <MessageSquare
- className={cn(
- "h-4 w-4",
- conv.hidden ? "text-muted-foreground/45" : "text-muted-foreground/70"
- )}
- />
- </div>
-
- <div className="min-w-0">
- <p
- className={cn(
- "text-sm truncate",
- conv.hidden ? "text-muted-foreground" : "text-foreground"
- )}
- >
- {(isConversationHistorySyncPrompt(conv.title) ? undefined : conv.title) || "untitled"}
- </p>
- </div>
-
- <div className="text-xs text-muted-foreground tabular-nums text-right">
- {updatedAt}
- </div>
+ {/* Column 2: Title */}
+ <div className="min-w-0">
+ <p
+ className={cn(
+ "text-sm truncate",
+ conv.hidden ? "text-muted-foreground" : "text-foreground"
+ )}
+ >
+ {(isConversationHistorySyncPrompt(conv.title) ? undefined : conv.title) || "untitled"}
+ </p>
+ </div>
- <div className="flex justify-end">
- <DropdownMenu
- open={openMenuId === conv.id}
- onOpenChange={(open) => setOpenMenuId(open ? conv.id : null)}
- >
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- onClick={(e) => e.stopPropagation()}
- className={cn(
- "h-7 w-7 rounded-md inline-flex items-center justify-center",
- "text-muted-foreground hover:text-foreground hover:bg-muted/60",
- "transition-opacity",
- openMenuId === conv.id
- ? "opacity-100"
- : "opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto"
- )}
- aria-label="Conversation actions"
- disabled={rowPending}
- >
- {rowPending ? (
- <Loader2 className="h-4 w-4 animate-spin" />
- ) : (
- <MoreVertical className="h-4 w-4" />
- )}
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- side="bottom"
- sideOffset={6}
- className="w-[156px] p-1 rounded-none border border-border bg-background shadow-none"
+ {/* Column 3: Date (default) / Kebab menu (hover) */}
+ <div className="flex items-center justify-end w-16 relative">
+ {/* Date — visible by default, hidden on hover */}
+ <span
+ className={cn(
+ "text-xs text-muted-foreground tabular-nums transition-opacity duration-75",
+ openMenuId === conv.id
+ ? "opacity-0 invisible"
+ : "opacity-100 visible group-hover:opacity-0 group-hover:invisible"
+ )}
+ >
+ {updatedAt}
+ </span>
+ {/* Kebab menu — visible on hover */}
+ <div
+ className={cn(
+ "absolute inset-0 flex items-center justify-end transition-opacity duration-75",
+ openMenuId === conv.id
+ ? "opacity-100 visible pointer-events-auto"
+ : "opacity-0 invisible pointer-events-none group-hover:opacity-100 group-hover:visible group-hover:pointer-events-auto"
+ )}
+ >
+ <DropdownMenu
+ open={openMenuId === conv.id}
+ onOpenChange={(open) => setOpenMenuId(open ? conv.id : null)}
+ >
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
onClick={(e) => e.stopPropagation()}
+ className={cn(
+ "h-7 w-7 inline-flex items-center justify-center",
+ "text-muted-foreground hover:text-foreground hover:bg-muted/60"
+ )}
+ aria-label="Conversation actions"
+ disabled={rowPending}
+ >
+ {rowPending ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <MoreVertical className="h-4 w-4" />
+ )}
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ side="bottom"
+ sideOffset={6}
+ className="w-[156px] p-1 rounded-none border border-border bg-background shadow-none"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <DropdownMenuItem
+ className="text-[11px] h-[30px] px-2 gap-2 rounded-none focus:bg-muted/30"
+ disabled={rowPending}
+ onSelect={(e) => {
+ toggleSelected(conv.id);
+ }}
+ >
+ <CheckSquare className="h-3 w-3 text-muted-foreground" />
+ {selected ? "Deselect" : "Select"}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator className="my-1 bg-border/70" />
+ <DropdownMenuItem
+ className="text-[11px] h-[30px] px-2 gap-2 rounded-none focus:bg-muted/30"
+ disabled={rowPending}
+ onSelect={(e) => {
+ void (async () => {
+ if (rowPendingIds.has(conv.id)) return;
+ setRowPendingIds((prev) => new Set(prev).add(conv.id));
+ try {
+ const nextPinned = !conv.pinned;
+ if (nextPinned && conv.hidden) {
+ await updateConversationFlags(conv.id, { pinned: true, hidden: false });
+ patchSidebarSession(conv.id, { pinned: true, hidden: false }, conv);
+ try {
+ await emit("chat-visibility-changed", { id: conv.id, hidden: false });
+ } catch {
+ // ignore
+ }
+ } else {
+ await updateConversationFlags(conv.id, { pinned: nextPinned });
+ patchSidebarSession(conv.id, { pinned: nextPinned }, conv);
+ }
+ void load();
+ } catch {
+ toast({
+ title: "Update failed",
+ description: "Could not update this chat. Please try again.",
+ });
+ } finally {
+ setRowPendingIds((prev) => {
+ const next = new Set(prev);
+ next.delete(conv.id);
+ return next;
+ });
+ }
+ })();
+ }}
>
+ <Pin className="h-3 w-3 text-muted-foreground" />
+ {conv.pinned ? "Unpin" : "Pin"}
+ </DropdownMenuItem>
+ {!conv.hidden ? (
<DropdownMenuItem
className="text-[11px] h-[30px] px-2 gap-2 rounded-none focus:bg-muted/30"
disabled={rowPending}
onSelect={(e) => {
- toggleSelected(conv.id);
+ void (async () => {
+ await updateConversationFlags(conv.id, { hidden: true, pinned: false });
+ patchSidebarSession(conv.id, { hidden: true, pinned: false }, conv);
+ try {
+ await emit("chat-visibility-changed", { id: conv.id, hidden: true });
+ } catch {
+ // ignore
+ }
+ void load();
+ })();
}}
>
- <CheckSquare className="h-3 w-3 text-muted-foreground" />
- {selected ? "Deselect" : "Select"}
+ <Archive className="h-3 w-3 text-muted-foreground" />
+ Archive
</DropdownMenuItem>
- <DropdownMenuSeparator className="my-1 bg-border/70" />
+ ) : (
<DropdownMenuItem
className="text-[11px] h-[30px] px-2 gap-2 rounded-none focus:bg-muted/30"
disabled={rowPending}
onSelect={(e) => {
void (async () => {
- if (rowPendingIds.has(conv.id)) return;
- setRowPendingIds((prev) => new Set(prev).add(conv.id));
+ await updateConversationFlags(conv.id, { hidden: false });
+ patchSidebarSession(conv.id, { hidden: false }, conv);
try {
- const nextPinned = !conv.pinned;
- if (nextPinned && conv.hidden) {
- // Make it atomic from the user's perspective:
- // keep the row in Archived until persistence completes, then refresh.
- await updateConversationFlags(conv.id, { pinned: true, hidden: false });
- patchSidebarSession(conv.id, { pinned: true, hidden: false }, conv);
- try {
- await emit("chat-visibility-changed", { id: conv.id, hidden: false });
- } catch {
- // ignore
- }
- } else {
- await updateConversationFlags(conv.id, { pinned: nextPinned });
- patchSidebarSession(conv.id, { pinned: nextPinned }, conv);
- }
- void load();
+ await emit("chat-visibility-changed", { id: conv.id, hidden: false });
} catch {
- toast({
- title: "Update failed",
- description: "Could not update this chat. Please try again.",
- });
- } finally {
- setRowPendingIds((prev) => {
- const next = new Set(prev);
- next.delete(conv.id);
- return next;
- });
+ // ignore
}
+ void load();
})();
}}
>
- <Pin className="h-3 w-3 text-muted-foreground" />
- {conv.pinned ? "Unpin" : "Pin"}
- </DropdownMenuItem>
- {!conv.hidden ? (
- <DropdownMenuItem
- className="text-[11px] h-[30px] px-2 gap-2 rounded-none focus:bg-muted/30"
- disabled={rowPending}
- onSelect={(e) => {
- void (async () => {
- await updateConversationFlags(conv.id, { hidden: true, pinned: false });
- patchSidebarSession(conv.id, { hidden: true, pinned: false }, conv);
- try {
- await emit("chat-visibility-changed", { id: conv.id, hidden: true });
- } catch {
- // ignore
- }
- void load();
- })();
- }}
- >
- <Archive className="h-3 w-3 text-muted-foreground" />
- Archive
- </DropdownMenuItem>
- ) : (
- <DropdownMenuItem
- className="text-[11px] h-[30px] px-2 gap-2 rounded-none focus:bg-muted/30"
- disabled={rowPending}
- onSelect={(e) => {
- void (async () => {
- await updateConversationFlags(conv.id, { hidden: false });
- patchSidebarSession(conv.id, { hidden: false }, conv);
- try {
- await emit("chat-visibility-changed", { id: conv.id, hidden: false });
- } catch {
- // ignore
- }
- void load();
- })();
- }}
- >
- <Undo2 className="h-3 w-3 text-muted-foreground" />
- Unarchive
- </DropdownMenuItem>
- )}
- <DropdownMenuItem
- className="text-[11px] h-[30px] px-2 gap-2 rounded-none text-destructive focus:text-destructive focus:bg-destructive/10"
- disabled={rowPending}
- onSelect={(e) => {
- setDeleteIds([conv.id]);
- }}
- >
- <Trash2 className="h-3 w-3 text-destructive" />
- Delete
+ <Undo2 className="h-3 w-3 text-muted-foreground" />
+ Unarchive
</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
+ )}
+ <DropdownMenuItem
+ className="text-[11px] h-[30px] px-2 gap-2 rounded-none text-destructive focus:text-destructive focus:bg-destructive/10"
+ disabled={rowPending}
+ onSelect={(e) => {
+ setDeleteIds([conv.id]);
+ }}
+ >
+ <Trash2 className="h-3 w-3 text-destructive" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
</div>
</div>
</div>
@@ -536,174 +523,106 @@ export function ChatHistoryView({
return (
<div className="h-full flex flex-col min-h-0">
- <div className="shrink-0 border-b border-border/50 bg-background">
- <div className="px-8 py-6">
- <div className="flex items-end gap-3">
- <div className="flex-1 min-w-0">
- <h1 className="text-3xl font-semibold tracking-tight truncate">Chats</h1>
- </div>
- <div ref={searchWrapRef} className="flex items-center gap-2">
- {!searchOpen ? (
- <Button
- variant="ghost"
- size="icon"
- className="h-9 w-9"
- title="Search chats"
- aria-label="Search chats"
- onClick={() => setSearchOpen(true)}
- >
- <Search className="h-4 w-4" />
- </Button>
- ) : (
- <div className="relative w-[320px]">
- <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- ref={searchInputRef}
- placeholder="Search chats…"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={(e) => {
- if (e.key !== "Escape") return;
- e.preventDefault();
- if (query.trim()) setQuery("");
- else setSearchOpen(false);
- }}
- className="h-9 pl-9 pr-9"
- />
+ <div ref={scrollContainerRef} className="flex-1 min-h-0 overflow-y-auto">
+ {/* Sticky header: tabs + search/bulk bar */}
+ <div className="sticky top-0 z-10 bg-background">
+ <div className="max-w-4xl mx-auto px-6 pt-6">
+ {/* Tabs */}
+ <div
+ className="flex items-center gap-6 border-b border-border/60"
+ role="tablist"
+ aria-label="Chat filter"
+ >
+ {TABS.map((t) => {
+ const active = tab === t.value;
+ return (
<button
+ key={t.value}
type="button"
+ role="tab"
+ aria-selected={active}
+ onClick={() => setTab(t.value)}
className={cn(
- "absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 transition-colors",
- "text-muted-foreground hover:text-foreground hover:bg-muted/50"
+ "relative -mb-px py-2 text-sm tracking-wide transition-colors duration-150",
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-background",
+ active
+ ? "text-foreground"
+ : "text-muted-foreground hover:text-foreground"
)}
- aria-label={query.trim() ? "Clear search" : "Close search"}
- title={query.trim() ? "Clear" : "Close"}
- onClick={() => {
- if (query.trim()) setQuery("");
- else setSearchOpen(false);
- }}
>
- <X className="h-3.5 w-3.5" />
+ {t.label}
+ <span
+ aria-hidden
+ className={cn(
+ "absolute left-0 right-0 -bottom-px h-px transition-colors duration-150",
+ active ? "bg-foreground" : "bg-transparent"
+ )}
+ />
</button>
- </div>
- )}
+ );
+ })}
</div>
- <Button
- variant="default"
- className="h-9 px-4 gap-2"
- onClick={() => {
- setSearchOpen(false);
- setQuery("");
- onNewChat();
- onBack();
- }}
- title="New chat"
- >
- <Plus className="h-4 w-4" />
- New chat
- </Button>
- </div>
- <div
- className="mt-6 flex items-center gap-6 border-b border-border/60"
- role="tablist"
- aria-label="Chat filter"
- >
- {TABS.map((t) => {
- const active = tab === t.value;
- return (
- <button
- key={t.value}
- type="button"
- role="tab"
- aria-selected={active}
- onClick={() => setTab(t.value)}
+ {/* Search + New Chat / Bulk Actions (swap in-place) */}
+ <div className="mt-4 mb-4 h-9">
+ {showBulkBar ? (
+ <div
className={cn(
- "relative -mb-px py-2 text-sm tracking-wide transition-colors duration-150",
- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-background",
- active
- ? "text-foreground"
- : "text-muted-foreground hover:text-foreground"
+ "grid grid-cols-[20px_1fr_auto] items-center gap-3 px-3 h-9 border border-border bg-background",
+ "transition-opacity duration-150",
+ selectedIds.size > 0
+ ? "opacity-100"
+ : "opacity-0 pointer-events-none"
)}
>
- <span className="lowercase">{t.label}</span>
- <span
- aria-hidden
- className={cn(
- "absolute left-0 right-0 -bottom-px h-px transition-colors duration-150",
- active ? "bg-foreground" : "bg-transparent"
- )}
- />
- </button>
- );
- })}
- </div>
- </div>
- </div>
-
- <div ref={scrollContainerRef} className="flex-1 min-h-0 overflow-y-auto">
- <div className="px-8 py-6 max-w-5xl">
- {showBulkBar && (
- <TooltipProvider>
- <div
- className={cn(
- "mb-2 flex items-center gap-3 text-xs text-muted-foreground",
- "transition-all duration-150",
- selectedIds.size > 0
- ? "opacity-100 translate-y-0"
- : "opacity-0 -translate-y-1 pointer-events-none"
- )}
- >
- {(() => {
- const selectedVisibleCount = visibleIds.reduce(
- (acc, id) => acc + (selectedIds.has(id) ? 1 : 0),
- 0
- );
- const hasAnyVisible = visibleIds.length > 0;
- const allVisibleSelected =
- hasAnyVisible && selectedVisibleCount === visibleIds.length;
- const someVisibleSelected = selectedVisibleCount > 0 && !allVisibleSelected;
- return (
- <div className={ROW_GUTTER_CLASS}>
- <Checkbox
- checked={
- allVisibleSelected ? true : someVisibleSelected ? "indeterminate" : false
- }
- onCheckedChange={() => {
- if (!hasAnyVisible) return;
- if (allVisibleSelected) clearSelection();
- else setAllVisibleSelected();
- }}
- aria-label={
- allVisibleSelected ? "Clear selection" : "Select all visible chats"
- }
- onClick={(e) => e.stopPropagation()}
- />
+ {/* Col 1: Select-all checkbox (aligns with row checkboxes) */}
+ <div className="h-5 w-5 flex items-center justify-center">
+ {(() => {
+ const selectedVisibleCount = visibleIds.reduce(
+ (acc, id) => acc + (selectedIds.has(id) ? 1 : 0),
+ 0
+ );
+ const hasAnyVisible = visibleIds.length > 0;
+ const allVisibleSelected =
+ hasAnyVisible && selectedVisibleCount === visibleIds.length;
+ const someVisibleSelected = selectedVisibleCount > 0 && !allVisibleSelected;
+ return (
+ <Checkbox
+ checked={
+ allVisibleSelected ? true : someVisibleSelected ? "indeterminate" : false
+ }
+ onCheckedChange={() => {
+ if (!hasAnyVisible) return;
+ if (allVisibleSelected) clearSelection();
+ else setAllVisibleSelected();
+ }}
+ aria-label={
+ allVisibleSelected ? "Clear selection" : "Select all visible chats"
+ }
+ />
+ );
+ })()}
</div>
- );
- })()}
- <div
- className={cn(
- "flex-1 min-w-0 rounded-md px-3 py-1.5",
- "grid grid-cols-[1fr_64px_28px] items-center gap-3"
- )}
- >
- <div className="flex items-center gap-2 min-w-0">
- <span className="tabular-nums leading-none">
- {selectedIds.size} selected
- </span>
- {bulkPending && (
- <span className="inline-flex items-center gap-1 text-muted-foreground/70">
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- {bulkPending === "archiving"
- ? "Archiving…"
- : bulkPending === "restoring"
- ? "Restoring…"
- : "Deleting…"}
+ {/* Col 2: Selection count + pending state */}
+ <div className="flex items-center gap-2 min-w-0">
+ <span className="text-sm tabular-nums text-muted-foreground">
+ {selectedIds.size} selected
</span>
- )}
- <div className="flex items-center gap-1">
+ {bulkPending && (
+ <span className="inline-flex items-center gap-1 text-xs text-muted-foreground/70">
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ {bulkPending === "archiving"
+ ? "Archiving…"
+ : bulkPending === "restoring"
+ ? "Restoring…"
+ : "Deleting…"}
+ </span>
+ )}
+ </div>
+
+ {/* Col 3: Action buttons */}
+ <div className="flex items-center gap-4">
{(() => {
const ids = Array.from(selectedIds);
const canArchive = ids.some((id) => !visibleById.get(id)?.hidden);
@@ -715,127 +634,140 @@ export function ChatHistoryView({
return (
<>
{showArchive && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7 text-muted-foreground hover:text-foreground"
- disabled={bulkPending != null}
- onClick={async () => {
- const idsToArchive =
- tab === "all"
- ? ids.filter((id) => !visibleById.get(id)?.hidden)
- : ids;
- if (idsToArchive.length === 0) return;
- setBulkPending("archiving");
- const result = await bulkSetHidden(idsToArchive, true);
- setBulkPending(null);
- if (result.failed.length > 0) {
- toast({
- title: "Some chats could not be archived",
- description: `${result.failed.length} failed.`,
- });
- return;
- }
- clearSelection();
- void load();
- }}
- aria-label="Archive selected"
- >
- <Archive className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="top" className="text-xs">
- Archive
- </TooltipContent>
- </Tooltip>
+ <button
+ type="button"
+ className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50"
+ disabled={bulkPending != null}
+ onClick={async () => {
+ const idsToArchive =
+ tab === "all"
+ ? ids.filter((id) => !visibleById.get(id)?.hidden)
+ : ids;
+ if (idsToArchive.length === 0) return;
+ setBulkPending("archiving");
+ const result = await bulkSetHidden(idsToArchive, true);
+ setBulkPending(null);
+ if (result.failed.length > 0) {
+ toast({
+ title: "Some chats could not be archived",
+ description: `${result.failed.length} failed.`,
+ });
+ return;
+ }
+ clearSelection();
+ void load();
+ }}
+ >
+ <Archive className="h-3.5 w-3.5" />
+ Archive
+ </button>
)}
{showRestore && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7 text-muted-foreground hover:text-foreground"
- disabled={bulkPending != null}
- onClick={async () => {
- const idsToRestore =
- tab === "all"
- ? ids.filter((id) => visibleById.get(id)?.hidden)
- : ids;
- if (idsToRestore.length === 0) return;
- setBulkPending("restoring");
- const result = await bulkSetHidden(idsToRestore, false);
- setBulkPending(null);
- if (result.failed.length > 0) {
- toast({
- title: "Some chats could not be restored",
- description: `${result.failed.length} failed.`,
- });
- return;
- }
- clearSelection();
- void load();
- }}
- aria-label="Restore selected"
- >
- <Undo2 className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="top" className="text-xs">
- Restore
- </TooltipContent>
- </Tooltip>
+ <button
+ type="button"
+ className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50"
+ disabled={bulkPending != null}
+ onClick={async () => {
+ const idsToRestore =
+ tab === "all"
+ ? ids.filter((id) => visibleById.get(id)?.hidden)
+ : ids;
+ if (idsToRestore.length === 0) return;
+ setBulkPending("restoring");
+ const result = await bulkSetHidden(idsToRestore, false);
+ setBulkPending(null);
+ if (result.failed.length > 0) {
+ toast({
+ title: "Some chats could not be restored",
+ description: `${result.failed.length} failed.`,
+ });
+ return;
+ }
+ clearSelection();
+ void load();
+ }}
+ >
+ <Undo2 className="h-3.5 w-3.5" />
+ Restore
+ </button>
)}
</>
);
})()}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7 text-muted-foreground hover:text-destructive"
- onClick={() => setDeleteIds(Array.from(selectedIds))}
- disabled={bulkPending != null}
- aria-label="Delete selected"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="top" className="text-xs">
- Delete
- </TooltipContent>
- </Tooltip>
- </div>
- </div>
- <div aria-hidden />
+ <button
+ type="button"
+ className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50"
+ onClick={() => setDeleteIds(Array.from(selectedIds))}
+ disabled={bulkPending != null}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ Delete
+ </button>
- <div className="flex justify-end">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7 text-muted-foreground hover:text-foreground"
- onClick={clearSelection}
- disabled={bulkPending != null}
- aria-label="Clear selection"
- >
- <X className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="top" className="text-xs">
- Clear selection
- </TooltipContent>
- </Tooltip>
+ <button
+ type="button"
+ className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50"
+ onClick={clearSelection}
+ disabled={bulkPending != null}
+ >
+ <X className="h-3.5 w-3.5" />
+ Close
+ </button>
+ </div>
</div>
+ ) : (
+ <div className="flex items-center gap-3 h-9">
+ <div className="relative flex-1 min-w-0">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
+ <Input
+ ref={searchInputRef}
+ placeholder="search chat"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key !== "Escape") return;
+ e.preventDefault();
+ if (query.trim()) setQuery("");
+ }}
+ className="h-9 pl-9 pr-9"
+ />
+ {query.trim() && (
+ <button
+ type="button"
+ className={cn(
+ "absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 transition-colors",
+ "text-muted-foreground hover:text-foreground hover:bg-muted/50"
+ )}
+ aria-label="Clear search"
+ title="Clear"
+ onClick={() => setQuery("")}
+ >
+ <X className="h-3.5 w-3.5" />
+ </button>
+ )}
+ </div>
+ <Button
+ variant="default"
+ className="h-9 px-4 gap-2 shrink-0"
+ onClick={() => {
+ setQuery("");
+ onNewChat();
+ onBack();
+ }}
+ title="New chat"
+ >
+ <Plus className="h-4 w-4" />
+ New chat
+ </Button>
</div>
+ )}
</div>
- </TooltipProvider>
- )}
+ </div>
+ </div>
+
+ {/* Scrollable list content */}
+ <div className="max-w-4xl mx-auto px-6 pb-6">
{loading ? (
<div className="min-h-[40vh] flex items-center justify-center">
<div className="flex items-center gap-2 text-xs text-muted-foreground">
@@ -848,7 +780,7 @@ export function ChatHistoryView({
{query.trim() ? "No matching chats." : "No chats yet."}
</div>
) : (
- <div className="space-y-1">
+ <div className="divide-y divide-border/30">
{list.map((c) => (
<Row key={c.id} conv={c} />
))}