← Context/ issues

The Recent Mail List Has No Previews

Asking for the latest mail returns senders and subjects with an empty preview. Previews only appear when there's a keyword to search for.

What we saw

Claude noted that listing the latest mail shows no preview text; previews only appear when searching with keywords. To know what a recent message says, it has to call read_message on each one.

Why

In connector/src/tools.ts, search_mail has two queries. With a keyword, the preview is FTS5's snippet(...), which only works inside a MATCH. Without one, the query selects '' AS snippet, an empty string by design. The same is true of kaymail.py's search on the laptop.

Fix

Without a query, return the first ~160 characters of the body as the preview: substr(m.body, 1, 160), with whitespace collapsed and quoted reply text (lines starting >, and "On … wrote:" blocks) stripped where that's cheap. Keep it inside the same untrusted-data markers as other mail content, since it's text a stranger wrote.

If reading body for 25–200 rows is slow on D1, store a short preview column at index time instead.

How we'll know

search_mail with no query returns a non-empty preview for every message with a text body.

Resolved (2026-11-27)

search_mail with no query reads the first 2,000 characters of each body and returns a one-line preview (preview() in connector/src/tools.ts): quoted lines and everything from an "On … wrote:" line dropped, whitespace collapsed, cut at 160 characters, inside the same untrusted-data markers. Reading the body for up to 200 rows was fine on D1, so no preview column was needed. Test: "listing recent mail gives each message a preview without the quoted reply". The laptop's kaymail.py search still returns no preview there.