Text chat 17: core search (#267) #349
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-17-core-search"
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 this builds
fluxer-core::chat::search(spec §6.2 "Search", §3.7):parse(&str, UtcOffset) -> SearchQuery: the original's query language (SearchQueryParser.ts:46-79,SearchUtils.ts):from:/-from:,mentions:(incl.everyone),in:/-in:,has:(forward->snapshot),before:/after:/on:/during:anda..branges,last:,beforeid:/afterid:,pinned:,author-type:,link:,filename:,ext:,sort:,order:,scope:,any:,mature:, embed filters, quoted values and"exact phrases"; unknown keys stay text. Dates become snowflake bounds in the given offset.SearchQuery::to_request(&App, page) -> SearchRequest: names resolved against the store, 25 per page, scope from menu/query limited to the channel's scope options,context_channel_id/context_guild_id, the sort menu wins oversort:(asapplySortModeToParams).{indexing:true}polls at 1500 ms x 1.25^n capped at 5000 ms (indexing_poll_interval); stale answers and stale timers dropped; 10 recent searches, newest first, deduplicated.selectors):search_results(&App) -> SearchResultsModel { total, page, pages, groups, state }(runs of consecutive same-channel results) andsearch_suggestions(&App, text, cursor)(Filters, Recent, Users, Channels, Dates, Values).Testing
crates/fluxer-core/tests/chat_search.rs:parse_cases(table, well over 15 cases),request_scope_and_context,page_size_25,indexing_poll_backoff,grouping_runs_by_channel,recent_searches_kept_10,jump_from_result, plus date bounds in local offset, blank query, failure state, suggestion sections and an odd-input no-panic table. Uses the existingfixtures/rest/search_results.json/search_indexing.json.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Deviations
SearchResultsStatehas aResultsvariant besides the plan'sIdle | Loading | Indexing | Empty | Error.chat_ports.rs::stubs_emit_nothingnow skipsUserAction::Search(search is no longer a stub).LocalSettings::chat.recent_searches, andSearch::utc_offsetis UTC until the runtime sets it: that wiring lives inapp.rs/persist.rs/chat/state.rs(outside this task's files) and is tracked in #315. Relative dates (today,last:2d) resolve against the newest message id the store knows (no clock, #109).2cf6ba9): date conversions are checked (checked_to_offset), so far-year instants in a non-UTC offset no longer panic (cases added toodd_input_never_panicsfor offsets ±14 h and ±25:59:59 and far-past/far-future nows); an instant typed with a zone now ends itsduring:/on:day in that zone (DateSpec::Instant { at_ms, offset }, testduring_an_instant_ends_with_its_day_in_its_zone); the plan records the extraResultsvariant for Text chat 30.Follow-ups
ApiResultshape changed outside this task).Closes #267
🤖 Generated with Claude Code
Independent review: Text chat 17 (core search), head
8535597I reviewed only
git diff 9fcc13d..origin/textchat-17-core-search(search.rs, selectors/mod.rs, chat_ports.rs, chat_search.rs, README).What checks out
parse_cases(36 cases covering from/-from, has:image, has:forward→snapshot, before/after/during/on, in:, pinned:true, sort:relevance, quoted values, unknown key kept as text),request_scope_and_context,page_size_25,indexing_poll_backoff(1500, 1875, 2343, 2929, 3662, 4577, 5000, 5000),grouping_runs_by_channel(runs, not buckets),recent_searches_kept_10,jump_from_result. The indexing test change after the failing-test commit only adds checks (it is stricter).search::parse(&str, UtcOffset) -> SearchQuery,SearchQuery::to_request(&App, page) -> SearchRequest,selectors::search_results/search_suggestionswithSearchResultsModel { total, page, pages, groups, state }andResultGroup { channel_id, messages }(pluschannel) all exist and are re-exported fromselectors.resolveSearchScope(SearchScopeResolution.ts) andgetScopeOptionsForChannelexactly: the override, then parsedscope:, then the active scope, each only if offered, falling back tocurrent. The menu's sort always wins (applySortModeToParams). Date bounds followparseQuery(before→start, after→end, during→start..resolveDuringUpperBound, ranges, later filter wins).search_results.json/search_indexing.json).FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a clean review worktree: all steps passed.Findings
[blocking] Typed query panics the reducer once the local offset is not UTC.
during_upper_bound(search.rs:1392-1394) callsOffsetDateTime::to_offset, and time 0.3.55 panics there when the result is out of range.parse("on:9999-12-31T23:00Z", offset!(+1)).id_bounds(None)panics at search.rs:1394 (I confirmed it with a scratch test).Search::Submit→build→id_boundsruns insideApp::apply, so as soon as the runtime setsSearch::utc_offset(#315 / Text chat 21), typing that query crashes the client.odd_input_never_panicsuses +14 but has no far-year instant, so it does not catch this. Fix: usechecked_to_offset(or convert the date in the offset withoutto_offset) and add the case toodd_input_never_panics. While you are there, also make theto_offsetinDateSpec::resolveanddate_wordschecked.[minor] A superseded search's answer is shown as the current one.
ApiResult::SearchResultscarries no effect id or request (Task 10's shape), andansweraccepts the first answer after any submit. Example: submit "first", then "second"; if the first answer arrives first, it is kept as the results of "second" and the real answer is dropped (confirmed with a scratch test). Sort, page and scope changes made while a search is in flight hit the same problem. The real fix needs the event to carry theEffectId(or the request), which is outside this task's files. Please open a follow-up/bug before merge.[minor] Recent searches are not persisted and the offset stays UTC. Already tracked in #315. Link it from the PR body as a follow-up.
[minor] Interface deviation:
SearchResultsStatehas an extraResultsvariant besides the plannedIdle | Loading | Indexing | Empty | Error. It is additive and needed, but please record it in the plan's interface notes for Text chat 30.[minor] The "now" stand-in (#109). Relative dates resolve against the max
channel.last_message_id, which MESSAGE_CREATE keeps current. On a quiet account,today,last:2dandweekresolve days in the past. This is documented in the README and #315, so it is acceptable until #109 lands.[minor] An instant with an explicit zone ends at the end of the day in the local offset. For
on:2024-05-01T10:00+09:00,resolveDuringUpperBoundin the original takes the end of the day in the parsed zone (LuxonsetZone). Here it is taken in the local offset. This is a small divergence.Verdict: changes requested. There is 1 blocking finding (#1: a one-line checked conversion plus a test case). CI is green locally.
Independent review: Text chat 17 (core search), head
c1a1526Scope:
git diff b87bcd9..origin/textchat-17-core-search(search.rs, selectors/mod.rs, chat_ports.rs, chat_search.rs, README, plan note).Checked
parse_caseshas 36 cases (from/-from, has:image, has:forward -> snapshot, before/after/during/on, in:, pinned:true, sort:relevance, quoted values, unknown key kept as text). Alsorequest_scope_and_context(scopecurrent, context channel and guild ids, 25 per page, the sort menu wins),page_size_25(31 results give 2 pages, page 401 and page 0 are refused),indexing_poll_backoff(1500, 1875, 2343, 2929, 3662, 4577, 5000, 5000, matchingChannelSearchPolling.ts),grouping_runs_by_channel(runs, not buckets),recent_searches_kept_10andjump_from_result.parse(&str, UtcOffset) -> SearchQuery,SearchQuery::to_request(&App, page) -> SearchRequest,selectors::search_resultsandselectors::search_suggestions(&App, text, cursor) -> Vec<SuggestionSection>all exist as planned. Two additions, neither breaks a consumer:ResultGrouphas an extrachannelfield, andSearchResultsStatehas an extraResultsvariant (recorded in the plan for Text chat 30).timewas already a fluxer-core dependency.search_results.jsonandsearch_indexing.json.KNOWN_KEYS,matchFilterKeyAt, the quote characters andchannel_id+channel_idsmatchSearchQueryParser.tsandSearchUtils.ts:210.checked_to_offset, the cursor is clamped to a char boundary, and slicing is bounded.odd_input_never_panicscovers offsets up to ±25:59:59 and far-year nows.LocalSettings::chat.recent_searchesis left untouched, so the settings file still round-trips.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a fresh review worktree: all steps passed (livekit-interop skipped by default).Findings
Search::utc_offsetstays UTC until the runtime sets it. The spec says "kept locally". This is deferred and tracked in #315.The merge-conflict resolutions in
selectors/mod.rsandchat_ports.rsare correct: both sides are kept.Verdict: approve. No blocking findings and local CI is green.