Skip to content

Search cached messages, on the socket and as tinyclient --text --search. - #12

Merged
itz4blitz merged 1 commit into
itz4blitz:mainfrom
unRekable:search/cached-messages
Oct 17, 2026
Merged

itz4blitz merged 1 commit into
itz4blitz:mainfrom
unRekable:search/cached-messages

Conversation

@unRekable

Copy link
Copy Markdown
Collaborator

What changed and why

The roadmap's message search starts here: the cache is searched, over the socket and from the
text shell. A query returns the newest hits, each with where it is and enough of it to choose
by. A later change puts the same hits in the switcher and lands on the message; after that the
networks themselves are asked (the spec's N12, staged).

  • Request::SearchMessages (filters optional), Response::MessageHits and MessageHit,
    added by the protocol's optional-field rules, so an older frame still reads.
  • Store::search_messages: LIKE over the message text, joined to the conversation for its
    title, newest first, clamped to PAGE_LIMIT.
  • tinyclient --text --search <query>: the hits as lines, so the change is usable without the
    window.
  • architecture.md's request table and the README's not-built-yet line follow the change.

Decisions taken in the change, with their reasons

  • Message requests are not searched, nor hidden conversations, nor messages that never
    went. The product keeps requests out of everything that counts and promises "opening one
    reads nothing"; a search that surfaced one would get around that. One SQL condition, tested.
  • No paging. Spec N12 is per keystroke; who needs more narrows the query or the
    conversation. A cursor can come later as an optional field, which costs nothing then.
  • LIKE, not FTS5. Measured on a 40,000-message store (20 conversations x 2,000, what
    retention holds): 8 to 16 ms per search in a release build, holding the store's lock. It
    grows with the cache, so an honest ceiling exists. FTS5 would raise the schema version and
    with it delete every user's cache, and would add index bookkeeping to ingest, deletes, prune
    and forget. When a real, large cache shows the need, that change can stand on its own.

Test

  • Store: newest-first order, conversation and network filters, hidden, request and pending
    excluded, case-insensitive, %/_/\ mean themselves, and the snippet window with its
    ... markers.
  • Protocol: the exact wire format of the request and the answer.
  • Measured against the seeded demo over the socket: tinyclient --text --search lichen
    returns the two hits with titles and snippets.

Numbers

40,000 messages, release build, the store's lock held while searching: 15.5 ms (4,000 hits),
10.4 ms (common word), 7.9 ms (full scan, no hits). Grows with the cache; the fix, when a real
cache needs it, is FTS5 as its own change.

Tested on Windows with --no-default-features (no protoc here for the signal feature);
cargo check -p tinyclient --features gui passes. The chatd suites that fail on this machine
(discord's spawn of true, the mediad process lookups in e2e, the release-json test in
tinyclient) fail the same on clean main; the blobs picker test is flaky under parallel load
and passes alone.

@unRekable
unRekable marked this pull request as ready for review October 17, 2026 13:56
@unRekable
unRekable requested a review from itz4blitz as a code owner October 17, 2026 13:56
@unRekable
unRekable force-pushed the search/cached-messages branch from d123677 to 4433107 Compare October 17, 2026 14:38

@itz4blitz itz4blitz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cached message search matches the protocol and store rules from review: bound LIKE with escaping, requests/hidden/pending excluded, and the README keeps the Signal Note to Self paragraph. macOS, Linux, and Windows CI are green on 4433107.

@itz4blitz
itz4blitz merged commit ed8912e into itz4blitz:main Oct 17, 2026
3 checks passed
@unRekable
unRekable deleted the search/cached-messages branch October 17, 2026 16:13
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.

2 participants