Warn on staged text attachment the model may read truncated - #625
Conversation
|
This one is a real gap and the repository asks for it by name: Closing this revision because of two defects rather than the idea. The third line of text squashes the icon. The tile is a fixed The predicate is also the wrong one. If you want to take another pass: those two, plus a test over the composer's derivation of the flag rather than only the tile rendering it. Happy to merge that. |
The warning arrived as a third line of text in a tile whose height is fixed, so it did not fit: at this repository's 15px root the two in-flow children need 63.75px inside a 58px box, and the icon is the only one that can give. Measured in Chromium, it rendered 18.75x13 on exactly the tiles carrying the warning. Pinning the icon alone only moves the overflow onto the border, so the warning folds onto the size line instead and the tile keeps two lines. `truncate` is what guarantees that: `formatBytes` is unbounded, and a large enough file would otherwise wrap the line and put the third one back. Also drops the `attachment.type` test from the composer's derivation. The filter above it already excludes images using `stagedModality`, which prefers the mime the server sniffed; `attachment.type` is the browser's claim, fixed at pick time and never revised. Testing both could only subtract, and the file it subtracted is the one that matters: a file the browser called a PNG and the server read as text goes down the extraction path and is exactly what gets cut. Covered by a composer-level test, which the warning did not have.
Fixes #624.
Summary
Closes the trust gap recorded in shared/attachments.ts: the server accepts text uploads up to MAX_FILE_BYTES (1MB) but the model reads only the first MAX_EXTRACTED_CHARACTERS (120k). Until now the truncation caption went to the model only (attachment-parts.ts) with nothing on screen for the person, so a 1MB CSV showed as a 1.0MB tile and was answered as roughly its first eighth with no warning.
Changes
Verification