Skip to content

fix: Discussion message count displays one less than actual#38719

Open
dodaa08 wants to merge 6 commits intoRocketChat:developfrom
dodaa08:fix/DiscussionCount
Open

fix: Discussion message count displays one less than actual#38719
dodaa08 wants to merge 6 commits intoRocketChat:developfrom
dodaa08:fix/DiscussionCount

Conversation

@dodaa08
Copy link
Contributor

@dodaa08 dodaa08 commented Feb 15, 2026

Proposed changes (including videos or screenshots)

This PR fixes an issue where the discussion message count displayed in the parent room's system message was always one less than the actual count.

Fix by adding a 1 before updating the Parent Room data with the correct timestamp for the message, also a check if the message is Only a fresh one not edited for the count.

Before, The issue is still reproducible

Screencast.From.2026-02-16.22-21-45.mp4

After

Screencast.From.2026-02-16.00-51-07.mp4

Issue(s)

Fixes #35435

Steps to test or reproduce

  1. Open a team, channel, or direct message
  2. Send a message and create a discussion from it (three-dot menu → "Create Discussion")
  3. Send multiple messages within the discussion (e.g., 3-5 messages)
  4. Navigate back to the original room/channel
  5. Expected: The discussion system message should show the correct total message count
  6. Before fix: The count was always one less than actual
  7. After fix: The count matches the actual number of messages in the discussion

Additional test cases:

  • Test with the first message in a discussion
  • Test with rapid consecutive messages
  • Test with edited messages
  • Verify the count updates correctly when messages are deleted

Further comments

Considered using setImmediate() but the current approach is more consistent and straightforward.
I hope this approach fits the most, let me know if the code or tests needs an upgrade here.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented message edits from being counted as new messages and from updating a room’s "last message" timestamp. This improves message counts and room activity indicators so they reflect only genuine new messages, avoiding inflated stats and misleading recent-activity ordering while preserving existing refresh and parent-room notification behavior.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 15, 2026

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

changeset-bot bot commented Feb 15, 2026

⚠️ No Changeset found

Latest commit: 8a4dbe4

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Walkthrough

The discussion metadata propagation hook was changed to detect edited messages and, for edits, skip incrementing the discussion room's message count and skip updating its last-message timestamp; other propagation (refresh/notify parent room) is unchanged.

Changes

Cohort / File(s) Summary
Discussion Metadata Hook
apps/meteor/app/discussion/server/hooks/propagateDiscussionMetadata.ts
Added isEditedMessage check in the afterSaveMessage flow to prevent edited messages from incrementing room.msgs or updating room.lm; new messages still trigger those updates and existing refresh/notify behavior remains.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped through code with nimble feet,
Found edits counted when they shouldn't meet,
Now tweaks skip the tally and the time,
Discussions stay honest, neat, and fine. 🥕✨

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: correcting discussion message count to display the actual count instead of one less.
Linked Issues check ✅ Passed The code changes implement the fix for issue #35435 by preventing edited messages from incrementing the message count and updating the last message timestamp.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the discussion message count issue; no unrelated or out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 1 file

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.50%. Comparing base (508b4a1) to head (8a4dbe4).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38719      +/-   ##
===========================================
- Coverage    70.51%   70.50%   -0.02%     
===========================================
  Files         3176     3176              
  Lines       111139   111139              
  Branches     20050    20041       -9     
===========================================
- Hits         78367    78355      -12     
- Misses       30721    30742      +21     
+ Partials      2051     2042       -9     
Flag Coverage Δ
e2e 60.40% <ø> (-0.07%) ⬇️
e2e-api 47.73% <ø> (-0.04%) ⬇️
unit 71.52% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

fix: Correct message count display in discussions

1 participant