Skip to content

fix: collapsible attachment with text duplicating the content#6956

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

fix: collapsible attachment with text duplicating the content#6956
OtavioStasiak wants to merge 16 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

    • Collapsed attachments are no longer treated as quote attachments, preventing incorrect quoted content.
  • New Features

    • Nested attachments now surface as related/reply content rather than being ignored.
    • Added an avatar-suggestion endpoint and client support to fetch service-based avatar suggestions.
  • Documentation

    • Added stories demonstrating collapsible attachments (standard and large-font) in collapsed and expanded states.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

Exclude collapsed or nested attachments from being classified as quote attachments; add nested-reply rendering for attachments with attachments; introduce Storybook stories for collapsible attachments; add a server-version-aware avatars suggestion API call and endpoint declaration.

Changes

Cohort / File(s) Summary
Quote logic
app/containers/message/Components/Attachments/Quote.tsx
Add early-return: isQuoteAttachment returns false when file.collapsed is true; add guard against attachments that themselves contain attachments; adjust media indicator checks accordingly.
Attachments rendering
app/containers/message/Components/Attachments/Attachments.tsx
Import Reply; extend removal/quote-detection logic to consider file.collapsed and file.attachments.length; render Reply for attachments that include nested attachments before other branches.
Storybook stories & test data
app/containers/message/Message.stories.tsx
Add collapsibleAttachmentWithText data and three new story exports (MessageWithNestedReplyAndFile, CollapsibleAttachmentWithText, CollapsibleAttachmentWithTextLargeFont) demonstrating nested reply and collapsed/expanded attachment states.
API definitions
app/definitions/rest/v1/users.ts
Add users.getAvatarSuggestion GET endpoint to UsersEndpoints returning { suggestions: { [service: string]: IAvatarSuggestion }; success: boolean }; import IAvatarSuggestion.
Client REST logic
app/lib/services/restApi.ts
Convert getAvatarSuggestion to async; add server-version-aware branch: call users.getAvatarSuggestion for server >= 5.4.0 (return suggestions or {}), otherwise fall back to methodCallWrapper('getAvatarSuggestion'). Signature changed to async function returning the suggestion map.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Client UI
    participant Lib as restApi.getAvatarSuggestion()
    participant Server as Server API
    participant Fallback as MethodCallFallback

    UI->>Lib: request getAvatarSuggestion()
    Lib->>Server: check serverVersion >= 5.4.0?
    alt server >= 5.4.0
        Lib->>Server: GET users.getAvatarSuggestion
        Server-->>Lib: { suggestions, success }
        Lib-->>UI: return suggestions or {}
    else older server
        Lib->>Fallback: methodCallWrapper('getAvatarSuggestion')
        Fallback-->>Lib: suggestions (or error)
        Lib-->>UI: return suggestions or {}
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I tuck a quote beneath my paw,
A folded leaf the reader won't gnaw.
I hop through stories, nested and neat,
Guarding the crumbs where replies meet. 🥕

🚥 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 clearly and concisely describes the main issue being fixed: preventing collapsible attachments with text from duplicating content in the message display.
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.

OtavioStasiak and others added 6 commits February 5, 2026 20:11
* 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>
* chore: type of getAvatarSuggestion

* chore: add getAvatarSuggestion endpoint and backward compatibility

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

---------

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