From 9cd894a8f2e479e593f89eb7f32b1d4da7dc963e Mon Sep 17 00:00:00 2001 From: Sreeram Sreedhar Date: Mon, 22 Jun 2026 16:19:40 -0700 Subject: [PATCH] Open desktop search results in preview --- apps/desktop/app/(app)/page.tsx | 92 ++++++++++++++++------ apps/desktop/components/search-command.tsx | 9 ++- apps/desktop/lib/search.ts | 2 + 3 files changed, 78 insertions(+), 25 deletions(-) diff --git a/apps/desktop/app/(app)/page.tsx b/apps/desktop/app/(app)/page.tsx index b692b583..52684971 100644 --- a/apps/desktop/app/(app)/page.tsx +++ b/apps/desktop/app/(app)/page.tsx @@ -12,19 +12,33 @@ import { import { Clock, FileText, RefreshCcw, Search } from "lucide-react" import { useMemo, useState } from "react" import { listDocuments, type DocumentWithMemories } from "@/lib/api" +import type { SearchResult } from "@/lib/search" import { SearchCommand, useCommandK } from "@/components/search-command" +type MemoryPreview = { + id: string + title: string | null + summary?: string | null + content?: string | null + raw?: string | null + url?: string | null + type?: string | null + createdAt: string | Date +} + export default function DashboardPage() { const { open, setOpen } = useCommandK() - const [selectedDocument, setSelectedDocument] = - useState(null) + const [selectedMemory, setSelectedMemory] = useState( + null, + ) const documentsQuery = useQuery({ queryKey: ["desktop-documents"], queryFn: listDocuments, staleTime: 60 * 1000, }) const documents = documentsQuery.data?.documents ?? [] - const activeDocument = selectedDocument ?? documents.at(0) ?? null + const activeMemory = + selectedMemory ?? toMemoryPreview(documents.at(0) ?? null) const totalCount = documentsQuery.data?.pagination.totalItems const subtitle = useMemo(() => { if (documentsQuery.isPending) return "Loading your recent memories." @@ -90,10 +104,10 @@ export default function DashboardPage() {