feat(desktop): search sessions by id (SQL-bounded) - #39062
Merged
Conversation
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.
Contributor
🔎 Lint report:
|
| 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.
19 tasks
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: sharedsessionMatchesSearchhelper (id +_lineage_root_id+ title/preview/cwd).apps/desktopsidebar: uses the shared helper, so the sidebar matches by session id including compression-lineage root.apps/desktopcommand center: haystack now includesid+_lineage_root_id.hermes_state.py:list_sessions_richgains an optionalid_query— a case-insensitiveLIKEpushed 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_idnow fetches only matching rows and ranks exact > prefix > substring over that small set.hermes_cli/web_server.py:/api/sessions/searchsurfaces direct id matches first, then FTS content matches, both deduped through one compression-lineage keyspace.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
tsc -bcleanAuthorship preserved: @0xharryriddle's feature commit + a Teknium perf follow-up, rebase-merge.
Infographic