The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): ⌘K session search reflects renames and archives immediately
brooklyn!122ffd3f398c
diff --git a/apps/desktop/src/app/command-palette/index.tsx b/apps/desktop/src/app/command-palette/index.tsxindex 98a3cf7f39e..3bed6c48bfa 100644--- a/apps/desktop/src/app/command-palette/index.tsx+++ b/apps/desktop/src/app/command-palette/index.tsx@@ -74,7 +74,8 @@ import { $dismissedAutoProjectIds, filterVisibleProjects } from '@/store/layout'import { openPetGenerate } from '@/store/pet-generate'import { openBrowserTab } from '@/store/preview'import { $projectTree, goToProject, openFolderAsProject, requestStartWorkSession } from '@/store/projects'-import { $connection } from '@/store/session'+import { $connection, $cronSessions, $messagingSessions, $sessions } from '@/store/session'+import { $removedSessionIds } from '@/store/session-removal'import { runGatewayRestart } from '@/store/system-actions'import {$backendUpdateApply,@@ -393,6 +394,11 @@ const toSessionEntry = (session: SessionRow): SessionEntry => ({title: sessionTitle(session)})+// Search terms beyond the label: the preview and branch, so a session is+// findable by what it's about, not only what it's called.+const sessionKeywords = (session: SessionEntry, ...tags: string[]): string[] =>+ [...tags, 'chat', 'session', session.preview, session.git_branch].filter((word): word is string => !!word)+type NonConfigSettingsLabel ='about' | 'archivedChats' | 'gateway' | 'keysSettings' | 'keysTools' | 'mcp' | 'providerAccounts' | 'providerApiKeys'@@ -637,21 +643,51 @@ function CommandPaletteBody({ onExited }: { onExited: () => void }) {queryFn: () => getHermesConfigRecord()})+ // staleTime 0 (not the 60s client default): renames, pins, and archives+ // happen in the sidebar while this component is unmounted, so nothing can+ // invalidate these keys — every open must revalidate. The cached page+ // still paints instantly; the live-store overlay below covers the gap.const sessionsQuery = useQuery({queryKey: ['command-palette', 'sessions'],- queryFn: () => listAllProfileSessions(200, 1, 'exclude')+ queryFn: () => listAllProfileSessions(200, 1, 'exclude'),+ staleTime: 0})const archivedQuery = useQuery({queryKey: ['command-palette', 'archived'],- queryFn: () => listAllProfileSessions(200, 0, 'only')+ queryFn: () => listAllProfileSessions(200, 0, 'only'),+ staleTime: 0})+ const liveSessions = useStore($sessions)+ const liveCronSessions = useStore($cronSessions)+ const liveMessagingSessions = useStore($messagingSessions)+ const removedSessionIds = useStore($removedSessionIds)+// getServers is the shared choke point that also drops malformed (null/// scalar) entries, so the palette never lists a server the MCP tab dropped.const mcpServers = useMemo(() => Object.keys(getServers(configQuery.data ?? null)).sort(), [configQuery.data])- const sessions = useMemo(() => (sessionsQuery.data?.sessions ?? []).map(toSessionEntry), [sessionsQuery.data])+ // The sidebar's stores are where a rename / pin / archive lands first (the+ // server page confirms later). Overlay them on the fetched 200-row page so+ // the palette says what the sidebar says: same title, same pin, and no row+ // the user just archived or deleted.+ const liveRows = useMemo(() => {+ const byId = new Map(+ [...liveCronSessions, ...liveMessagingSessions, ...liveSessions].map(row => [row.id, row] as const)+ )++ return (sessionsQuery.data?.sessions ?? [])+ .filter(session => !removedSessionIds.has(session.id))+ .map(session => {+ const live = byId.get(session.id)++ return live ? { ...session, pinned: live.pinned, title: live.title } : session+ })+ }, [liveCronSessions, liveMessagingSessions, liveSessions, removedSessionIds, sessionsQuery.data])++ const sessions = useMemo(() => liveRows.map(toSessionEntry), [liveRows])+const archivedSessions = useMemo(() => (archivedQuery.data?.sessions ?? []).map(toSessionEntry), [archivedQuery.data])// Search/sub-page are local to a mount, and this component remounts per open@@ -1168,12 +1204,7 @@ function CommandPaletteBody({ onExited }: { onExited: () => void }) {items: sessions.map(session => ({icon: MessageCircle,id: `session-${session.id}`,- keywords: [- 'chat',- 'session',- ...(session.preview ? [session.preview] : []),- ...(session.git_branch ? [session.git_branch] : [])- ],+ keywords: sessionKeywords(session),label: session.title,runWithEvent: goSession(session.id)}))@@ -1230,13 +1261,7 @@ function CommandPaletteBody({ onExited }: { onExited: () => void }) {items: archivedSessions.map(session => ({icon: Archive,id: `archived-${session.id}`,- keywords: [- 'archived',- 'chat',- 'session',- ...(session.preview ? [session.preview] : []),- ...(session.git_branch ? [session.git_branch] : [])- ],+ keywords: sessionKeywords(session, 'archived'),label: session.title,run: go(`${SETTINGS_ROUTE}?tab=sessions&session=${encodeURIComponent(session.id)}`)}))