Skip to content

Conversation

@MartinSchoeler
Copy link
Member

@MartinSchoeler MartinSchoeler commented Jan 22, 2026

Proposed changes (including videos or screenshots)

In #38067 we removed a delay when sending a message, but the streamNewMessage callback happened to run between this delay, considering the recently sent message as a new message, with the delay removed, the message is upserted before the callback run, so it does not consider it a new message and does not do the sendToBottom() call

Issue(s)

CORE-1748

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Improved new message notification handling to better track unread messages when scrolled away from the bottom of the chat
    • Enhanced event handling for proper scrolling behavior in message threads

✏️ Tip: You can customize this high-level summary in your review settings.

@MartinSchoeler MartinSchoeler added this to the 8.1.0 milestone Jan 22, 2026
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 22, 2026

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

  • This PR is missing the 'stat: QA assured' label

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 Jan 22, 2026

🦋 Changeset detected

Latest commit: 0ffafec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
@rocket.chat/rest-typings Patch
@rocket.chat/meteor Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/ui-client Patch
@rocket.chat/media-calls Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@rocket.chat/apps Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

The changes modify message event handling to differentiate between incoming and sent messages. Sent messages now trigger automatic scroll-to-bottom behavior through the afterSaveMessage callback instead of relying on streamNewMessage, while incoming messages continue to display a new message indicator when not at bottom.

Changes

Cohort / File(s) Summary
Message State Management
apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts
Changed event lifecycle: removed afterSaveMessage handler that set hasNewMessages for non-current-user messages; added afterSaveMessage handler that scrolls to bottom and clears hasNewMessages when current user sends a message; added proper cleanup for the new callback registration.
Thread Scrolling
apps/meteor/client/views/room/contextualBar/Threads/hooks/useLegacyThreadMessageListScrolling.ts
Replaced event listener from streamNewMessage to afterSaveMessage in both add and remove callback paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hop, skip, and jump to the bottom we go,
When a message is sent, it's the scroll we now know,
No more lingering high when we pen down our words,
The auto-scroll magic makes our chat dreams heard! ✨

🚥 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 describes the regression being fixed: restoring the automatic scroll-to-bottom behavior when a message is sent.
Linked Issues check ✅ Passed The code changes address CORE-1748 by switching from 'streamNewMessage' to 'afterSaveMessage' callback to restore auto-scroll behavior when sending messages.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the regression: modifying event listeners in useHasNewMessages and useLegacyThreadMessageListScrolling hooks to restore scroll-to-bottom functionality.
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 regression/jumptomessage

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.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-8.1.0@dee9618). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-8.1.0   #38297   +/-   ##
================================================
  Coverage                 ?   70.81%           
================================================
  Files                    ?     3158           
  Lines                    ?   109356           
  Branches                 ?    19700           
================================================
  Hits                     ?    77441           
  Misses                   ?    29886           
  Partials                 ?     2029           
Flag Coverage Δ
e2e 60.28% <100.00%> (?)
e2e-api 48.06% <ø> (?)
unit 71.99% <ø> (?)

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "01/22 20:27 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38297
  • Baseline: develop
  • Timestamp: 2026-01-22 20:27:18 UTC
  • Historical data points: 30

Updated: Thu, 22 Jan 2026 20:27:19 GMT

@MartinSchoeler MartinSchoeler marked this pull request as ready for review January 22, 2026 19:31
@MartinSchoeler MartinSchoeler requested a review from a team as a code owner January 22, 2026 19:31
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 2 files

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts (1)

67-77: Missing room and message type guards in afterSaveMessage callback.

The callback should include the same guards as streamNewMessage above (and as done in useLegacyThreadMessageListScrolling.ts):

  1. Room ID check (rid !== msg.rid) — without this, messages from other rooms could trigger scroll
  2. Edited message check (isEditedMessage(msg)) — edits shouldn't trigger scroll
  3. Thread message check (msg.tmid) — thread replies shouldn't scroll the main room
Proposed fix
 		clientCallbacks.add(
 			'afterSaveMessage',
 			(msg: IMessage) => {
+				if (rid !== msg.rid || isEditedMessage(msg) || msg.tmid) {
+					return;
+				}
+
 				if (msg.u._id === uid) {
 					sendToBottom();
 					setHasNewMessages(false);
 				}
 			},
 			clientCallbacks.priority.MEDIUM,
 			rid,
 		);

tassoevan
tassoevan previously approved these changes Jan 22, 2026
@MartinSchoeler MartinSchoeler force-pushed the regression/jumptomessage branch from a36ab9d to 0ffafec Compare January 22, 2026 20:06
@MartinSchoeler MartinSchoeler requested review from a team as code owners January 22, 2026 20:06
@MartinSchoeler MartinSchoeler changed the base branch from develop to release-8.1.0 January 22, 2026 20:06
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts (1)

67-77: Missing guard conditions in afterSaveMessage callback.

The afterSaveMessage callback is missing the same guard conditions present in the streamNewMessage callback (lines 55-57). Without these checks, sendToBottom() will be incorrectly triggered when:

  1. The user sends a message in a different room
  2. The user edits an existing message
  3. The user sends a thread reply (which shouldn't scroll the main room)

Note that useLegacyThreadMessageListScrolling.ts correctly includes these guards in its afterSaveMessage callback.

🐛 Proposed fix
 		clientCallbacks.add(
 			'afterSaveMessage',
 			(msg: IMessage) => {
+				if (rid !== msg.rid || isEditedMessage(msg) || msg.tmid) {
+					return;
+				}
+
 				if (msg.u._id === uid) {
 					sendToBottom();
 					setHasNewMessages(false);
 				}
 			},
 			clientCallbacks.priority.MEDIUM,
 			rid,
 		);

@dougfabris dougfabris removed the request for review from a team January 22, 2026 21:14
@tassoevan tassoevan merged commit c240ef4 into release-8.1.0 Jan 22, 2026
57 of 70 checks passed
@tassoevan tassoevan deleted the regression/jumptomessage branch January 22, 2026 21:58
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.

4 participants