Improve iOS attachment previews and file delivery

Closed
AZ
2mo ago
+5883-875

Summary

  • Unify Photos and Files selection across Terminal, Agent Chat, and both New Task layouts.
  • Show ordered square image and file cards with preview, removal, preparation progress, and localized errors.
  • Stream exact staged bytes to the Mac with stable retry identities, validated host paths, and shell-safe terminal insertion.
  • Enforce 10-file, 32 MB per-file, and 64 MB per-draft limits without loading full files into composer state.

Verification

Closes https://github.com/manaflow-ai/cmux/issues/6643

Summary by CodeRabbit

  • New Features

    • Added photo and file attachments in iOS composers.
    • Added staged uploads with previews, thumbnails, progress indicators, removal controls, and accessibility support.
    • Added localized English and Japanese attachment workflows and error messages.
  • Bug Fixes

    • Improved size, count, readability, and upload validation.
    • Improved cleanup after cancellation, removal, failures, delivery, and sign-out.
    • Preserved attachment identity across retries and prevented stale preparation results.
    • Added support for empty files and safer transfer error messages.

[!NOTE]
Medium Risk
Touches composer send routing, large-file I/O, and new RPC delivery paths across chat and terminal; mistakes could leak temp files or drop attachments mid-retry, but auth is not redesigned and errors are sanitized for display.

Overview
iOS composers (terminal, agent chat, new task) now stage Photos and Files as app-owned on-disk payloads with shared card UI (preview, remove, preparing state, localized limits/errors), instead of holding full image bytes in composer state.

Delivery moves from inline base64 to mobile.task.attachment.upload chunking with stable upload_id / operation_id (retries reuse identities; completed uploads can short-circuit re-upload), then host references via mobile.chat.send, mobile.terminal.paste_attachment, or the existing task-create path. CmuxMobileAttachmentTransfer centralizes upload + privacy-safe transfer errors.

Chat store assigns a shared operation per prompt, releases staged files when pending rows reconcile, discard, reset, or change event source. Terminal shell adds typed admission results, raises per-terminal total staging to 64 MB, and deletes staged files on sign-out, topology prune, and clear/remove.

Reviewed by Cursor Bugbot for commit c8a43204fe232587da1f667bc0aae6489be27abf. Bugbot is set up for automated code reviews on this repo. Configure here.