Skip to content

feat(platform): let chat list the emailed attachments in scope - #3033

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/list-mail-attachments
Aug 21, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/list-mail-attachments

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

Chat can now list the emailed attachments a caller may read. Closes the remaining half of #3016.

Why

An emailed attachment had no listing surface anywhere in the product. It is not a Document Hub row, so it is absent from the Documents page and from list kind="document" — list_documents_for_agent.ts walks the documents table, and a mail attachment has only a fileMetadata row plus a corpus row. Its sole appearance was on its own conversation in the Inbox.

So retrieval was the only way to discover one, which means guessing words inside a file whose name says nothing about why it was sent. #3029 gave the Document Hub a list action; this gives mail attachments one.

What changed

  • rag_search gains a tenth kind, mail-attachment, listable through action: "list".
  • Rows carry the corpus ref, so a listed attachment can be read with rag_fetch rather than searched for by name.
  • Rows carry indexed. Received-but-unindexed is a real state, and implying it is readable sets the model up to fetch text that is not there.
  • The caller resolution behind the retrieval gate moved into conversation_caller.ts, and both the gate and this listing call it.
  • Timeline label thinking.listing.mailAttachments in en, de and fr. de-CH overrides nothing in that block.

Risk

Scope is shared, not copied. Each row is decided by conversationAssignmentAllows against the conversation as it stands now, through the same resolver the gate uses. A listing is a wider door than a search — search needs the caller to guess words in the file, a listing hands over the catalogue — so one deriving its own notion of visibility would drift wider than the search beside it. The read subject is conversations, not documents, because an attachment is visible exactly when its conversation is.

Because assignment is read live, reassigning a conversation moves its attachments in this listing too, with nothing rewritten.

Two bounds, both reported. limit bounds what is kept; the scan cap bounds what is examined. The second is the one that matters: the walk filters as it goes, so a caller who can read few conversations rejects most of what it touches, and an unbounded walk would read the whole table. Newest-first, because the bound decides the answer.

This kind narrows rather than pages, matching the choice #3029 made for conversations and websites.

Tests

Twelve at the reader, through convex-test against the real schema: admin sees unassigned and other-team mail, a member sees only their team's, an individual assignee sees theirs, a disabled role sees nothing, an unidentified caller sees nothing, unbound and trashed rows are excluded, the indexed flag is real, the newest survive the limit, the corpus ref is carried, a cross-org conversation reference lists nothing, and the scan budget stops the walk and says so.

The non-member case is not testable here — a caller absent from memberMirror falls through to the Better Auth component, which convex-test cannot register. It is covered where the shared resolver is driven directly, and since both surfaces now use that resolver, that one test covers this listing too.

Ten mutations, all red. Three survived first: a cross-org conversation reference was unasserted, the scan bound was unasserted, and an unbound-row guard was redundant with the check inside the allow helper, so no test could tell it from dead code — removed rather than kept.

Scope

Does not page. Does not index message bodies (#3015). Does not give attachments a Documents-page surface — this is the chat tool only.

Gate: typecheck, oxlint --type-aware, oxfmt, SAST 0 findings, platform server+pii 75,399 tests, client 3,316 tests.

An emailed attachment had no listing surface anywhere. It is not a Document
Hub row, so it is absent from the Documents page and from
`list kind="document"` — `list_documents_for_agent.ts` walks the `documents`
table, and a mail attachment has only a `fileMetadata` row and a corpus row.
Its sole appearance was on its own conversation in the Inbox, so retrieval was
the only way to discover one, and that means guessing words inside a file whose
name says nothing about why it was sent.

`rag_search` gains a tenth kind, `mail-attachment`, so `action: "list"` browses
them. Rows carry the corpus ref, so a listed attachment can be read with
`rag_fetch` rather than searched for by name, and an `indexed` flag, because
received-but-unindexed is a real state and implying it is readable sets the
model up to fetch text that is not there.

Scope is each attachment's conversation as it stands NOW, decided by the same
predicate and the same resolver the retrieval gate uses — the caller resolution
moved into `conversation_caller.ts` so both surfaces share it. A listing is a
wider door than a search: search needs the caller to guess words that appear in
the file, a listing hands over the catalogue. One deriving its own notion of
visibility would drift wider than the search beside it, and the failure mode is
publishing an inbox. The read subject is `conversations`, not `documents`, for
the same reason.

Two bounds, both reported. `limit` bounds what is kept; the scan cap bounds what
is EXAMINED, which is the one that matters — the walk filters as it goes, so a
caller who can read few conversations rejects most of what it touches. Newest
first: the bound decides the answer, so oldest-first would answer "what has come
in?" with the stalest mail on the box.
@Israeltheminer
Israeltheminer merged commit f227f28 into main Aug 21, 2026
50 checks passed
@Israeltheminer
Israeltheminer deleted the feat/list-mail-attachments branch August 21, 2026 12:10
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