Skip to content

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

    • Nested attachments now render as reply-style attachments within messages.
  • Bug Fixes

    • Quote detection improved to ignore collapsed items and attachments that contain nested attachments.
  • Tests

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Walkthrough

Renders nested attachments using the Reply component when an attachment has its own attachments; tightens quote detection to early-exclude collapsed attachments and attachments with 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
removeQuote and isQuoteAttachment now consider file.collapsed and file.attachments (early-return guards). Attachments.tsx adds a branch to render Reply when an attachment contains nested attachments, preserving existing Image/Audio/Video/AttachedActions/CollapsibleQuote paths.
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 has no detailed description available to validate whether all coding requirements are met. Access the full description of SUP-986 to verify all nested attachment visibility requirements are addressed by the code changes.
✅ 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 clearly and concisely summarizes the main bugfix: forwarding a message twice does not properly render attachments, which matches the core change in the PR.
Out of Scope Changes check ✅ Passed All changes directly address the nested attachment rendering issue: extending removeQuote logic, adding Reply component rendering for nested attachments, and adding test stories for nested cases.
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 docstrings
🧪 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.

@Rohit3523
Copy link
Contributor

LGTM

@OtavioStasiak OtavioStasiak requested a deployment to experimental_android_build February 5, 2026 20:15 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak requested a deployment to experimental_ios_build February 5, 2026 20:15 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak requested a deployment to official_android_build February 5, 2026 20:15 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak merged commit d2aa920 into develop Feb 5, 2026
3 of 9 checks passed
@OtavioStasiak OtavioStasiak deleted the fix.forward-message-twice-not-render-image branch February 5, 2026 20:16
OtavioStasiak added a commit that referenced this pull request Feb 5, 2026
* fix: collapsible attachment with text duplicating the content

* fix: nested attachment does not render

* chore: storybook nested reply

* fix: update snapshot test

* chore: format code and fix lint issues [skip ci]

* code improvements

* fix: forward message between channels not rendering image

* update snapshot test

* fix: collapsible attachment with text duplicating the content

* fix: snapshot test

---------

Co-authored-by: OtavioStasiak <OtavioStasiak@users.noreply.github.com>
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