From 4e7b0389eaa259e0fff3c5d211a33e343471976e Mon Sep 17 00:00:00 2001 From: ethernet Date: Wed, 15 Jul 2026 15:37:12 -0400 Subject: [PATCH] fix(desktop): match sessions by git branch in ctrl-k palette and sidebar search (#65172) SessionInfo already carries git_branch from the backend, but neither the ctrl-k command palette nor the sidebar search function included it in their matching fields. Typing a branch name matched nothing. - session-search.ts: add session.git_branch to sessionMatchesSearch - command-palette/index.tsx: thread git_branch through SessionEntry and into the keywords array for both sessions and archived sessions groups - session-search.test.ts: cover full, partial, and "main" branch matches --- apps/desktop/src/app/command-palette/index.tsx | 6 ++++-- apps/desktop/src/lib/session-search.test.ts | 6 ++++++ apps/desktop/src/lib/session-search.ts | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/app/command-palette/index.tsx b/apps/desktop/src/app/command-palette/index.tsx index f7a6e0139403..09d6dac8a2a1 100644 --- a/apps/desktop/src/app/command-palette/index.tsx +++ b/apps/desktop/src/app/command-palette/index.tsx @@ -118,6 +118,7 @@ interface PalettePage { } interface SessionEntry { + git_branch?: null | string id: string preview?: string title: string @@ -212,6 +213,7 @@ const SESSION_ID_RE = /^\d{8}_\d{6}_[a-f0-9]{6}$/ type SessionRow = Awaited>['sessions'][number] const toSessionEntry = (session: SessionRow): SessionEntry => ({ + git_branch: session.git_branch ?? null, id: session.id, preview: session.preview ?? undefined, title: sessionTitle(session) @@ -684,7 +686,7 @@ export function CommandPalette() { items: sessions.map(session => ({ icon: MessageCircle, id: `session-${session.id}`, - keywords: ['chat', 'session', ...(session.preview ? [session.preview] : [])], + keywords: ['chat', 'session', ...(session.preview ? [session.preview] : []), ...(session.git_branch ? [session.git_branch] : [])], label: session.title, run: go(sessionRoute(session.id)) })) @@ -722,7 +724,7 @@ export function CommandPalette() { items: archivedSessions.map(session => ({ icon: Archive, id: `archived-${session.id}`, - keywords: ['archived', 'chat', 'session', ...(session.preview ? [session.preview] : [])], + keywords: ['archived', 'chat', 'session', ...(session.preview ? [session.preview] : []), ...(session.git_branch ? [session.git_branch] : [])], label: session.title, run: go(`${SETTINGS_ROUTE}?tab=sessions&session=${encodeURIComponent(session.id)}`) })) diff --git a/apps/desktop/src/lib/session-search.test.ts b/apps/desktop/src/lib/session-search.test.ts index 00027ff3186b..79384c9d5b12 100644 --- a/apps/desktop/src/lib/session-search.test.ts +++ b/apps/desktop/src/lib/session-search.test.ts @@ -52,6 +52,12 @@ describe('sessionMatchesSearch', () => { expect(sessionMatchesSearch(session, 'hermes-agent')).toBe(true) }) + it('matches sessions by git branch', () => { + expect(sessionMatchesSearch(makeSession({ git_branch: 'feat/cool-thing' }), 'feat/cool-thing')).toBe(true) + expect(sessionMatchesSearch(makeSession({ git_branch: 'feat/cool-thing' }), 'cool')).toBe(true) + expect(sessionMatchesSearch(makeSession({ git_branch: 'main' }), 'main')).toBe(true) + }) + it('matches sessions by source platform and aliases', () => { expect(sessionMatchesSearch(makeSession({ source: 'telegram' }), 'Telegram')).toBe(true) expect(sessionMatchesSearch(makeSession({ source: 'whatsapp' }), 'WhatsApp')).toBe(true) diff --git a/apps/desktop/src/lib/session-search.ts b/apps/desktop/src/lib/session-search.ts index 1b7f508a20b2..967c58816611 100644 --- a/apps/desktop/src/lib/session-search.ts +++ b/apps/desktop/src/lib/session-search.ts @@ -17,6 +17,7 @@ export function sessionMatchesSearch(session: SessionInfo, query: string): boole sessionTitle(session), session.preview ?? '', session.cwd ?? '', + session.git_branch ?? '', ...sessionSourceSearchTerms(session.source) ].some(value => value.toLowerCase().includes(needle)) }