Repository navigation
feat(messaging): message attachments — upload with progress, preview and secure download (#23) - #135
Conversation
|
@Gentle842 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Thanks. The upload pipeline is well thought out: real progress with abort, in-memory staging, SVG and executables rejected, and a fresh signed URL for every download that's never cached. It can't merge yet: Blocking
Should fix
Once CI is green and the branch is rebased, I'll review again. |
|
This PR has merge conflicts with |
|
@Gentle842 Thanks for the PR. It can't be merged yet. To unblock it: CI is failing. Here's what broke:
Please fix these errors and run the same steps locally before pushing ( Merge conflicts: this branch conflicts with Push to this same branch and CI will re-run. Once it's green and conflict-free, it'll be reviewed for merge. |
7bb3549 to
878b847
Compare
|
@Gentle842 This PR now has merge conflicts with git fetch upstream # upstream = https://github.com/DocForum/docforum-web.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-leaseThe usual culprits are shared files like Automated message. It won't repeat unless the PR conflicts again after your next push. |
878b847 to
b774840
Compare
b774840 to
386988a
Compare
afeezorobsco-cyber
left a comment
There was a problem hiding this comment.
Reviewed: no malicious code found, CI is green. Merging.
Overview
Adds message attachments to the consultation composer (Phase W2, issue #23): pick or capture from the camera on mobile, client-side image downscale before upload, real upload progress with cancel + retry, inline image previews and PDF chips, and secure per-click signed downloads.
Implements the PRD §4 core flow: patient ⇄ treating doctor async consultation messaging (Phase W2). Built against a documented assumed API shape, since the dependencies below are not merged yet.
Depends on / context:
DocForum/docforum-core#62(attachment storage + access-checked short-lived download URLs) — not landed, so all endpoints here are documented assumptions.MessageThread) purely so the composer/preview have a real home; the full thread UX (optimistic send, live updates, pagination states) stays in [Phase W2] Consultation message thread UI (shared by patients and doctors) #22.Related Issue
Closes #23
Changes
📎 Upload + secure download pipeline
src/services/api-client.ts—apiUpload()(XMLHttpRequest — the one deliberate exception to the fetch-only client, sincefetchcan't report upload progress; still the only place HTTP details live) with real progress reporting and abort.ApiErrorgains acancelledflag distinct from a network error.src/services/messaging-service.ts— thread fetch, message list/send, multipart attachment upload, and per-click signed download URL.src/types/models.ts—MessageThread,Message,MessageAttachment,MessagePage,SignedDownloadUrl,SendMessageInput(mirror the assumeddocforum-coremodels).🖼️ Composer, previews & validation
src/features/messaging/attachment-validation.ts— type/size caps with clear messages; SVG and executables rejected client-side.src/features/messaging/image-utils.ts— best-effort client-side downscale (never scales up, falls back to the original). EXIF is never read or displayed here; stripping stays server-side.src/features/messaging/hooks/useAttachmentUploader.ts— staged uploads with progress / cancel / retry / remove; in-memory only, aborts in-flight uploads on unmount.src/features/messaging/hooks/useMessageThread.ts— thread fetch + send-message hooks.src/features/messaging/components/MessageComposer.tsx— attach-file and take-photo inputs, progress bar, cancel/retry, send gated on upload state.src/features/messaging/components/AttachmentPreview.tsx— inline image preview + PDF chip; every click mints a fresh signed URL and opens it.src/features/messaging/components/MessageThread.tsx— minimal shared thread shell (text-only rendering; message bodies are PHI).🔀 Routing / docs
src/pages/MessageThreadPage.tsx, mounted at/patient/messages/:threadIdand/doctor/messages/:threadId.src/pages/PatientDashboardPage.tsx,src/pages/DoctorDashboardPage.tsx— register the shared route.ROADMAP.md,ARCHITECTURE_ESSENTIALS.md— item status + changelog, and the assumed API contract recorded under "Known assumptions".🧪 Tests
attachment-validation.test.ts,image-utils.test.ts,useAttachmentUploader.test.tsx,AttachmentPreview.test.tsx,MessageComposer.test.tsx— upload states (progress, cancel, retry, validation, cap) and the download flow (fresh URL per click, error handling).Verification Results
ROADMAP.md+ARCHITECTURE_ESSENTIALS.mdupdatedNotes
Signed URLs are never stored in React Query's cache: the inline preview holds its URL only in component state, and each click/download mints a new one. All network calls (including multipart upload) stay inside
src/services/api-client.ts, holding hard rule 1 and the repo's storage rule (drafts/staged uploads are in-memory only). No screenshots this session (no browser tool available) — same disclosed gap as prior UI PRs in this repo; typecheck/tests/build all pass. Happy to add desktop + mobile screenshots on request.