feat(ui): per-room scoped search from the room header (LC-268) #312
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-268-per-room-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
Adds a "search this room" box to the room header (LC-268). Typing scopes the existing full-text search to the current room, so you can find a message in the room you are viewing without wading through global results. Hits are jump links (
#msg-{id}) into the room, with the sharedsearch.jscombobox keyboard nav (Arrow/Enter/Esc).How
routes::search:SearchQuerygains an optionalroom_id. When set it takes precedence over enclave scope: the caller's room access is gated withis_room_accessible(403 if they cannot see it), then the FTS is narrowed viasearch_messages' existingroom_id_filter. The home-scope clause still enforces readability, so the filter only narrows - it cannot widen access. With noroom_id, the sidebar global search behaves exactly as before. No new DB query.partials/room_header.html: a compactdata-lc-searchinput whosehx-get="/search?room_id={{ room.id }}"targets a small results popover below it, mirroring the sidebar search markup sosearch.jsdrives nav and Enter jumps to the hit.No new route, DB query, or env var. Not operator-visible.
Tests
routes_search_room: a room-A-scoped search returns A's hit and not room B's; searching a private room a non-admin cannot access 403s.just testandjust test-saaspass.Note
This branch also picks up a 2-line
cargo fmtnormalization ofroutes_reactions_authz.rs(the LC-266react_bodyhelper merged without a fmt pass since CI does not gate fmt); it just makesmainfmt-clean again.QA note
Server-gated and test-covered, so low-risk. Worth a quick manual check: open a room, type in the header search (results are from this room only, jump on click/Enter); confirm an empty query collapses the popover; confirm the sidebar global search still works unchanged.
Adds a "search this room" box to the room header. Typing scopes the existing full-text search to the current room, so you can find a message in the room you are viewing without wading through global results. Hits are jump links (#msg-{id}) into the room, with the shared search.js combobox keyboard nav. The /search handler gains an optional room_id param. When set it takes precedence over enclave scope: the caller's room access is gated (403 if they cannot see the room), then the FTS is narrowed to that room via search_messages' existing room_id_filter. The home-scope clause still enforces readability, so the filter only narrows - it cannot widen access. With no room_id the behavior (sidebar global search) is unchanged. No new DB query. The header input reuses the sidebar search markup (data-lc-search + results popover) so search.js drives Arrow/Enter/Esc. Strings localized in en + es. Tests assert a room-scoped search excludes other rooms' hits and that an inaccessible room 403s. #LC-268 #LC-269 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>