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
This commit is contained in:
ethernet 2026-07-15 15:37:12 -04:00 committed by GitHub
parent c1945d410b
commit 4e7b0389ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View file

@ -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<ReturnType<typeof listAllProfileSessions>>['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)}`)
}))

View file

@ -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)

View file

@ -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))
}