The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): sidebar search shows the real session title, not the matched snippet (#91068)
Brooklyn Nicholson15c775aa2207
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsxindex e58fe3af359..c1fb61a44ee 100644--- a/apps/desktop/src/app/chat/sidebar/index.tsx+++ b/apps/desktop/src/app/chat/sidebar/index.tsx@@ -289,7 +289,13 @@ export function stripFtsMarkers(snippet: string): string {return snippet.replaceAll('>>>', '').replaceAll('<<<', '')}-function searchResultToSession(result: SessionSearchResult): SessionInfo {+// The backend already ships the real session title on every search hit+// (web_routers/sessions.py add_lineage_result enriches each result via+// get_session_rich_row). Map it onto the synthesized row so the sidebar+// paints the actual name; the snippet stays as the preview. Untitled+// sessions keep today's snippet fallback via sessionTitle().+// Exported for tests.+export function searchResultToSession(result: SessionSearchResult): SessionInfo {const ts = result.session_started ?? Date.now() / 1000return {@@ -307,7 +313,7 @@ function searchResultToSession(result: SessionSearchResult): SessionInfo {preview: stripFtsMarkers(result.snippet ?? '').trim() || null,source: result.source ?? null,started_at: ts,- title: null,+ title: result.title?.trim() || null,tool_call_count: 0}}diff --git a/apps/desktop/src/app/chat/sidebar/search-result-to-session.test.ts b/apps/desktop/src/app/chat/sidebar/search-result-to-session.test.tsnew file mode 100644index 00000000000..c843748d3cc--- /dev/null+++ b/apps/desktop/src/app/chat/sidebar/search-result-to-session.test.ts@@ -0,0 +1,56 @@+// Regression (#91068): the backend's /api/sessions/search payload carries the+// real session title on every hit (web_routers/sessions.py add_lineage_result+// enriches via get_session_rich_row), but the sidebar's search mapper dropped+// it (title: null). sessionTitle() then fell back to the preview — the FTS+// snippet of the matched message — painting rows with raw message content+// (tool JSON, shell commands) as the session name.+import { describe, expect, it } from 'vitest'++import { searchResultToSession } from './index'++describe('searchResultToSession', () => {+ it('uses the backend-provided title for the synthesized row', () => {+ const s = searchResultToSession({+ lineage_root: 'root-1',+ model: 'deepseek-v4-flash',+ role: 'tool',+ session_id: '20260725_132',+ session_started: 1753450000,+ snippet: '{"bytes_written": 1879, "dirs_created": true}',+ source: 'agent',+ title: ' Fact-checking PR review comments '+ })++ expect(s.title).toBe('Fact-checking PR review comments')+ expect(s.id).toBe('20260725_132')+ })++ it('keeps the FTS snippet as the preview with markers stripped', () => {+ const s = searchResultToSession({+ session_id: 'cron_f7da0e4',+ session_started: null,+ snippet: '...Report "PR #>>>67834<<< still in draft..."',+ role: 'user',+ model: null,+ source: 'cron',+ title: 'PR #67834 CI followup'+ })++ expect(s.title).toBe('PR #67834 CI followup')+ expect(s.preview).toBe('...Report "PR #67834 still in draft..."')+ })++ it('leaves title null when the backend sends none (untitled session)', () => {+ const s = searchResultToSession({+ session_id: '20260720_233',+ session_started: null,+ snippet: '[{"id": "call_d632e8dc7bf740048f242bfe", "c...',+ role: 'assistant',+ model: null,+ source: null+ })++ expect(s.title).toBeNull()+ expect(s.preview).toBe('[{"id": "call_d632e8dc7bf740048f242bfe", "c...')+ })+})diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.tsindex 46fdcea1a46..f2a5d455e68 100644--- a/apps/desktop/src/types/hermes.ts+++ b/apps/desktop/src/types/hermes.ts@@ -1329,6 +1329,11 @@ export interface SessionSearchResult {session_started: number | nullsnippet: stringsource: string | null+ /** Real session title from the sessions table; the backend enriches every+ * search hit with it (web_routers/sessions.py add_lineage_result), absent+ * for untitled sessions. The sidebar maps it onto the synthesized row so+ * search hits show the actual name, not the matched-message snippet. */+ title?: string | null}export interface SessionSearchResponse {