feat(ui): search operators from: and before:/after: (LC-280) #318
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-280-search-operators"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Message search now understands typed operators that refine a text query (LC-280):
from:<username>- only that author's messagesbefore:<YYYY-MM-DD>/after:<YYYY-MM-DD>- date-boundedThey combine with the free text and with the existing room-scoped (LC-268) and enclave scopes, e.g.
from:alice before:2024-06-01 deploy.How
SearchFilters { author_id, before, after }+search_messages_filtered(...)which appendsAND m.user_id = ?,AND m.created_at < ?,AND m.created_at >= ?(and their binds, last, in that order) to the existing query.search_messagesstays a thin shim delegating with default filters, so all existing callers/tests are untouched (the bind order is positional and brittle - this keeps it intact).routes::search):parse_operatorspullsfrom:/before:/after:tokens out of the query; dates are validated with chrono and an invalid value is left as plain text (no silent filtering).from:<name>resolves viafind_user_by_username(an unknown user yields no results); the remaining text goes through the unchangedsanitize_fts_querypath. Filters only narrow within the caller's already-access-scoped set - no new disclosure.Scope notes:
in:<room>was dropped (room names are not unique across enclaves, and the LC-268 room-header search box already covers "this room"); a pure-operator query with no free text collapses the popover, matching today's empty-query behavior (the FTS path requires a MATCH term). No UI/i18n change - operators are typed by power users.No new DB column or env. Not operator-visible.
Tests
db_search: author filter returns only that author's hits;before/afterbound by date.routes_search_room:from:bob needlereturns only bob's hit; an unknownfrom:returns no results.routes::searchunit tests: operator parsing +YYYY-MM-DDvalidation.just testandjust test-saaspass.QA note
Mostly server-side and test-covered. Worth a quick manual check in the sidebar message search:
from:<someone> <term>narrows to their messages;before:2020-01-01 <term>returns nothing recent; an invalid date likebefore:soon <term>just searches the text; plain text and the room-header search are unchanged. (No placeholder hint yet - operators are undocumented in the UI for now.)