45 messages · 3 searches
One room, one append-only log, and a search that fills up as people talk.
What fold does here
Messages are a log of events. Counts per author and in total are views, and so is search: a BM25 index over every message, which fold updates in the same commit as each send. There's no separate search service to keep in step.
Names and colours aren't stored anywhere. Each browser gets a random id in a cookie, and its label and colour are read straight off the bits.
Why it shows off fold
Search that's always current. A search index usually lags its database: it's rebuilt on a schedule or fed by a pipeline. Here the index is just another view, so a message is searchable the moment it commits. New messages are pushed to every open page from a fold subscription, and a page holding a search asks the index again only when a new message could match, so fold ranks it into place.
Worth trying
- Search for a word, then ask someone to type it. Their message lands in your results, ranked, as they send it.
- Type the start of a word: "wo" already finds every "wow".
- Watch the caption: how many results, how big the index is, and how long the query took.
Still app code
Very little: the cookie id, highlighting the matched words, and the page itself.
Press \ in the app to watch fold's commits as they happen.