Skip to content

[GEN-11] Search index rebuilt from scratch on every message-list change #354

@intendednull

Description

@intendednull

Audit finding from #300 (commit 679f9fe)

Severity: high
Category: performance / bug
File: crates/web/src/app.rs:341
Obvious fix: no

Description

The Effect at app.rs:341 reads messages_sig.get() (current-channel messages) and calls search.rebuild(indexable), which drops the index and re-inserts every message (each insert clones the full Posting per token — see GEN-03). On every send / receive / edit, the entire index is destroyed and rebuilt synchronously on the WASM main thread. Worse: the comment claims indexing is global, but the effect only feeds in the current channel's messages (current_channel_sig derived list); switching channels wipes the index for the previous channel.

Impact / Threat

User-facing — every keystroke that arrives over the wire causes a UI stutter; cross-channel search is broken (results vanish when you switch away).

Suggested fix

Use the existing incremental_insert path on MessageReceived events; subscribe at the client-event stream level instead of the rendered-message signal. Hydrate once on bootstrap.

Verify

rg "search\.rebuild\(indexable\)" crates/web/src/app.rs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions