Repository navigation
feat(platform): let chat list the emailed attachments in scope - #3033
Merged
Merged
Conversation
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.
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tswalks thedocumentstable, and a mail attachment has only afileMetadatarow 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
listaction; this gives mail attachments one.What changed
rag_searchgains a tenth kind,mail-attachment, listable throughaction: "list".ref, so a listed attachment can be read withrag_fetchrather than searched for by name.indexed. Received-but-unindexed is a real state, and implying it is readable sets the model up to fetch text that is not there.conversation_caller.ts, and both the gate and this listing call it.thinking.listing.mailAttachmentsinen,deandfr.de-CHoverrides nothing in that block.Risk
Scope is shared, not copied. Each row is decided by
conversationAssignmentAllowsagainst 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 isconversations, notdocuments, 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.
limitbounds 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
indexedflag 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
memberMirrorfalls 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.