Skip to content

regression: thread not scrolling on receiving new message#40642

Merged
dionisio-bot[bot] merged 5 commits into
release-8.5.0from
reg-thread-not-scrolling
May 25, 2026
Merged

regression: thread not scrolling on receiving new message#40642
dionisio-bot[bot] merged 5 commits into
release-8.5.0from
reg-thread-not-scrolling

Conversation

@MartinSchoeler
Copy link
Copy Markdown
Member

@MartinSchoeler MartinSchoeler commented May 21, 2026

Proposed changes (including videos or screenshots)

Issue(s)

CORE-2215

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Exit early when a requested jump target is missing to avoid unnecessary scrolling.
    • Faster highlight clearing after jumping to a message (reduced delay).
    • Clear deep-link message query parameter after performing a jump to prevent stale links.
    • Refined auto-scroll logic so “jump to bottom” only re-enables when already at bottom and content height changed.

Review Change Stack

@MartinSchoeler MartinSchoeler requested a review from a team as a code owner May 21, 2026 14:05
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 21, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 14349dc

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
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Walkthrough

Two files update message-jump behavior: the jump effect now exits early when no target message is found and clears highlights faster (500ms), while the thread message list clears the msg deep-link after jumping and re-enables auto-scroll-to-bottom only when the virtualizer's scroll height has changed while the user is at bottom.

Changes

Message Jump Robustness and Thread Navigation Cleanup

Layer / File(s) Summary
Jump target validation and highlighting timing
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
useTryToJumpToMessage adds an early-return guard when the fetched message is falsy to prevent running scrolling/highlight logic without a valid target. The highlight-clearing timeout is reduced from 1000ms to 500ms.
Thread message jump cleanup and scroll behavior
apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
ThreadMessageList imports and calls setMessageJumpQueryStringParameter(null) to clear the msg deep-link parameter after highlighting, adds lastScrollSizeRef to track virtualizer scroll-size changes, and updates the jump-to-bottom effect to conditionally re-enable auto-scroll when content height changes while the user is at bottom.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

type: bug

Suggested reviewers

  • tassoevan
  • gabriellsh
🚥 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 main regression being fixed—thread message scrolling—which aligns with both code changes targeting thread message list behavior and jump-to-message functionality.
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.

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

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CORE-2215: Request failed with status code 401

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
Copy Markdown
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.

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/contextualBar/Threads/components/ThreadMessageList.tsx (1)

117-137: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clear msg when jump target cannot be resolved.

Right now, unresolved targets (threadMsgTargetIndex < 0) keep msg in the URL, while the other effect keeps forcing shouldJumpToBottom off whenever msg is present. That can leave thread scroll behavior degraded until a manual URL cleanup.

Proposed fix
 useEffect(() => {
-	if (threadMsgTargetIndex < 0 || !msgJumpParam) {
+	if (!msgJumpParam) {
 		return;
 	}
+	if (threadMsgTargetIndex < 0) {
+		setMessageJumpQueryStringParameter(null);
+		return;
+	}
 	const jumpKey = `${mainMessage._id}:${msgJumpParam}`;
 	if (lastThreadJumpKeyRef.current === jumpKey) {
 		return;
 	}
@@
-}, [threadMsgTargetIndex, msgJumpParam, mainMessage._id, setShouldJumpToBottom]);
+}, [threadMsgTargetIndex, msgJumpParam, mainMessage._id, setShouldJumpToBottom]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx`
around lines 117 - 137, When the jump target can't be resolved
(threadMsgTargetIndex < 0) the effect currently returns early but leaves the msg
in the URL; update the early-return branch of the useEffect (the one referencing
threadMsgTargetIndex and msgJumpParam) to clear the jump query by calling
setMessageJumpQueryStringParameter(null) (and optionally clear highlight state
if needed) so the URL-driven logic and setShouldJumpToBottom don't get stuck;
keep the rest of the logic (lastThreadJumpKeyRef, scrollToIndex,
setHighlightMessage) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx`:
- Around line 117-137: When the jump target can't be resolved
(threadMsgTargetIndex < 0) the effect currently returns early but leaves the msg
in the URL; update the early-return branch of the useEffect (the one referencing
threadMsgTargetIndex and msgJumpParam) to clear the jump query by calling
setMessageJumpQueryStringParameter(null) (and optionally clear highlight state
if needed) so the URL-driven logic and setShouldJumpToBottom don't get stuck;
keep the rest of the logic (lastThreadJumpKeyRef, scrollToIndex,
setHighlightMessage) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2a28658-bf1b-45b9-9ef1-3324a25bc16c

📥 Commits

Reviewing files that changed from the base of the PR and between f3c2b83 and 94c14cf.

📒 Files selected for processing (2)
  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
  • apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
📜 Review details
⏰ 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). (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
🧰 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/views/room/MessageList/hooks/useTryToJumpToMessage.ts
  • apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
🧠 Learnings (6)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
📚 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/views/room/MessageList/hooks/useTryToJumpToMessage.ts
  • apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
📚 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/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
🔇 Additional comments (2)
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts (1)

41-43: LGTM!

Also applies to: 84-84

apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx (1)

27-27: LGTM!

Also applies to: 77-77, 107-110, 133-133

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

Re-trigger cubic

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

🧹 Nitpick comments (1)
apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx (1)

107-115: 💤 Low value

Drop redundant optional chaining and the unused effect dep.

handle is already narrowed to non-null at line 100, so handle?.scrollSize (twice) can be handle.scrollSize. Also, threadMsgTargetIndex is listed in the dependency array but never referenced inside this effect; the jump logic lives in the separate effect below. Removing it avoids needless re-runs on jump-target changes.

♻️ Proposed change
-		if (isAtBottom.current && lastScrollSizeRef.current !== handle?.scrollSize) {
-			lastScrollSizeRef.current = handle?.scrollSize ?? 0;
+		if (isAtBottom.current && lastScrollSizeRef.current !== handle.scrollSize) {
+			lastScrollSizeRef.current = handle.scrollSize;
 			setShouldJumpToBottom(true);
 		}
 		if (shouldJumpToBottom) {
 			handle.scrollToIndex(items.length, { align: 'end' });
 			setShouldJumpToBottom(false);
 		}
-	}, [loading, items.length, msgJumpParam, threadMsgTargetIndex, shouldJumpToBottom, setShouldJumpToBottom]);
+	}, [loading, items.length, msgJumpParam, shouldJumpToBottom, setShouldJumpToBottom]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx`
around lines 107 - 115, The effect is using redundant optional chaining and
includes an unused dependency; replace both occurrences of handle?.scrollSize
with handle.scrollSize (since handle is narrowed non-null around line 100) when
updating lastScrollSizeRef.current and comparing, and remove
threadMsgTargetIndex from the effect's dependency array so the effect only
depends on loading, items.length, msgJumpParam, shouldJumpToBottom, and
setShouldJumpToBottom; keep the rest of the logic (isAtBottom.current check,
setShouldJumpToBottom(true), and the scrollToIndex call) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx`:
- Around line 107-115: The effect is using redundant optional chaining and
includes an unused dependency; replace both occurrences of handle?.scrollSize
with handle.scrollSize (since handle is narrowed non-null around line 100) when
updating lastScrollSizeRef.current and comparing, and remove
threadMsgTargetIndex from the effect's dependency array so the effect only
depends on loading, items.length, msgJumpParam, shouldJumpToBottom, and
setShouldJumpToBottom; keep the rest of the logic (isAtBottom.current check,
setShouldJumpToBottom(true), and the scrollToIndex call) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06cb8286-766c-47b1-b658-fc51d9f18f7b

📥 Commits

Reviewing files that changed from the base of the PR and between 94c14cf and 4a0a3d1.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
📜 Review details
⏰ 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). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
🧰 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/views/room/contextualBar/Threads/components/ThreadMessageList.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/views/room/contextualBar/Threads/components/ThreadMessageList.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/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
🔇 Additional comments (1)
apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx (1)

117-137: ⚡ Quick win

Please provide the original <review_comment> text (and any referenced file/diff context) so I can rewrite it accurately based on the verification results.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

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

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-8.5.0   #40642   +/-   ##
================================================
  Coverage                 ?   69.65%           
================================================
  Files                    ?     3338           
  Lines                    ?   123236           
  Branches                 ?    22006           
================================================
  Hits                     ?    85846           
  Misses                   ?    34032           
  Partials                 ?     3358           
Flag Coverage Δ
unit 70.48% <ø> (?)

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.

@MartinSchoeler MartinSchoeler added this to the 8.5.0 milestone May 25, 2026
@cardoso cardoso added the stat: QA assured Means it has been tested and approved by a company insider label May 25, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 25, 2026
@dionisio-bot dionisio-bot Bot merged commit 6fb88e1 into release-8.5.0 May 25, 2026
79 of 85 checks passed
@dionisio-bot dionisio-bot Bot deleted the reg-thread-not-scrolling branch May 25, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants