Skip to content

feat(platform): find a conversation by its message text - #3084

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/conversation-body-search
Aug 26, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/conversation-body-search

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

Chat can now find a conversation by a word in one of its messages, not only by its subject or who it is with.

Why

An email arrives with a CV attached. The attachment is searchable; the covering note that explains what the sender wants is not. Asking about an order number, a serial, or a name that appears only in the body of a message found nothing, so the only route to a conversation was remembering its subject line.

The file already said this was the missing leg, and that the index it needed existed.

What changed

One bounded pre-pass over conversationMessages, walking by_organizationId_and_deliveredAt newest-first, turning the term into a set of conversation ids — the same shape the contact-name leg already uses. A conversation then matches on its subject, on being with a matching contact, or on one of its messages containing the term.

HTML is stripped before matching. Bodies arrive as whatever the sender's mail client produced, so matching raw would make a search for "table" hit every <table>. htmlToText is the existing stripper, and the cheap < test keeps a plain-text body from paying for it.

MESSAGE_SCAN_CAP is 400 and BODY_MATCH_CAP is 50, both separate from the conversation walk's own cap. Messages outnumber conversations several times over, and this walk pays a strip per row rather than an assignment decision.

Risk

The body walk reads text the caller may not be allowed to see. That is safe only because it returns conversation ids and nothing else — every id still faces conversationAssignmentAllows in the main walk, so an unreadable conversation's body match is collected and then discarded. A test asserts a member outside the assignment gets nothing from a body that plainly matches.

Truncation from the body walk makes the whole answer partial, not just that leg, so it is folded into the returned truncated. A caller told "no matches" would otherwise read it as complete when the walk stopped at 400 messages.

It is keyword matching. A question phrased by meaning rather than by words that appear in the mail will not match, and neither will anything past either cap. Nothing here embeds or stores anything, which is the trade: no third-party processing, no backfill, and it works on existing mail immediately.

Tests

Six cases: a body-only match, a body match refused for the wrong caller, matching through HTML, not matching a word that exists only in markup, truncation surfacing from the body walk, and a listing skipping the walk entirely.

Five deliberate breakages, all caught: the leg switched off, the HTML strip removed, truncation dropped, the cap raised, and the assignment check disabled.

Scope

Does not index anything. Email bodies still have no presence in the search index, which is #3015 — a different trade, and one that owes an erasure cascade.

Gate: repo-wide typecheck, oxlint --type-aware, oxfmt, knip, SAST 0 findings, platform suite 75,801 passing.

@Israeltheminer
Israeltheminer merged commit 0453e65 into main Aug 26, 2026
51 checks passed
@Israeltheminer
Israeltheminer deleted the feat/conversation-body-search branch August 26, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant