Skip to content

perf: skip redundant sessions query for file-only search (CS-32)#112

Merged
xingkaixin merged 1 commit into
mainfrom
feat/cs-32-skip-redundant-search
Jul 10, 2026
Merged

perf: skip redundant sessions query for file-only search (CS-32)#112
xingkaixin merged 1 commit into
mainfrom
feat/cs-32-skip-redundant-search

Conversation

@xingkaixin

Copy link
Copy Markdown
Owner

Summary

searchIndexedSessions always ran searchSessions alongside the file-activity path; for file-only queries every one of its hits was dropped by the first-write-wins dedupe — one wasted SQL round-trip per search (found during CS-30 characterization, quirk #7).

The skip is deliberately narrow. searchSessions still runs whenever it can contribute:

  • text present — FTS is the primary source
  • tools filtered — its empty-query branch is the sole source for tool-only queries
  • tags filteredlistFileActivity has no tag clause, so tag filtering only happens in searchSessions
  • from/to window — the file path filters on fa.latest_time, not the session's activity_time
  • fileKind-onlysearchFileActivitySessions returns nothing without a path, so searchSessions is the only source

New outcome tests assert each boundary via a Database.prototype.prepare spy (the sessions-table query is provably absent for file-only, provably present for the other four cases). The file+tags test also pins a pre-existing quirk as-is: file-path hits are tag-blind and win the dedupe, so a mismatched-tag session still surfaces today — unchanged by this PR, documented in the issue notes.

Verification

  • pnpm build ✓, pnpm test ✓ (core 291 / web 228 / cli 105), pnpm test:e2e
  • All CS-30 characterization/outcome tests pass unchanged

Issue: CS-32

searchIndexedSessions ran searchSessions unconditionally next to the
file-activity path, and for file-only queries its hits were always
dropped by the first-write-wins dedupe. Skip it when nothing else can
contribute: no text, no tools (empty-query branch is their sole
source), no tags (the file path is tag-blind), and no from/to window
(the file path filters on fa.latest_time, not activity_time).
@xingkaixin xingkaixin marked this pull request as ready for review July 10, 2026 10:59
@xingkaixin xingkaixin merged commit 33e4d90 into main Jul 10, 2026
7 checks passed
@xingkaixin xingkaixin deleted the feat/cs-32-skip-redundant-search branch July 10, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant