Skip to content

feat(remote-threads): a paired device can send documents with a thread message and read them back - #2505

Merged
TheAnimatrix merged 2 commits into
masterfrom
paired-device-documents
Nov 30, 2026
Merged

TheAnimatrix merged 2 commits into
masterfrom
paired-device-documents

Conversation

@TheAnimatrix

Copy link
Copy Markdown
Collaborator

Problem

A paired phone or computer could send only pictures into a thread on this computer. Any other file was refused, because a file attached here goes to the agent as a path on this computer, and nothing carried another device's file onto it. The phone app therefore can't attach a PDF, a text file or an Office document to a thread, and it can't open such a file it sees in a transcript.

Change

  • Send: routed.orchestrator.send (version 11) and routed.queue.enqueue (version 4) take files: [{ name, data }] (data is base64), inline or staged as one value on routed.send.open, the same resumable bulk lane pictures use. Needs chat access, as any send does; a read-only device is refused before anything is written.
  • Checks (src/mms/bridge/routed/threadFiles.ts): at most 10 files and 18 MiB together (as base64 JSON that stays inside one 25 MiB staged value). Each name is made safe (no folders, no reserved Windows names). Its extension must be on the list in src/shared/bridge/threadFiles.ts, and its first bytes must match: %PDF- for PDF, a ZIP header for docx/xlsx/pptx/odt/epub/zip, an OLE header for doc/xls/ppt, gzip/7z/tar headers, and UTF-8 or UTF-16-with-BOM text with no zero bytes for text, data and code. Programs, installers, Windows script files, macro-enabled Office files and SVG are refused, as is anything whose bytes don't match its name.
  • Storage: files are written with wx (never over another file) and mode 600 into <temp>/mousse-attachments/<threadId>/<unique>-<name>. That is the folder where a file pasted into the composer already goes, with the same one-week cleanup. The message text gets the usual [Attached files: name (path)] line, so every provider reads the file as a local attachment. Nothing opens or runs it. A refused message deletes its files. The ledger's request id keeps a retried send from writing them twice.
  • Read back: new read row routed.thread.attachedFile { threadId, path, offset? }. It returns 40 KiB pages shaped like bots.chat.file, but only for a file directly in that thread's attachment folder, reached by real path, not through a link or hard link, and never SVG.
  • Capability: net.info now carries threadFiles: { v: 1, maxFiles, maxBytes, extensions }. A phone that checks it never sends files to an older desktop. The spec is updated in docs(app-session): a thread send may carry files where the host advertises threadFiles mousse-net#61 (merged, docs and one vector), and the vendored vectors now come from that merge.
  • Desktop windows, the composer and local sends are unchanged. Bot chats already took and served files on their own routes (bots.send.open, bots.chat.file); they are unchanged too.

Verification

Tier 5 (networking and security). node scripts/verify.mjs at a605e11, recorded as current:

  • PASS tests: 15 files, 236 tests: npx vitest run tests/net/bridge/routed/threadFiles.test.ts tests/net/bridge/routed/threadFilesSend.test.ts tests/net/bridge/routed/table.test.ts tests/net/bridge/routed/owner.test.ts tests/net/bridge/routed/access.test.ts tests/net/bridge/routed/accessClasses.test.ts tests/net/bridge/routed/sendManifest.test.ts tests/net/bridge/routed/ids.test.ts tests/gitAccessTable.test.ts tests/mmsProtocolServer.test.ts tests/netEngine/allowlist.test.ts tests/netEngine/appSessionVectors.test.ts tests/fileDrag.test.ts tests/bots/botChatAttachments.test.ts tests/net/connectedHere.test.ts
  • PASS tsc --noEmit -p tsconfig.node.json and tsc --noEmit -p tsconfig.web.json

What observes each part:

  • Types, byte sniffing, limits, names, storage, cleanup, the read-back folder rule (another thread, .., a relative path, a hard link, SVG): threadFiles.test.ts (33 rows).
  • A paired computer sending a PDF and a Markdown file through the real owner routes, with the message naming them and the device reading them back: threadFilesSend.test.ts. The same file covers a queued message, a disallowed type, an .exe named .pdf, a refused send leaving no file, files over 18 MiB on the bulk lane, a read-only device refused on both the send and send.open, and a dropped bulk upload resumed from the saved offset and then sent twice under one request id (one send, three files).
  • The new phone vector thread send carries files: appSessionVectors.test.ts.

Not checked by these runs:

  • A real phone. The phone app doesn't send files yet.
  • Each connection type (direct, LAN, Cloudflare, own relay, Plus) separately. The change is above the transport, in the routed rows every connection uses.
  • tests/net/bridge/routed/staging.test.ts (untouched code) timed out on this PC while other work held the CPU at 100%. It fails the same way on unchanged master in the same conditions.

Notes

A desktop composer sending documents to a thread on another computer still refuses them ("threads on another computer take images only"); it can use this owner side in a follow-up. Files the user picked from elsewhere on disk (not pasted) are not served by thread.attachedFile.

No issue

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