Loquax: files
Status: slice one built (1221, 2026-11-01). Lew, 2026-10-31: attach a file to a message, compatible with the other messengers; the received file is kept on the phone and opens in the app the phone has for it.
Decisions
| Question | Decision |
|---|---|
| Wire | The LXMF file attachments field, 0x05, holding [[name, bytes], ...], the name a str, as the reference names it and Columba and Sideband write and read it. No field of our own. |
| A file and text | A file is one message with an empty text, as the plus sheet's File row sends it. A received message with several files shows a row for each. |
| Cap | 990 000 bytes a file: a receiver refuses a message past 1000 KB, and the message around the file needs room. Refused with both sizes said, before anything goes. |
| Names | What the sender wrote is shown and saved only after safe_name: no path, no control character, no leading dot. |
| Where it is kept | Under the home: files/<peer>-<key>-<n>/<name>, written once when the file is first opened. On the phone that is the app's own files; a provider of the app's lends that one file read only to the app that opens it. |
| Where the work is done | In Rust: the field, the cap and its words, the names, the save. Java keeps the system picker, the open and share intents and the provider. |
1. The wire
The reference defines FIELD_FILE_ATTACHMENTS = 0x05
(reference/LXMF/LXMF/LXMF.py:12). Columba writes
fields[LxmfFields.FIELD_FILE_ATTACHMENTS] = options.fileAttachments.map { (name, data) -> listOf(name, data) }
(columba/rns-backend-kt/src/main/kotlin/network/columba/app/rns/backend/kt/NativeMessageSender.kt:141-145,
the same in
columba/rns-backend-py/src/main/kotlin/network/columba/app/rns/backend/py/PythonRnsLxmf.kt:520-531),
whose comment says why the name is a str: Sideband renders it with
str(name), so a bin name shows as its b'...' repr. Columba reads an
entry of two or more elements, the name either a str or hex of a bin
(columba/app/src/main/java/network/columba/app/ui/model/MessageMapper.kt:784-800),
and its interop suite carries files both ways to Sideband
(columba/tests/interop/test_file.py). Sideband's source is not on this
host; the Python reference passes the field through unchanged.
The bytes Loquax writes for fields[5] = [["a.txt", 01 02]] are those
umsgpack.packb([["a.txt", b"\x01\x02"]]) gives:
05 91 92 a5 61 2e 74 78 74 c4 02 01 02
key arr arr "a.txt" bin 2
ui::files::tests::the_field_is_the_references_list_of_name_and_bytes
pins them. Reading is lenient (ui::files::file_parts): a name may be a
str or a bin, elements past the bytes are skipped, and an entry that does
not read is skipped while the rest are still read.
2. The caps
| Where | Limit | Source |
|---|---|---|
| A file Loquax sends | 990 000 bytes | loquax::ui::files::LARGEST, the same budget as an original photo |
| Any receiver, direct or over a link | 1000 KB a message | DELIVERY_LIMIT, reference/LXMF/LXMF/LXMRouter.py:60, applied at :1979; ours leviculum_lxmf::constants::DELIVERY_LIMIT_BYTES |
| A stock Python propagation node (lxmd) | 256 KB a message | PROPAGATION_LIMIT, reference/LXMF/LXMF/LXMRouter.py:55; lxmd's propagation_transfer_max_accepted_size default, reference/LXMF/LXMF/Utilities/lxmd.py:165-177 |
| lnpnd | 4 KB a message with no config file or flag, 256 with lxmd's config | transfer_limit_kb's fallback unwrap_or(4), lnpnd/src/main.rs:466-472 |
| A Loquax Mailbox's archive | 1024 MB in all, oldest first out | DEFAULT_ARCHIVE_CAP_MB, loquax/src/home.rs:300, archive_cap_mb in the config |
| Columba | none of its own | MAX_SINGLE_FILE_SIZE = Int.MAX_VALUE, columba/app/src/main/java/network/columba/app/util/FileUtils.kt:37; its receiver defaults to 1 MB (columba/app/src/main/java/network/columba/app/repository/SettingsRepository.kt:1849) |
So a file up to 990 KB goes to a peer that is online, and to a peer that is offline through a Loquax Mailbox. Through a stock propagation node a file past 256 KB is refused by the node (past 4 KB by an lnpnd started without a config): the same open question as a phone-size photo (photos, section 7).
The refusal says both sizes, in the reader's language: "This file is 4.2 MB. A message carries at most 990 KB." The phone reads at most the first megabyte of a picked file and only counts the rest, so a film is not held in memory to be refused.
3. The core
loquax/src/ui/files.rs:
FileRef { name, bytes },files_of,file_at,file_fields.send_name: a picked file goes under its last path element, cut to 255 bytes on a character.safe_name: what a received name may be shown and saved as./,\,:,*,?,",<,>,|and control characters become_; leading dots and spaces, and trailing ones, go; the name is cut to 120 bytes keeping its extension; nothing left isfile...isfile,../../etc/passwdis_.._etc_passwd.refusal(bytes): the cap's words, or none.UiEvent::SendFile { peer, name, data }sends one message whose only field is the file; past the cap it adds a toast and nothing.UiEvent::OpenFile { peer, key, index }givesUiEffect::OpenFile.chat::Bubble::files;scene::FileNodewith idfile_<key>_<n>, its safe name, bytes, size words, its words "File report.pdf, 313 KB" or "Datei report.pdf, 313 KB", and the tapIntent::OpenFile, whichScene::actionresolves. A bubble with no text is said as its first file. The list says the first file's name, its kind isfile.loquax::file_save::save(std) writes the file under the home.
The terminal draws ▤ report.pdf · 313 KB ([f] report.pdf - 313 KB in
ASCII) above the text or alone; Enter saves the first file and hands it to
the system's handler (Output::File). The window draws the same line,
pressable. loquax send --file FILE sends one from a script.
4. Android
- The compose bar's plus sheet (1270): Gallery, File, My position. File opens the system
picker with
ACTION_GET_CONTENTand*/*; Java reads the display name and the bytes off the UI thread and sendsRequest::File { peer, name, data, size }. A refusal shows on the chat's status line. MessageRow::filescarries each file's safe name, bytes, size words and words. The rows sit in the bubble above its words (1268), as a photo does; a tap asksQuery::SaveFile, gets the path, and startsACTION_VIEWwith the type from the extension; where nothing opens that kind the share sheet is offered, and where nothing takes it either the chat says "No app on this device opens this file." A long press shares it.FilesProvider(authority<package>.files, not exported, grants URI permissions) serves only files two levels underfiles/files/, read only, resolved through canonical paths.
5. Delivery and progress
A file goes as a photo goes: over a link as a resource from the desktop,
through the mailbox's /send as a request resource from the phone
(1220's fallback in leviculum-std). The archive stores it packed and
counts it against archive_cap_mb like any other message.
Progress in the bubble is not built yet, for photos or files: the request resource's progress does not reach the scene. It is the next slice for both.
6. Proof
loquax-android/tests/facade.rs::a_file_travels_both_ways_with_python_lxmf: Python sends two files as Sideband does, one named../../evil.sh; the phone shows both rows, the second as_.._evil.sh; the list saysProtokoll.pdf,file;Query::SaveFilewrites both under the app'sfiles/with their bytes, a third index is an error. The phone sendsGrüße.txt, 300 000 bytes, and Python's router gets field 5 with one entry, the name a str, the bytes unchanged. A file of 990 001 bytes, and one Java stopped reading at 1 MB of 48.3 MB, are refused with both sizes and nothing reaches Python. Positive control:safe_namereturning the name as it came turns the test red.loquax/tests/python_interop.rs::a_file_reaches_a_python_lxmf_receiver_as_the_attachments_field:loquax send --filewith a 300 KB file namedProtokoll Grüße.pdfreaches Python as field 5, name a str, bytes unchanged; a file past 990 KB exits 2 with the refusal. Positive control: a fixed namexturns it red.- Unit tests: the wire bytes, lenient reading, malformed fields, the safe and the sent name, the cap's words in both languages, the scene node and its tap, the terminal's line and Enter, the save under the home.
- The device walk's
filestep (device walk).
7. Open
- Progress in the bubble (section 5).
- The propagation node's 256 KB per message (section 2), shared with photos; lnpnd's fallback of 4 KB without a config is lower still.
- One file per message from the plus sheet; several picked at once are a later slice. Received messages with several show all.
- No preview of a received picture sent as a file: it is a file row.
- A saved file stays under the app's files until the app is removed; deleting the message does not remove it yet.