Fossil User Forum

RFC: integrating /chat-search into the main /chat UI
Login

RFC: integrating /chat-search into the main /chat UI

RFC: integrating /chat-search into the main /chat UI

(1.1) By Stephan Beal (stephan) on 2024-06-30 08:48:46 edited from 1.0 [link] [source]

Dan Kennedy, of sqlite fame, recently pushed the fts5-chat-search branch, which adds a /chat-search page for (spoiler alert!) searching through the /chat history.

My tasks is now to figure out how best to integrate that capability into the main /chat page, and this post is a Request for Comments about how to go about that. The essential question is:

How should the UI/UX of such integration look/feel like?

There are at least two options:

  1. Show the search results in their own dedicated view (like how the config options and preview work). This would be pretty straightforward and Dan's already done 98% of the work for that part.

  2. Integrate the search results with the main /chat message feed. That seems, to me, more confusion-prone: we would need to integrate the search results into the currently-loaded feed, in their correct order. Most of the results are likely to be much older than the current conversation, so would be scrolled back above the currently-loaded messages, possibly requiring many mouse-wheels of scrolling to reach them.

How to achieve option 1 is clear. How to achieve option 2 is not, and your suggestions on how it might function would be appreciated. Similarly, any hypothetical other options would be appreciated, as would ideas for what useful new functionality we could add based on historical search.

(2.1) By Warren Young (wyoung) on 2024-06-30 09:07:41 edited from 2.0 in reply to 1.1 [link] [source]

For such a limited search set size, I'd add a magnifying glass button that pops up a search box toast with input focus set. On each keystroke, send the new search string to the back end and get the sorted result set, LIMIT 50. On scrolling up, reapply the same search for the prior 50, etc.

Better, apply the endless scroll technique to it all to hide the artificial 50-message chunk size.

Point being, 1000 messages is “lots” to humans, but to computers, repeating the search at human typing speed of ~10 keystrokes per second max gives eons of computer time between each to hide the HTTP round-trip in. This is especially true since a 10 character search string is likely to reduce the search set to a few results at most. The search gets faster the more specific you make it.

(3.5) By Stephan Beal (stephan) on 2024-07-02 11:37:52 edited from 3.4 in reply to 1.1 [source]

The /chat-search page functionality has been moved over into a new search feature of the /chat page. Every effort has been made to make the UI behavior for the search as intuitive as possible, but ideas for improvement are welcomed.

Definite TODO(s):

  • Figure out why the search index is not being updated for new messages. The associated triggers are in place and seem to be correct. Edit: Dan fixed that - fossil disables non-temp triggers, which caused the update triggers to be no-ops.

  • Have the chat search index use the same FTS5 config options as the repo search, e.g. so that it can work with Chinese text if configured to do so. Similarly, rebuild the chat search index when the repo's main search index is rebuilt. Done. We should arguably tie the chat search into the general repo-related search options, and will consider that as one of the...

Potential TODOs with no immediate priority include:

  • "Endless scrolling" to replace the current "load previous X messages" buttons. This needs to be done for both the main message list and search results.

  • The ability to search by message number, so that User A does not have to copy/paste search result text into a new message to convey something. Instead they can say "search for #12345." The old/incomplete markdown-tagrefs branch would tie well into this but that branch still has unresolved parsing corner cases.

  • The ability to "forward" a search result message to the main chat view, as if it had been sent but (A) retaining its original author/timestamp info, (B) appending it to the end of the list (like a new message, instead of sorting by its original time), and (C) clearly marking it as a forwarded/repeated message.

  • ...?

BTW, Warren: search-as-you-type was not added for the simple reason that the search input frield is the same widget as the message input (to save space on phone screens, as /chat actually gets quite a bit of usage on phones).