Skip to content

Conversation

diegolmello
Copy link
Member

@diegolmello diegolmello commented Sep 23, 2025

Proposed changes

Regression introduced on #6121

Issue(s)

https://rocketchat.atlassian.net/browse/NATIVE-1031

How to test or reproduce

Screenshots

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 now treated as regular items, consistently appearing in the attachments list and available to expand, improving visibility and grouping of media and action-enabled items in message threads.
  • Documentation

    • Added example views demonstrating collapsed attachments in normal and large-font contexts to showcase rendering and accessibility behavior.

Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Updated attachment filtering to treat attachments with collapsed set as non-quote items (so they are rendered), and added Storybook data plus two story variants demonstrating collapsed attachment rendering.

Changes

Cohort / File(s) Summary of Changes
Attachment filtering logic
app/containers/message/Components/Attachments/Attachments.tsx
Extended the removeQuote predicate to treat file.collapsed as a non-quote condition, increasing the set of attachments passed to the renderer (collapsed attachments now render as CollapsibleQuote).
Story additions / test data
app/containers/message/Message.stories.tsx
Added collapsedAttachments test data and two exported stories (CollapsedAttachments, CollapsedAttachmentsLargeFont) demonstrating rendering of a collapsed attachment alongside a non-collapsed counterpart.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Story as Storybook
  participant Message
  participant Attachments
  participant Filter as removeQuote()
  participant Renderer

  Story->>Message: Render message with attachments (includes `collapsed` flag)
  Message->>Attachments: Pass attachments array
  Attachments->>Filter: Evaluate each attachment
  Note right of Filter #E6F4EA: Non-quote if image_url OR audio_url OR video_url OR actions.length > 0 OR collapsed == true
  Filter-->>Attachments: Return nonQuoteAttachments
  Attachments->>Renderer: Render non-quote attachments (including collapsed)
  Renderer-->>Message: Display attachments in UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • OtavioStasiak

Poem

I twitch my nose at folded bits,
Collapsed no more, they spring and flit.
Filters changed, the views expand,
More tiny panels take their stand.
Thump-thump — a rabbit's joyous fix. 🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "regression: Collapsible quote not rendering after #6121" is concise, specific, and directly describes the bug addressed by the changeset, making it clear to reviewers and future readers what the PR fixes.
Linked Issues Check ✅ Passed The code change adds handling for file.collapsed in the removeQuote predicate and includes storybook examples for collapsed attachments, which directly implements the fix described in NATIVE-1031 (collapsible quote not rendering).
Out of Scope Changes Check ✅ Passed All modified files (Attachments.tsx and Message.stories.tsx) relate to collapsed-attachment handling and story examples, and there are no unrelated code changes evident in the provided summary.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 60a2335 and 075c465.

⛔ 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/Components/Attachments/Attachments.tsx (1 hunks)
  • app/containers/message/Message.stories.tsx (1 hunks)

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.

@diegolmello diegolmello marked this pull request as ready for review September 23, 2025 13:50
@diegolmello diegolmello had a problem deploying to experimental_android_build September 23, 2025 13:52 — with GitHub Actions Error
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: 1

🧹 Nitpick comments (1)
app/containers/message/Components/Attachments/Attachments.tsx (1)

76-78: Add a key to AttachedActions to avoid list reconciliation issues.

Currently missing a key, which can cause warnings and unstable reconciliation.

-				return <AttachedActions attachment={file} getCustomEmoji={getCustomEmoji} />;
+				return <AttachedActions key={`actions-${index}`} attachment={file} getCustomEmoji={getCustomEmoji} />;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8a19a9f and 4f23b73.

📒 Files selected for processing (1)
  • app/containers/message/Components/Attachments/Attachments.tsx (1 hunks)
⏰ 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). (1)
  • GitHub Check: ESLint and Test / run-eslint-and-test


const removeQuote = (file?: IAttachment) =>
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0;
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || 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.

⚠️ Potential issue

Fix filter: truthy check skips non-collapsed quotes. Use explicit boolean check.

file?.collapsed only includes true, excluding quotes with collapsed === false. Since rendering later checks typeof file.collapsed === 'boolean', align the filter to include both states.

-	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || file?.collapsed;
+	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';

Optional (naming clarity):

  • Rename removeQuote to isRenderableAttachment.
  • Rename nonQuoteAttachments to renderableAttachments.
-const removeQuote = (file?: IAttachment) =>
-	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';
+const isRenderableAttachment = (file?: IAttachment) =>
+	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';

-const nonQuoteAttachments = attachments?.filter(removeQuote);
+const renderableAttachments = attachments?.filter(isRenderableAttachment);

And update subsequent uses accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || file?.collapsed;
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';
🤖 Prompt for AI Agents
In app/containers/message/Components/Attachments/Attachments.tsx around line 16,
the filter uses file?.collapsed as a truthy check which excludes attachments
where collapsed === false (quotes that should still be considered); change the
filter to explicitly include boolean collapsed values (e.g. typeof
file.collapsed === 'boolean' or file.collapsed !== undefined) alongside the
existing image/audio/video/actions checks so both true and false collapsed are
kept, and optionally rename removeQuote to isRenderableAttachment and
nonQuoteAttachments to renderableAttachments and update all subsequent
references to match.

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: 0

🧹 Nitpick comments (1)
app/containers/message/Message.stories.tsx (1)

1989-2017: Nit: rename constant to singular for clarity.

The value is a single attachment object. Optional, but improves readability.

Apply:

-const collapsedAttachments = {
+const collapsedAttachment = {
   collapsed: true,
   title: 'Title collapsed',
   fields: [
     {
       title: 'Field 1',
       value: 'Value 1'
     },
     {
       title: 'Field 2',
       value: 'Value 2'
     }
   ]
 };
 export const CollapsedAttachments = () => (
   <>
-    <Message msg='Message' attachments={[collapsedAttachments]} />
+    <Message msg='Message' attachments={[collapsedAttachment]} />
     {/* technically not CollapsibleQuote, but it's similar enough to write a story for */}
-    <Message msg='Message' attachments={[{ ...collapsedAttachments, collapsed: false }]} />
+    <Message msg='Message' attachments={[{ ...collapsedAttachment, collapsed: false }]} />
   </>
 );
 
 export const CollapsedAttachmentsLargeFont = () => (
   <>
-    <MessageLargeFont msg='Message' attachments={[collapsedAttachments]} />
+    <MessageLargeFont msg='Message' attachments={[collapsedAttachment]} />
     {/* technically not CollapsibleQuote, but it's similar enough to write a story for */}
-    <MessageLargeFont msg='Message' attachments={[{ ...collapsedAttachments, collapsed: false }]} />
+    <MessageLargeFont msg='Message' attachments={[{ ...collapsedAttachment, collapsed: false }]} />
   </>
 );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f23b73 and 60a2335.

⛔ 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 (1 hunks)
⏰ 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). (1)
  • GitHub Check: ESLint and Test / run-eslint-and-test
🔇 Additional comments (3)
app/containers/message/Message.stories.tsx (3)

2003-2009: Story coverage LGTM.

Good side-by-side of collapsed vs non-collapsed.


2011-2017: Large-font story LGTM.

Mirrors the normal variant as expected.


1989-2002: Resolved — IAttachment already declares collapsed?: boolean.

app/definitions/IAttachment.ts contains collapsed?: boolean.

Copy link
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!

@diegolmello diegolmello force-pushed the regression.collapsible-quote branch from 60a2335 to 075c465 Compare September 24, 2025 16:14
@diegolmello diegolmello merged commit 14b131c into develop Sep 24, 2025
4 of 8 checks passed
@diegolmello diegolmello deleted the regression.collapsible-quote branch September 24, 2025 16:15
@diegolmello diegolmello requested a deployment to official_android_build September 24, 2025 16:18 — with GitHub Actions Waiting
@diegolmello diegolmello requested a deployment to experimental_ios_build September 24, 2025 16:18 — with GitHub Actions Waiting
@diegolmello diegolmello requested a deployment to experimental_android_build September 24, 2025 16:18 — with GitHub Actions Waiting
@coderabbitai coderabbitai bot mentioned this pull request Oct 3, 2025
10 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 15, 2025
10 tasks
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