Skip to content

fix: collapsible attachment with text duplicating the content#6956

Open
OtavioStasiak wants to merge 4 commits intodevelopfrom
fix.duplicated-message-collapsible-attachment
Open

fix: collapsible attachment with text duplicating the content#6956
OtavioStasiak wants to merge 4 commits intodevelopfrom
fix.duplicated-message-collapsible-attachment

Conversation

@OtavioStasiak
Copy link
Contributor

@OtavioStasiak OtavioStasiak commented Jan 29, 2026

Proposed changes

Fix collapsible attachment with text duplicating the content.

Issue(s)

How to test or reproduce

  • Post the message;
curl -X POST 'https://YOUR_SERVER/api/v1/chat.postMessage' \
  -H 'Content-Type: application/json' \
  -H 'X-Auth-Token: YOUR_AUTH_TOKEN' \
  -H 'X-User-Id: YOUR_USER_ID' \
  -d '{
    "roomId": "ROOM_ID",
    "text": "This is the main message body.",
    "attachments": [
      {
        "collapsed": true,
        "title": "Collapsed attachment block",
        "text": "This attachment text should NOT appear as plain text above the message or duplicate before the block.",
        "description": "Attachment description that might also leak as duplicate plain text.",
        "color": "#2c3e50",
        "fields": [
          { "title": "Field 1", "value": "Value 1", "short": true },
          { "title": "Field 2", "value": "Value 2", "short": true },
          { "title": "Long field", "value": "This field value could also contribute to duplicate text when expanded.", "short": false }
        ]
      }
    ]
  }'
  • open the app;
  • navigate to the room with the message;

Screenshots

Before After
Simulator Screenshot - iPhone 16 - 2026-01-29 at 20 09 23 Simulator Screenshot - iPhone 16 - 2026-01-29 at 20 09 09

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

  • Bug Fixes

    • Fixed an issue where collapsed attachments were incorrectly processed as quote attachments.
  • Tests

    • Added test coverage for collapsible attachments with text in different display modes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

These changes modify how collapsed attachments are handled in message quotes and add Storybook stories for testing collapsible attachments with text content. The Quote.tsx logic now prevents collapsed attachments from being classified as quotes through an early return guard.

Changes

Cohort / File(s) Summary
Quote Logic Guard
app/containers/message/Components/Attachments/Quote.tsx
Added early return in isQuoteAttachment that rejects collapsed attachments (when file.collapsed is true) before evaluating color, text, and image flags.
Storybook Test Cases
app/containers/message/Message.stories.tsx
Added collapsible attachment test data and two corresponding stories (CollapsibleAttachmentWithText and CollapsibleAttachmentWithTextLargeFont) to verify rendering in normal and large-font contexts.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested reviewers

  • diegolmello

Poem

🐰 A quote that collapses away,
Won't fool us in display,
With guards in place and tests so bright,
Our attachments now render right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a bug where collapsed attachments with text were duplicating content.
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.duplicated-message-collapsible-attachment

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.


if (file.collapsed) return false;

if (!file.color && !file.text && (file.image_url || file.audio_url || file.video_url || file.collapsed)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove file.collapsed from here because we have added a check in line 14

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