Skip to content

fix: message deep links (?msg=) reload loop when jumping to an old message - #41499

Merged
dionisio-bot[bot] merged 2 commits into
release-8.8.0from
fix/msg-deeplink-reload-loop
Aug 21, 2026
Merged

fix: message deep links (?msg=) reload loop when jumping to an old message#41499
dionisio-bot[bot] merged 2 commits into
release-8.8.0from
fix/msg-deeplink-reload-loop

Conversation

@ricardogarim

@ricardogarim ricardogarim commented Jul 21, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Opening a message deep link (?msg=<id>) to a message far from recent history flashes the target, then keeps loading until it hits the server rate limit (429) and the room reloads.

On a ?msg= open, two loads compete over the same message store: RoomProvider prefetches recent history, and the jump loads the surrounding window. The surrounding load calls clear() (which resets loaded), so RoomProvider re-fires recent and clobbers the window — which re-triggers the surrounding load → 429.

Fix (2 files):

  • RoomProvider — skip the recent-history prefetch while ?msg= is set, so the surrounding-window load owns the initial load (removes the competing load / the race).
  • RoomHistoryManager — re-assert isLoading right after clear() in loadSurroundingMessages, so the surrounding load isn't re-fired into the brief empty-store gap clear() opens before the messages are upserted.

Result: a ?msg= open does a single surrounding-window load and opens positioned on the message. Normal opens (no ?msg=) are unchanged.

Issue(s)

Steps to test or reproduce

  1. Pick a message far from the bottom of a busy channel, copy its link (?msg=<id>).
  2. Open it in an incognito window (empty cache is required — a warm cache hides the bug).
  • Before: target flashes in, then loads keep firing → 429 / reload.
  • After: opens positioned on the target and stays.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed message links that could trigger repeated reloads when opening older messages.
    • Rooms now remain focused on the selected message without hitting rate limits.
    • Improved navigation to messages within threads, including loading surrounding context when needed.
    • Corrected loading indicators while message history is being fetched.

@dionisio-bot

dionisio-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The message deep-link flow skips initial history prefetch, resolves thread targets to parent messages, loads surrounding messages with explicit identifiers, and preserves loading state during fetches. A patch Changeset documents the fix.

Changes

Message deep-link flow

Layer / File(s) Summary
Skip initial history prefetch for message links
apps/meteor/client/views/room/providers/RoomProvider.tsx
RoomProvider reads the msg parameter and skips the initial history prefetch while it is present.
Resolve and load deep-linked messages
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts, apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts, .changeset/plenty-lines-double.md
Thread jumps resolve to the parent message. Surrounding messages load with explicit _id and rid values. The loading state is restored after clearing room history. A patch release entry documents the fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: dougfabris

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary fix for the ?msg= deep-link reload loop when jumping to older messages.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • CORE-2424: 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.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.29%. Comparing base (ea163f5) to head (13ec11c).
⚠️ Report is 24 commits behind head on release-8.8.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release-8.8.0   #41499      +/-   ##
=================================================
+ Coverage          69.25%   69.29%   +0.04%     
=================================================
  Files               4234     4234              
  Lines             167278   167373      +95     
  Branches           29806    29880      +74     
=================================================
+ Hits              115841   115981     +140     
+ Misses             46279    46233      -46     
- Partials            5158     5159       +1     
Flag Coverage Δ
e2e 58.94% <72.41%> (+0.01%) ⬆️
e2e-api 46.13% <0.00%> (+0.26%) ⬆️
unit 71.24% <93.33%> (+0.03%) ⬆️

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.

@ricardogarim ricardogarim added this to the 8.7.0 milestone Jul 21, 2026
@ricardogarim
ricardogarim force-pushed the fix/msg-deeplink-reload-loop branch from ae8ea9f to ded3e22 Compare July 21, 2026 23:38
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 13ec11c

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

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings 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

@ricardogarim ricardogarim modified the milestones: 8.7.0, 8.8.0 Jul 22, 2026
@ricardogarim
ricardogarim marked this pull request as ready for review July 22, 2026 12:14
@ricardogarim
ricardogarim requested a review from a team as a code owner July 22, 2026 12:14

@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 3 files

Re-trigger cubic

@dougfabris dougfabris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Previously it attempts to scroll to the message in main room, now its not scrolling anymore not sure if thats expected 🤔

@ricardogarim
ricardogarim force-pushed the fix/msg-deeplink-reload-loop branch from ded3e22 to b6a21d0 Compare August 7, 2026 21:45
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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/MessageList/hooks/useTryToJumpToMessage.ts`:
- Around line 75-77: Update the jump-handling effect in useTryToJumpToMessage to
track the handled (messageJumpParam, mainMessageId) pair in a ref once the
target is loaded. For thread-message jumps where the IDs differ, retain the
query parameter but return early for the already-handled pair so subsequent
messages updates do not repeat scrolling or highlight timers; reset or replace
the tracked pair when the target changes.
🪄 Autofix

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 Plus

Run ID: 9eeb8612-5634-4b3d-8bf7-8a2cd29cb12d

📥 Commits

Reviewing files that changed from the base of the PR and between a9f3e6c and b6a21d0.

📒 Files selected for processing (4)
  • .changeset/plenty-lines-double.md
  • apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts
  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
  • apps/meteor/client/views/room/providers/RoomProvider.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts
  • .changeset/plenty-lines-double.md
  • apps/meteor/client/views/room/providers/RoomProvider.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (4)

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/**

📄 CodeRabbit inference engine (CLAUDE.md)

The main Rocket.Chat Meteor application resides in apps/meteor/; place its application code there rather than in other monorepo areas.

Files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts
🧠 Learnings (5)
📚 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
🔇 Additional comments (1)
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts (1)

44-57: LGTM!

Comment thread apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToMessage.ts Outdated
cardoso
cardoso previously approved these changes Aug 12, 2026

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

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts Outdated
@ricardogarim
ricardogarim force-pushed the fix/msg-deeplink-reload-loop branch from 944c592 to 676d9ed Compare August 18, 2026 00:31
cardoso
cardoso previously approved these changes Aug 18, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Aug 18, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 18, 2026
@ricardogarim ricardogarim removed this from the 8.8.0 milestone Aug 18, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Aug 18, 2026
@ricardogarim ricardogarim added this to the 8.8.0 milestone Aug 18, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 18, 2026
@ricardogarim
ricardogarim force-pushed the fix/msg-deeplink-reload-loop branch from 676d9ed to 62097c7 Compare August 18, 2026 23:30
@nazabucciarelli
nazabucciarelli self-requested a review August 19, 2026 18:00

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

BE is okay

@ricardogarim
ricardogarim removed the request for review from dougfabris August 20, 2026 20:44
cardoso
cardoso previously approved these changes Aug 21, 2026
@ricardogarim
ricardogarim changed the base branch from develop to release-8.8.0 August 21, 2026 12:15
@ricardogarim
ricardogarim dismissed stale reviews from cardoso and nazabucciarelli August 21, 2026 12:15

The base branch was changed.

@ricardogarim ricardogarim removed this from the 8.8.0 milestone Aug 21, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Aug 21, 2026
@ricardogarim ricardogarim added this to the 8.8.0 milestone Aug 21, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 21, 2026
@dionisio-bot
dionisio-bot Bot merged commit 6a5456e into release-8.8.0 Aug 21, 2026
56 checks passed
@dionisio-bot
dionisio-bot Bot deleted the fix/msg-deeplink-reload-loop branch August 21, 2026 12:18
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.

5 participants