mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-10 19:42:21 +00:00
Composer attachment tray wired end to end: "+" bottom sheet (photo library / camera / files), upload-on-pick against POST upload (JSON+base64), per-chip uploading -> ready/failed states with retry and best-effort delete-on-remove, AttachmentMetadata riding SendMessageRequest and the optimistic row so user bubbles thumbnail instantly, and a UserTextBlockView upgrade decoding wire previewUrl data URLs (web-sent messages thumbnail too). Mobile-data compression policy (differs from web, which uploads originals): recompressible images over 4 MB downscale to 2048 px JPEG q85 (filename swaps to .jpg); GIF/SVG/non-images keep originals; hard 50 MB reject with a notice, plus a capped read guarding unknown-size picks. previewUrl embeds a <=512 px JPEG thumb instead of the web's full-size data URL to keep send bodies small. Simplifications noted in KDoc: attachments do not persist in drafts v1 (holder onCleared discards un-sent uploads after best-effort deletes); inactive sessions fail the upload chip until a text send auto-resumes. Scheduled sends guard the wire constraint (scheduledAt excludes attachments) with a loud check. Seam: ChatSessionApi now extends AttachmentUploadApi (HapiApi methods gain override); camera captures use a FileProvider cache scratch, rememberSaveable across rotation. Tests: pure policy decisions (plan/sample-size/filenames/data URLs), controller state machine incl. mid-upload removal orphan cleanup, VM send/retry/refusal flows with metadata assertions, MockWebServer wire shapes for upload + delete. Full gate green (protocol/data/app tests + assembleDebug).