Skip to content

regression: Jump to recent message is not navigating to the latest message#40624

Merged
ggazzo merged 1 commit into
developfrom
reg-jump-to-message
May 20, 2026
Merged

regression: Jump to recent message is not navigating to the latest message#40624
ggazzo merged 1 commit into
developfrom
reg-jump-to-message

Conversation

@MartinSchoeler

@MartinSchoeler MartinSchoeler commented May 20, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Missing await on a RoomHistoryManager call

Issue(s)

CORE-2208

Steps to test or reproduce

Further comments

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved the "jump to recent" feature to properly load message history before navigating to latest messages, ensuring users can reliably access current content with complete context.

Review Change Stack

@MartinSchoeler MartinSchoeler requested a review from a team as a code owner May 20, 2026 17:44
@dionisio-bot

dionisio-bot Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented May 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0234437

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

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The hook useHasNewMessages is updated to make the jump-to-recent handler asynchronous. When triggered, it now clears room history, awaits the history manager's fetch completion, and only then sets the scroll-to-bottom flag, ensuring loaded messages are visible.

Changes

Jump to recent behavior

Layer / File(s) Summary
Async jump to recent handler
apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts
handleJumpToRecentButtonClick callback is converted to async, clearing history and awaiting RoomHistoryManager.getMoreIfIsEmpty(rid) before setting setShouldJumpToBottom(true) to ensure proper sequencing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: bug

Suggested reviewers

  • gabriellsh
  • tassoevan
🚥 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 clearly and specifically identifies the regression being fixed: the 'Jump to recent message' action not navigating to the latest message, which directly matches the changeset's addition of async/await behavior to ensure proper sequencing.
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-2208: 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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts`:
- Around line 31-35: The async handler handleJumpToRecentButtonClick currently
clears history then awaits RoomHistoryManager.getMoreIfIsEmpty(rid) without
error handling, which can leave the UI cleared if that promise rejects; wrap the
await in try/catch (or try/finally) so failures from
RoomHistoryManager.getMoreIfIsEmpty(rid) are caught and logged, and ensure
setShouldJumpToBottom(true) still runs (use finally or call it after catch) so
the UI state is consistent; reference handleJumpToRecentButtonClick,
RoomHistoryManager.clear, RoomHistoryManager.getMoreIfIsEmpty, and
setShouldJumpToBottom when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6a4fecac-ca77-44c3-a7e6-6a5cd32d82cc

📥 Commits

Reviewing files that changed from the base of the PR and between cedda23 and 0234437.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts
📜 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: 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/body/hooks/useHasNewMessages.ts
🧠 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/body/hooks/useHasNewMessages.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/body/hooks/useHasNewMessages.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/body/hooks/useHasNewMessages.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/body/hooks/useHasNewMessages.ts
📚 Learning: 2026-03-11T22:04:16.136Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 39545
File: apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts:59-61
Timestamp: 2026-03-11T22:04:16.136Z
Learning: In apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts, the early-return condition that checks msg.u._id === uid in the streamNewMessage handler is intentional. The New messages indicator should notify only about messages from other users; self-sent messages (including those from a different session/device) are intentionally skipped. Do not flag this as a multi-session regression for this file.

Applied to files:

  • apps/meteor/client/views/room/body/hooks/useHasNewMessages.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/body/hooks/useHasNewMessages.ts
🔇 Additional comments (1)
apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts (1)

33-33: Verify that RoomHistoryManager.getMoreIfIsEmpty returns a Promise.

The regression fix relies on awaiting getMoreIfIsEmpty(rid). If this method is synchronous or doesn't return a Promise, the await will have no effect and the fix will not work as intended.

Comment thread apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts
@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.75%. Comparing base (cedda23) to head (0234437).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40624      +/-   ##
===========================================
- Coverage    69.80%   69.75%   -0.06%     
===========================================
  Files         3325     3325              
  Lines       122974   122974              
  Branches     21943    21946       +3     
===========================================
- Hits         85839    85777      -62     
- Misses       33784    33847      +63     
+ Partials      3351     3350       -1     
Flag Coverage Δ
e2e 59.27% <100.00%> (-0.14%) ⬇️
e2e-api 46.13% <ø> (-0.86%) ⬇️
unit 70.51% <33.33%> (+<0.01%) ⬆️

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.

@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.

No issues found across 1 file

Re-trigger cubic

@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label May 20, 2026
@jessicaschelly jessicaschelly added stat: QA assured Means it has been tested and approved by a company insider and removed stat: QA assured Means it has been tested and approved by a company insider labels May 20, 2026
@dionisio-bot dionisio-bot Bot added stat: QA assured Means it has been tested and approved by a company insider and removed stat: QA assured Means it has been tested and approved by a company insider labels May 20, 2026
@MartinSchoeler MartinSchoeler added this to the 8.5.0 milestone May 20, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 20, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 20, 2026
@ggazzo ggazzo removed this pull request from the merge queue due to a manual request May 20, 2026
@ggazzo ggazzo merged commit 053dcb6 into develop May 20, 2026
47 checks passed
@ggazzo ggazzo deleted the reg-jump-to-message branch May 20, 2026 20:26
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.

4 participants