Skip to content

Signal: send photos, videos and files (the composer has no attach button) - #842

Closed
itz4blitz wants to merge 3 commits into
mainfrom
issue/742-signal-send-files
Closed

itz4blitz wants to merge 3 commits into
mainfrom
issue/742-signal-send-files

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

A Signal chat can send photos, videos and files. The composer can attach them because Signal now reports a file size and a count. A still picture is written again so camera data stays here, and a copy that comes back from the phone does not replace the file already shown.

Type

  • feature
  • fix
  • perf
  • refactor
  • chore
  • docs

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/signal-send-file

Lab run:

Compatibility

No protocol change. An older client still sends text. The file limits use the fields the composer already reads.

Risk and rollback

A bad send fails that one message, or a phone copy could replace the file already shown. Revert this change.

Release note

Photos, videos and files can be sent in a Signal chat.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Tiny Code Review

⚠️ Code review unavailable · run

the AI provider rate-limited the request

This is advice, not a gate. Re-run with the agent:review label or a /review comment.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟡 1 finding (0 blocking).

The PR wires Signal file sends onto the existing plumbing: Command::SendWith, the shared upload helper, Context::landed, and the capabilities the composer already reads; no protocol field changes. The picture re-encode in chatd mirrors the Tiny sealing path (same decode limits, same JPEG/PNG strategy), so no process boundary is crossed that the repo does not already cross. The echo suppression in apply is sound (timestamp list plus a stored-attachments backstop covers restarts). The one real defect is memory: the send holds every payload and then deep-clones the whole set, several GB at this PR's own caps.

Residual risk

  • A picture that fails to decode, or is past the 100-megapixel or 16384-pixel limits, goes out as the original file with its EXIF, XMP or GPS intact — the same fallback the Tiny sealing path takes, so the module's no-metadata promise holds only for pictures that decode.
  • Photos and files the phone itself sends still arrive as text rows with the Photo/Video placeholder (the pre-existing unsupported handling in real.rs); this diff covers sends from this computer only.
  • A cancel cannot interrupt presage once an attachment upload has begun: check runs between files, so a 100 MB upload runs to completion after Cancel.
  • wire::File derives Debug while holding full payload bytes; nothing formats it today, but any future {:?} on a Body would copy a user's file into a log.

Comment thread crates/chatd/src/adapters/signal.rs Outdated
let quote = quote_of(account, conversation, reply_to).map_err(|fault| fault.words())?;
let sent = account
.wire
.send(&to, Body::Files { text: text.to_owned(), quote: quote.clone(), files: prepared.clone() })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Major: The send deep-clones every file's payload, so chatd holds all of one message's bytes twice at once while the wire uploads them — about 6 GB at this PR's own caps (32 files x 100 MB), against the upload helper's stated contract that the whole file is never in memory. Only show_file after the send needs the bytes; build the row's attachments without the second copy (for example land each file's bytes inside the read loop under a client-id based media id, or cap the total bytes of one message).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The send moves the prepared files into the wire instead of cloning them. Each payload is written to disk under the client id first, and a failed send deletes those files. Signal's upload still holds that one buffer, because upload_attachment takes the bytes.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟢 No findings.

The delta (old head 658053d to new head 09e0984) touches only crates/chatd/src/adapters/signal.rs: send_files now writes each prepared file to the media cache before the wire send, moves prepared into Body::Files instead of cloning it, keys the attachment ids on the shell's client id (known before Signal names the message), and a failed send deletes the copies it just wrote (forget_landed). That resolves the prior major: no second copy of a message's payload exists; the bytes are held once and then consumed per file by presage's upload_attachment. I found no blocker or major in the new full diff: the phone-copy echo guard is bounded and has a store-side fallback, image decoding is capped before allocation, media ids are hashed before they reach a path, nothing logs a File's bytes, and the new test and e2e scenario cover the send and the phone-copy rule.

Residual risk

  • A send still holds one full copy of every file in memory at once (up to ~3.2 GB at the PR's own 32x100 MB caps) until presage consumes them; streaming would need a presage change, so the single copy is the smallest fix.
  • A failed send deletes the files it just landed but leaves their registered media rows, so orphaned rows naming a missing file sit in the store until the cache's LRU sweep reaches them.
  • If the media-cache write fails before the send (a full disk), the message still goes and the local row shows the attachment with no local copy behind it; only the sender's own view is affected.

@itz4blitz

Copy link
Copy Markdown
Collaborator Author

Superseded by and merged in #903 (d387971 — Release 2026-11-20 combined PR).

@itz4blitz itz4blitz closed this Nov 21, 2026
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.

2 participants