hermes-agent/apps/desktop/src/lib/session-search.ts
ethernet 4e7b0389ea
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
2026-07-15 15:37:12 -04:00

23 lines
631 B
TypeScript

import { normalize } from '@/lib/text'
import type { SessionInfo } from '@/types/hermes'
import { sessionTitle } from './chat-runtime'
import { sessionSourceSearchTerms } from './session-source'
export function sessionMatchesSearch(session: SessionInfo, query: string): boolean {
const needle = normalize(query)
if (!needle) {
return true
}
return [
session.id,
session._lineage_root_id ?? '',
sessionTitle(session),
session.preview ?? '',
session.cwd ?? '',
session.git_branch ?? '',
...sessionSourceSearchTerms(session.source)
].some(value => value.toLowerCase().includes(needle))
}