fix(search): make the sidebar People tab actually query /users/search (LC-392) #404
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lc-392-people-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?
Fixes LC-392. The sidebar search "People" tab returned nothing - typing a name surfaced no users.
Root cause
The LC-369 search input is server-rendered with
hx-get="/search"(messages). The People tab switch didinput.setAttribute('hx-get', '/users/search'). But htmx resolves an element's request verb + path once, at process time, and binds them into the trigger-handler closure - it does not re-readhx-geton each fire (the attribute name is even built dynamically as"hx-"+verb, so the literal never appears in the source). So mutating the attribute had no effect on the input's own debouncedinput/focus/ Enter triggers: they kept issuingGET /search. The tab handler's immediatehtmx.ajax('GET', '/users/search', ...)used the explicit path, so it only flickered people results before the next keystroke reverted to messages.Backend was fine:
/users/search->users::get_user_search->db::auth::search_usersworks, andis_profile_publicdefaults to 1, so public profiles are findable.Fix
Track the active mode and rewrite the request path in an
htmx:configRequestlistener (fires before every htmx request, exposesdetail.path+detail.elt, and takes effect regardless of the captured path), scoped to#sidebar-search-inputso other/searchcallers (room-scoped search, etc.) are untouched. The placeholder/aria swap and the immediate re-fire are unchanged.Testing
./dev/cargo checkclean.just check,just test,just test-saasall green (exit 0, zero failures).No operator-visible change (UI only): no
[operator-action]marker.htmx resolves an element's request verb+path once at process time and binds them into the trigger closure; it does not re-read hx-get per fire. The LC-369 tab switch did input.setAttribute('hx-get', '/users/search'), which therefore never redirected the input's own debounced input/focus/Enter triggers - they kept hitting /search, so People search returned message results (or nothing) and looked dead. The immediate htmx.ajax fire used the explicit path, so it only flickered. Track the active mode and rewrite the request path in an htmx:configRequest listener (fires before every request, takes effect regardless of the captured path), scoped to #sidebar-search-input so other /search callers are untouched. The placeholder/aria swap and immediate re-fire are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>