Skip to content

fix: keep the quote when replying in direct message to a thread message - #7899

Open
OtavioStasiak wants to merge 1 commit into
developfrom
fix.reply-from-thread-and-quote
Open

OtavioStasiak wants to merge 1 commit into
developfrom
fix.reply-from-thread-and-quote

Conversation

@OtavioStasiak

@OtavioStasiak OtavioStasiak commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

"Reply in direct message" on a thread reply opened the DM without the quote. The DM composer looked up the quoted id in the messages table only, and a thread reply that was loaded by opening its thread lives only in thread_messages.

  • Add getMessageOrThreadMessageById, which falls back to thread_messages when the message isn't in messages and there's no tmid.
  • Use it for the quote preview (useMessage) and the quote link added on send (prepareQuoteMessage).
  • getMessageById is unchanged, since room sync relies on it only reading messages.

Regression from the new message composer (#5205, 4.47.0), which switched Reply in DM from passing the message object to a messageId lookup. #7535 added the thread lookup only when a tmid is passed, so the DM path stayed broken.

Issue(s)

https://rocketchat.atlassian.net/browse/SUP-1144

How to test or reproduce

  • Open a channel with an older thread whose replies aren't in the room's loaded history.
  • Open the thread from the Threads list.
  • Long-press a reply in the thread and tap "Reply in direct message".
  • Check that the DM composer shows the quote preview.
  • Send a message and check that it renders with the quoted reply.
  • Repeat on a message outside a thread and check that the quote still works.

Screenshots

Before After
reply-in-dm-thread-quote-before reply-in-dm-thread-quote-after

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

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The message service adds a lookup that can fall back from messages to thread messages. MessageComposer uses this lookup when loading a message and preparing quoted messages. Tests cover lookup behavior, thread IDs, and quote handling.

Changes

Thread-aware message lookup

Layer / File(s) Summary
Message lookup and fallback
app/lib/database/services/Message.ts, app/lib/database/services/Message.test.ts
The service adds getMessageOrThreadMessageById. It checks the message lookup first and can fall back to a thread-message lookup. Tests cover message matches, fallback behavior, thread IDs, and missing results.
MessageComposer integration
app/containers/MessageComposer/helpers/prepareQuoteMessage.ts, app/containers/MessageComposer/hooks/useMessage.ts, app/containers/MessageComposer/helpers/prepareQuoteMessage.test.ts, app/containers/MessageComposer/MessageComposer.test.tsx, app/containers/MessageComposer/__tests__/MessageComposerContainer.test.tsx
Message loading and quote preparation use the new lookup. Tests update mocks and verify calls with and without thread IDs, while retaining quote behavior assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: type: bug

Suggested reviewers: diegolmello

Merge Risk: Minimal · up to f1bee

This change restores the quote when replying in a direct message to a thread message. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the quote is kept when replying in a direct message to a thread message. The changeset adds getMessageOrThreadMessageById, which falls back to thread_messages, and us…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title states the main change: the quote is kept when replying in a direct message to a thread message. The changeset adds getMessageOrThreadMessageById, which falls back to thread_messages, and uses it in useMessage and prepareQuoteMessage. The title matches this fix.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Errors were encountered while retrieving linked issues.

Errors: 1

  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 194c6032-2a6b-4f71-b752-dc9c84b7b777
Commits

Reviewing files that changed from the base of the PR and between 1b487ca and f1bee44.

Files selected for processing: 7

  • app/containers/MessageComposer/MessageComposer.test.tsx
  • app/containers/MessageComposer/__tests__/MessageComposerContainer.test.tsx
  • app/containers/MessageComposer/helpers/prepareQuoteMessage.test.ts
  • app/containers/MessageComposer/helpers/prepareQuoteMessage.ts
  • app/containers/MessageComposer/hooks/useMessage.ts
  • app/lib/database/services/Message.test.ts
  • app/lib/database/services/Message.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 3

  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: E2E Shard Preflight
  • GitHub Check: format
Additional comments: 7

app/lib/database/services/Message.ts: 1

30-36: LGTM!

app/lib/database/services/Message.test.ts: 1

4-4: LGTM!

Also applies to: 104-152

app/containers/MessageComposer/helpers/prepareQuoteMessage.ts: 1

2-2: LGTM!

Also applies to: 12-12

app/containers/MessageComposer/hooks/useMessage.ts: 1

4-4: LGTM!

Also applies to: 13-13

app/containers/MessageComposer/helpers/prepareQuoteMessage.test.ts: 1

3-3: LGTM!

Also applies to: 13-13, 27-29, 53-53, 81-81, 86-86, 97-97, 115-115, 120-120, 130-130, 135-135, 143-143, 157-157, 170-170, 189-189, 194-194, 200-200, 205-206, 210-210, 215-215, 228-228, 247-247

app/containers/MessageComposer/MessageComposer.test.tsx: 1

97-98: LGTM!

Also applies to: 110-112

app/containers/MessageComposer/__tests__/MessageComposerContainer.test.tsx: 1

60-63: LGTM!

This branch is waiting to be deployed

3 waiting deployments
android_build — f1bee442 Waiting Nov 13, 2026 by OtavioStasiak via Build Android / Hold #7787
ios_build — f1bee442 Waiting Nov 13, 2026 by OtavioStasiak via Build iOS / Hold #7787
approve_e2e_testing — f1bee442 Waiting Nov 13, 2026 by OtavioStasiak via E2E Hold #7787
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.

1 participant