Skip to content

fix: forwarding a message twice does not render the attachment#6960

Open
OtavioStasiak wants to merge 9 commits intodevelopfrom
fix.forward-message-twice-not-render-image
Open

fix: forwarding a message twice does not render the attachment#6960
OtavioStasiak wants to merge 9 commits intodevelopfrom
fix.forward-message-twice-not-render-image

Conversation

@OtavioStasiak
Copy link
Contributor

@OtavioStasiak OtavioStasiak commented Feb 2, 2026

Proposed changes

When forwarding messages with file attachments files from forwarded messages remain invisible to users. Files located in nested attachment structures are not processed or displayed by the Reply component.

Issue(s)

https://rocketchat.atlassian.net/browse/SUP-986

How to test or reproduce

  • Open the app;
  • Go to room with a attachment message;
  • Forward it twice;

Screenshots

Before After
Simulator Screenshot - iPhone 16 - 2026-01-29 at 21 10 26 Simulator Screenshot - iPhone 16 - 2026-02-02 at 16 51 06

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

Summary by CodeRabbit

  • New Features

    • Render nested attachments as reply-style attachments within messages.
  • Bug Fixes

    • Improved quote detection to exclude collapsed items and attachments that contain nested attachments.
  • Tests

    • Added Storybook stories demonstrating nested reply/file attachments, collapsible attachment with text, and a large-font variant.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • app/containers/message/__snapshots__/Message.test.tsx.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

Renders nested attachments using the Reply component when an attachment contains its own attachments; tightens quote detection to early-exclude collapsed attachments and attachments with nested children; adds Storybook stories covering nested replies and collapsible-attachment cases.

Changes

Cohort / File(s) Summary
Attachment rendering & quote logic
app/containers/message/Components/Attachments/Attachments.tsx, app/containers/message/Components/Attachments/Quote.tsx
Extends removeQuote predicate to consider file.collapsed and file.attachments; adds branch to render a Reply component when an attachment contains nested attachments; adds early-return guards in isQuoteAttachment for collapsed items and attachments with children.
Storybook test cases
app/containers/message/Message.stories.tsx
Adds MessageWithNestedReplyAndFile, CollapsibleAttachmentWithText, CollapsibleAttachmentWithTextLargeFont stories and a collapsibleAttachmentWithText fixture to exercise nested-reply and collapsible-attachment rendering.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client
  participant MessageComp as Message
  participant AttachmentsComp as Attachments
  participant ReplyComp as Reply
  participant MediaRenderers as Image/Audio/Video/AttachedActions/CollapsibleQuote
  Client->>MessageComp: render message with attachments
  MessageComp->>AttachmentsComp: pass attachments array
  AttachmentsComp->>AttachmentsComp: evaluate removeQuote / isQuoteAttachment (checks collapsed, attachments)
  alt attachment contains attachments
    AttachmentsComp->>ReplyComp: render nested Reply for attachment
    ReplyComp->>AttachmentsComp: (may render nested attachments)
  else attachment is image/audio/video/action/collapsible
    AttachmentsComp->>MediaRenderers: render appropriate renderer
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • diegolmello

Poem

🐰
I hop through code with nimble paws,
Nested replies obey new laws.
Collapsed I skip, no quote to keep,
Attachments wake from nested sleep.
Stories bloom — a joyful leap! 📎✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The linked issue SUP-986 lacks detail about specific coding requirements, making it difficult to assess whether all requirements are fully met. Review the full issue details at SUP-986 to validate that all coding requirements for nested attachment visibility have been addressed in the implementation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing rendering of attachments when forwarding messages multiple times.
Out of Scope Changes check ✅ Passed All changes directly address the nested attachment visibility issue: modifications to attachment rendering logic, quote predicate checks, and comprehensive test stories.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix.forward-message-twice-not-render-image

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.

@OtavioStasiak OtavioStasiak changed the title Fix.forward message twice not render image fix: forward message twice does not render attachment Feb 2, 2026
@OtavioStasiak OtavioStasiak changed the title fix: forward message twice does not render attachment fix: forwarding a message twice does not render the attachment Feb 2, 2026
@OtavioStasiak OtavioStasiak marked this pull request as ready for review February 2, 2026 19:52
Copy link
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: 2

🤖 Fix all issues with AI agents
In `@app/containers/message/Components/Attachments/Attachments.tsx`:
- Around line 76-85: The nested-attachment branch fails to pass the
already-computed msg into the Reply component, so update the JSX that renders
<Reply key={index} attachment={file} ... /> to include the msg prop (e.g.,
msg={msg}) so Reply receives the computed message for translated text/display;
locate the rendering in Attachments.tsx where Reply is returned for
file.attachments?.length and add the msg prop alongside attachment, timeFormat,
getCustomEmoji and showAttachment.

In `@app/containers/message/Components/Attachments/Quote.tsx`:
- Around line 11-18: isQuoteAttachment currently doesn't exclude attachments
that contain nested attachments, so nested items can be rendered both as a Quote
and again in Attachments; add an early guard in isQuoteAttachment to return
false when the incoming file has a non-empty attachments array (e.g.
file.attachments && file.attachments.length > 0) so its behavior mirrors
removeQuote and prevents duplicate rendering in Quote and Attachments.

@OtavioStasiak OtavioStasiak deployed to approve_e2e_testing February 4, 2026 19:42 — with GitHub Actions Active
@OtavioStasiak OtavioStasiak requested a deployment to official_android_build February 4, 2026 19:45 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak requested a deployment to experimental_android_build February 4, 2026 19:45 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak requested a deployment to experimental_ios_build February 4, 2026 19:45 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 self-requested a review February 4, 2026 20:00
@Rohit3523
Copy link
Contributor

LGTM

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