Skip to content

feat(desktop): search sessions by id (SQL-bounded) - #39062

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-f6349bd2
Jun 4, 2026
Merged

feat(desktop): search sessions by id (SQL-bounded)#39062
teknium1 merged 2 commits into
mainfrom
hermes/hermes-f6349bd2

Conversation

@teknium1

@teknium1 teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds session-ID search to Hermes Desktop (exact / prefix / substring, lineage-aware) across the sidebar, command center, and the search backend — and makes the ID lookup SQL-bounded instead of an O(n) Python scan.

Salvage of #37883 by @0xharryriddle onto current main. Fixes #37882.

Changes

  • apps/desktop/src/lib/session-search.ts: shared sessionMatchesSearch helper (id + _lineage_root_id + title/preview/cwd).
  • apps/desktop sidebar: uses the shared helper, so the sidebar matches by session id including compression-lineage root.
  • apps/desktop command center: haystack now includes id + _lineage_root_id.
  • hermes_state.py: list_sessions_rich gains an optional id_query — a case-insensitive LIKE pushed into SQL, matched against each surfaced row's id AND every id in its forward compression chain (via the existing chain CTE). search_sessions_by_id now fetches only matching rows and ranks exact > prefix > substring over that small set.
  • hermes_cli/web_server.py: /api/sessions/search surfaces direct id matches first, then FTS content matches, both deduped through one compression-lineage keyspace.
  • Tests: TS Vitest for the helper, Python state tests for id/prefix/substring/lineage/limit, endpoint dedup-ordering test.

Why the follow-up commit

@0xharryriddle's original fetched up to 10k sessions and filtered in Python (O(n) per keystroke). The perf commit pushes the filter into SQL and unifies the id/content dedup so a compression tip can't double-list.

Validation

Before After
ID search over 3000+ sessions ~3000 rows materialized in Python 1 row, ~5ms (E2E verified)
Root-id search n/a resolves to live projected tip
Targeted tests 39 passing (state + endpoint)
Desktop typecheck tsc -b clean

Authorship preserved: @0xharryriddle's feature commit + a Teknium perf follow-up, rebase-merge.

Infographic

desktop-session-id-search

0xharryriddle and others added 2 commits June 4, 2026 06:02
search_sessions_by_id previously fetched up to 10k sessions via
list_sessions_rich and filtered them in Python — O(n) per keystroke.
Push the id match into SQL instead.

- list_sessions_rich gains an optional id_query param: a case-insensitive
  LIKE pushed into the outer WHERE, matched against each surfaced row's id
  AND every id in its forward compression chain (via the existing chain
  CTE). Searching a compression root id or a tip id both resolve to the
  same projected conversation. LIKE wildcards in the needle are escaped.
- search_sessions_by_id now fetches only matching rows (limit*4) and ranks
  exact > prefix > substring in Python over that small set.
- web_server /api/sessions/search: route ID matches and content matches
  through one lineage-keyed dedup helper so an id-hit and a content-hit on
  the same conversation collapse to a single result (the contributor's
  version keyed ID hits by raw sid and content hits by root, which could
  double-list a compression tip).
- command-center haystack also matches _lineage_root_id for parity.

E2E verified against a real DB: exact match over 3000+ sessions
materializes 1 row in Python (was ~3000), 5ms; root-id resolves to tip;
LIKE-wildcard escaping holds.

Follow-up to @0xharryriddle's feat(desktop): search sessions by id.
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-f6349bd2 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9807 on HEAD, 9805 on base (🆕 +2)

🆕 New issues (1):

Rule Count
invalid-argument-type 1
First entries
hermes_cli/web_server.py:1728: [invalid-argument-type] invalid-argument-type: Argument to function `add_lineage_result` is incorrect: Expected `str`, found `Any | None`

✅ Fixed issues: none

Unchanged: 5089 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/feature New feature or request comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels Jun 4, 2026
@teknium1
teknium1 merged commit 580d924 into main Jun 4, 2026
23 checks passed
@teknium1
teknium1 deleted the hermes/hermes-f6349bd2 branch June 4, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Search Hermes Desktop Sessions by Session ID

3 participants