Skip to content

feat: Support message with multiple attachments#6068

Merged
OtavioStasiak merged 6 commits intodevelopfrom
feat.multiple-files-render
Feb 23, 2026
Merged

feat: Support message with multiple attachments#6068
OtavioStasiak merged 6 commits intodevelopfrom
feat.multiple-files-render

Conversation

@diegolmello
Copy link
Copy Markdown
Member

@diegolmello diegolmello commented Dec 17, 2024

Proposed changes

Issue(s)

closes #5942

How to test or reproduce

Screenshots

Screenshot 2025-01-10 at 15 43 59
Screenshot 2025-01-10 at 15 43 50
Screenshot 2025-01-10 at 15 43 38
Screenshot 2025-01-10 at 15 43 01

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

CORE-848

Summary by CodeRabbit

  • New Features

    • Added support for multi-file attachments in messages (images, video, audio, files) with large-font and non-header rendering variants
    • Improved media download/persistence to better handle attachments
  • Tests

    • Expanded message stories to include multi-file scenarios, large-font variants, and non-header examples
    • Updated several attachment descriptions to reflect new display text and emoji usage

@Rohit3523
Copy link
Copy Markdown
Contributor

This PR will also close #5942

@diegolmello diegolmello force-pushed the feat.multiple-files-render branch from 009223d to 8717d5a Compare January 10, 2025 17:57
@diegolmello diegolmello marked this pull request as ready for review January 10, 2025 19:03
Copy link
Copy Markdown
Contributor

@OtavioStasiak OtavioStasiak left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@Rohit3523
Copy link
Copy Markdown
Contributor

I have noticed an issue: when we send the same images in different messages, only the image in the first message will open in the preview, not the ones in the rest. For example, if we send images one and two across three messages, we can tap and open the preview for the image in the first message, but not for the images in the second and third messages.

@Rohit3523
Copy link
Copy Markdown
Contributor

Fixed in #6093

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 23, 2026

Walkthrough

Adds multi-attachment message story variants (images, video, audio, files, large-font, and isHeader=false cases) and threads downloadUrl through the media download flow so attachment title_link is set when the downloaded URL matches an attachment’s image_url.

Changes

Cohort / File(s) Summary
Message Stories
app/containers/message/Message.stories.tsx
Adds many multi-attachment story variants (two-attachment blocks) for images, videos, audio, files and URL attachments; adds isHeader={false} and large-font multi-attachment examples; updates some attachment descriptions.
Media Download Handling
app/lib/methods/handleMediaDownload.ts
Introduces downloadUrl propagation through mapAttachments/persistMessage; conditionally sets title_link when an attachment’s image_url matches the download URL; updates download flow call sites to pass downloadUrl.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Story as Message Story
participant Downloader as MediaDownloader
participant Persist as PersistService
participant DB as Database
Story->>Downloader: request download (file URL)
Downloader-->>Story: download progress / complete (downloadUrl, local uri)
Downloader->>Persist: persistMessage(message, attachments, downloadUrl, uri)
Persist->>Persist: mapAttachments(attachments, downloadUrl)
Persist->>DB: save message with updated attachments (title_link set when image_url == downloadUrl)
DB-->>Persist: ack
Persist-->>Story: persisted message (updated attachments)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hop, a click, two files in a row,
I stitched their links where downloads go,
Images, videos, all side by side,
Now stories show the multi-attach pride,
Nyan rocket cheers — hop on for the ride! 🚀✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR adds storybook stories for multi-attachment scenarios and implements downloadUrl context for attachment processing, partially supporting the linked issues' requirements for displaying multiple attachments. Verify that all acceptance criteria from CORE-848 are met: multiple attachment display across file types, scrollable layout, per-attachment interaction, E2EE support, and performance handling.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically summarizes the main feature being implemented: support for messages with multiple attachments.
Out of Scope Changes check ✅ Passed Both changed files directly support the PR objective: Message.stories.tsx adds multi-attachment scenarios, and handleMediaDownload.ts implements download URL context for proper attachment handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/containers/message/Message.stories.tsx (1)

746-758: ⚠️ Potential issue | 🟡 Minor

<Message> used instead of <MessageLargeFont> inside WithImageLargeFont

The new multi-file block at line 746 renders with the default (1×) font scale instead of the FONT_SCALE_LIMIT scale that the rest of this export uses. This undermines the visual accuracy of large-font snapshots.

🔧 Proposed fix
-		<Message
+		<MessageLargeFont
 			msg='multi file'
 			attachments={[
 				{
 					title: 'This is a title',
 					image_url: '/dummypath'
 				},
 				{
 					title: 'This is a title',
 					image_url: '/dummypath'
 				}
 			]}
-		/>
+		/>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/containers/message/Message.stories.tsx` around lines 746 - 758, The
WithImageLargeFont story is rendering the multi-file block with the default
Message component instead of the large-font variant; update the component used
for that multi-attachment render to MessageLargeFont so it respects the
FONT_SCALE_LIMIT applied elsewhere in the export (locate the Message usage in
the WithImageLargeFont story and swap it to MessageLargeFont).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/containers/message/Message.stories.tsx`:
- Around line 1119-1129: The snapshot for FileAttachmentsWithFilenamesLargeFont
is using the regular Message component instead of the large-font variant; update
the JSX in the story where the multi-file block is rendered (the <Message ... />
instance inside FileAttachmentsWithFilenamesLargeFont) to use <MessageLargeFont
... /> so the multi-file attachments snapshot reflects large-font scaling
consistently with other fixtures.

In `@app/lib/methods/handleMediaDownload.ts`:
- Line 216: The current use of substring matching with
downloadUrl.includes(att.image_url) when setting title_link can produce false
positives; update the check in the title_link assignment to perform an exact
match between the attachment URL and the downloadUrl (e.g., normalize both by
removing query strings or comparing full normalized URLs) before choosing uri
over att.title_link—replace the includes() test with a precise equality check on
the normalized att.image_url and downloadUrl values in the same scope where
title_link is computed.
- Around line 214-218: The attachments mapping in handleMediaDownload.ts only
checks att.image_url when deciding to set att.title_link, so video/audio
attachments never get their title_link updated; update the condition inside the
attachments?.map callback to check for att.image_url || att.video_url ||
att.audio_url and test downloadUrl.includes(...) against whichever URL exists
(preferring image_url then video_url then audio_url), then set title_link to uri
when that match is true and preserve the existing e2e logic (encryption ? 'done'
: undefined) so video/audio attachments receive the local file:// URI in
title_link just like images.

---

Outside diff comments:
In `@app/containers/message/Message.stories.tsx`:
- Around line 746-758: The WithImageLargeFont story is rendering the multi-file
block with the default Message component instead of the large-font variant;
update the component used for that multi-attachment render to MessageLargeFont
so it respects the FONT_SCALE_LIMIT applied elsewhere in the export (locate the
Message usage in the WithImageLargeFont story and swap it to MessageLargeFont).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4415a07 and b850692.

⛔ Files ignored due to path filters (1)
  • app/containers/message/__snapshots__/Message.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • app/containers/message/Message.stories.tsx
  • app/lib/methods/handleMediaDownload.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: format
🧰 Additional context used
🧬 Code graph analysis (1)
app/lib/methods/handleMediaDownload.ts (3)
app/definitions/IAttachment.ts (1)
  • IAttachment (9-48)
app/definitions/IMessage.ts (1)
  • TMessageModel (180-183)
app/lib/database/services/Message.ts (1)
  • getMessageById (7-19)

@OtavioStasiak
Copy link
Copy Markdown
Contributor

Approved... tested with the latest changes

Simulator Screenshot - iPhone 16 - 2026-02-23 at 16 23 30 Simulator Screenshot - iPhone 16 - 2026-02-23 at 16 23 14

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/containers/message/Message.stories.tsx (1)

746-758: ⚠️ Potential issue | 🟡 Minor

<Message> used instead of <MessageLargeFont> inside WithImageLargeFont

The multi-file image block renders with the regular Message component, so large-font scaling will not be reflected in this story variant — inconsistent with every other multi-file block added in the LargeFont stories (WithVideoLargeFont, WithAudioLargeFont, FileAttachmentsWithFilenamesLargeFont).

🔧 Proposed fix
-		<Message
+		<MessageLargeFont
 			msg='multi file'
 			attachments={[
 				{
 					title: 'This is a title',
 					image_url: '/dummypath'
 				},
 				{
 					title: 'This is a title',
 					image_url: '/dummypath'
 				}
 			]}
 		/>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/containers/message/Message.stories.tsx` around lines 746 - 758, The story
variant WithImageLargeFont incorrectly renders the multi-file image block using
the regular Message component; change the component instance in that block from
Message to MessageLargeFont so the large-font scaling is applied consistently
(locate the JSX where Message is used inside WithImageLargeFont and replace it
with MessageLargeFont).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@app/containers/message/Message.stories.tsx`:
- Around line 746-758: The story variant WithImageLargeFont incorrectly renders
the multi-file image block using the regular Message component; change the
component instance in that block from Message to MessageLargeFont so the
large-font scaling is applied consistently (locate the JSX where Message is used
inside WithImageLargeFont and replace it with MessageLargeFont).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b850692 and 9f48afe.

⛔ Files ignored due to path filters (1)
  • app/containers/message/__snapshots__/Message.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • app/containers/message/Message.stories.tsx
📜 Review details
🔇 Additional comments (5)
app/containers/message/Message.stories.tsx (5)

676-676: LGTM — description text updated consistently with the rest of the file.


700-712: LGTM — new multi-file image block correctly uses <Message> for the normal story variant.


786-839: LGTMWithVideo multi-file block uses the correct <Message> component, and WithVideoLargeFont correctly uses <MessageLargeFont>.


858-949: LGTMWithAudio and WithAudioLargeFont multi-file blocks use the correct components.


1119-1129: LGTM — the multi-file file-attachment block now correctly uses <MessageLargeFont>, addressing the previous review comment.

@OtavioStasiak OtavioStasiak merged commit 57137f3 into develop Feb 23, 2026
5 of 10 checks passed
@OtavioStasiak OtavioStasiak deleted the feat.multiple-files-render branch February 23, 2026 20:33
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.

Multiple image attachments in one message do not work correctly

3 participants