Skip to content

fix: render mobile image caption (alt text) on desktop clients#41094

Open
bhavik17-ctrl wants to merge 1 commit into
RocketChat:developfrom
bhavik17-ctrl:develop
Open

fix: render mobile image caption (alt text) on desktop clients#41094
bhavik17-ctrl wants to merge 1 commit into
RocketChat:developfrom
bhavik17-ctrl:develop

Conversation

@bhavik17-ctrl

@bhavik17-ctrl bhavik17-ctrl commented Jun 28, 2026

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved image attachment text rendering so descriptions and alt text display more consistently.
    • Prevented empty image description content from being shown when no description is available.

@bhavik17-ctrl bhavik17-ctrl requested a review from a team as a code owner June 28, 2026 13:12
@dionisio-bot

dionisio-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 95dc4b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


BHAVIK DATTATRAY SANGALE seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 136ae023-9525-4265-a38b-aeb7d65bf4c3

📥 Commits

Reviewing files that changed from the base of the PR and between 294ee5d and 95dc4b6.

📒 Files selected for processing (1)
  • apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx
🧠 Learnings (2)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx
🔇 Additional comments (1)
apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx (1)

32-33: 🎯 Functional Correctness

Keep altText out of the md prop unless it matches the token shape

MessageContentBody forwards md into Markup, so this fallback only works if altText is already parsed markdown tokens. If it’s still a plain image alt string, keep the caption on a plain-text path here or normalize it before passing it in.


Walkthrough

In ImageAttachment, the condition for rendering MessageContentBody is updated to include altText alongside descriptionMd. The fallback MarkdownText render path now has an explicit guard requiring description to be truthy, preventing a render when description is undefined.

Changes

ImageAttachment description/altText render fix

Layer / File(s) Summary
Description/altText render condition
apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx
MessageContentBody is now rendered when `descriptionMd

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#40839: Directly modifies the same ImageAttachment.tsx file to introduce altText/image_alt mapping and adjust the alt-text guard logic that this PR builds upon.

Suggested labels

type: bug

Suggested reviewers

  • nazabucciarelli
🚥 Pre-merge checks | ✅ 5
✅ 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 accurately summarizes the fix to render alt text/image captions on desktop clients.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx">

<violation number="1" location="apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx:32">
P1: The `altText` branch incorrectly suppresses `description`. When an attachment has both `image_alt` and `description` but no `descriptionMd`, the new `descriptionMd || altText` condition evaluates to true and renders `altText`, skipping the existing `description` entirely. `altText` and `description` are independent fields and can coexist, so this is a semantic regression.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

return (
<>
{descriptionMd ? <MessageContentBody md={descriptionMd} /> : <MarkdownText parseEmoji content={description} />}
{(descriptionMd || altText) ? (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: The altText branch incorrectly suppresses description. When an attachment has both image_alt and description but no descriptionMd, the new descriptionMd || altText condition evaluates to true and renders altText, skipping the existing description entirely. altText and description are independent fields and can coexist, so this is a semantic regression.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/components/message/content/attachments/file/ImageAttachment.tsx, line 32:

<comment>The `altText` branch incorrectly suppresses `description`. When an attachment has both `image_alt` and `description` but no `descriptionMd`, the new `descriptionMd || altText` condition evaluates to true and renders `altText`, skipping the existing `description` entirely. `altText` and `description` are independent fields and can coexist, so this is a semantic regression.</comment>

<file context>
@@ -29,7 +29,11 @@ const ImageAttachment = ({
 	return (
 		<>
-			{descriptionMd ? <MessageContentBody md={descriptionMd} /> : <MarkdownText parseEmoji content={description} />}
+	{(descriptionMd || altText) ? (
+				<MessageContentBody md={descriptionMd || altText} />
+			) : (
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants