Skip to content

regression: unfollowed thread message marked as unread#40644

Merged
tassoevan merged 12 commits into
release-8.5.0from
reg-unread
May 26, 2026
Merged

regression: unfollowed thread message marked as unread#40644
tassoevan merged 12 commits into
release-8.5.0from
reg-unread

Conversation

@MartinSchoeler
Copy link
Copy Markdown
Member

@MartinSchoeler MartinSchoeler commented May 21, 2026

Proposed changes (including videos or screenshots)

Issue(s)

CORE-2221
CORE-2214

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • More accurate unread detection so jump-to-unread targets the correct visible message.
    • Prevents automatic navigation into thread messages when jumping to unread.
    • Jump-to navigation now preserves contextual query state for predictable behavior.
    • Improved scroll-bottom detection and clears stale deep-link parameters when targets are missing.
  • Tests

    • Added tests covering jump-to behavior and early-return scenarios.

Review Change Stack

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

dionisio-bot Bot commented May 21, 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
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 7abc0d7

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

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

First-unread selection excludes thread-only messages unless tshow === true. Navigation now sets an optional jumpContext (jumpToUnread) and thread-jump logic skips jumping when that context is present; thread list scroll gating and timed deep-link cleanup were also added.

Changes

Unread message filtering by thread visibility

Layer / File(s) Summary
Thread-aware unread message selection
apps/meteor/client/lib/chats/readStateManager.ts, apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts
Both updateFirstUnreadRecordId() and handleUnreadBarJumpToButtonClick() add the predicate `(!record.tmid
JumpContext query parameter and thread-jump guard
apps/meteor/client/lib/utils/setMessageJumpQueryStringParameter.ts, apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.ts, apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts
setMessageJumpQueryStringParameter gains an optional context ('jumpToUnread') and preserves existing search params; useTryToJumpToThreadMessage reads jumpContext and skips thread-jumping when it equals jumpToUnread. Tests cover early-return behaviors.
Thread list scroll gating and deep-link cleanup
apps/meteor/client/views/room/contextualBar/Threads/components/ThreadMessageList.tsx
isAtBottom ref becomes tri-state (null initial), bottom-detection requires isAtBottom.current === true, and a timed effect clears invalid msg deep-links after 500ms with cleanup.

Sequence Diagram(s)

sequenceDiagram
  participant UnreadHook
  participant RouterUtil as setMessageJumpQueryStringParameter
  participant URLSearchParams
  participant ThreadJumpHook as useTryToJumpToThreadMessage
  UnreadHook->>RouterUtil: setMessageJumpQueryStringParameter(msgId, 'jumpToUnread')
  RouterUtil->>URLSearchParams: read current search, include jumpContext when provided
  ThreadJumpHook->>URLSearchParams: read jumpContext param
  ThreadJumpHook-->>ThreadJumpHook: exit early if jumpContext == jumpToUnread
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

type: bug

Suggested reviewers

  • cardoso
  • 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 'regression: unfollowed thread message marked as unread' clearly identifies the core issue being fixed: a regression affecting how unfollowed thread messages are handled in unread state tracking.
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 (2)
  • CORE-2221: Request failed with status code 401
  • CORE-2214: 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/body/hooks/useUnreadMessages.ts (1)

93-99: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unread count predicate is inconsistent with the new thread filter.

updateFirstUnreadRecordId() and handleUnreadBarJumpToButtonClick() now exclude thread-only messages via (!record.tmid || record.tshow === true), but this filterMessages call still counts them. This can produce a non-zero unread badge with no corresponding unread mark or jump target (the regression this PR addresses can still surface here when only threaded replies are loaded for the room), keeping the bar visible until a manual mark-as-read.

🔧 Suggested fix
 		const count = filterMessages(
 			(record) =>
 				record.rid === room._id &&
 				!!lastMessageDate &&
 				record.ts.getTime() <= lastMessageDate?.getTime() &&
-				record.ts.getTime() > (subscription?.ls?.getTime() ?? -Infinity),
+				record.ts.getTime() > (subscription?.ls?.getTime() ?? -Infinity) &&
+				(!record.tmid || record.tshow === true),
 		).length;
🤖 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/body/hooks/useUnreadMessages.ts` around lines
93 - 99, The unread count predicate used in filterMessages in
useUnreadMessages.ts is still including thread-only messages, causing a mismatch
with updateFirstUnreadRecordId and handleUnreadBarJumpToButtonClick; modify the
predicate used to compute count so it mirrors the other functions by excluding
thread-only messages (add the same condition: (!record.tmid || record.tshow ===
true)) alongside the existing checks for record.rid, lastMessageDate, and
subscription.ls to ensure the badge and jump target stay in sync.
🧹 Nitpick comments (1)
apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts (1)

67-72: 💤 Low value

Nit: comparator indentation is misaligned.

Line 71’s comparator argument is indented one extra level beyond the predicate argument on line 67, making it visually appear nested inside the predicate. Aligning both arguments at the same indent improves readability.

🎨 Suggested formatting
 			message = findFirstMessage(
 				(record) =>
 					record.rid === rid &&
 					record.ts.getTime() > (unread?.since.getTime() ?? -Infinity) &&
-					(!record.tmid || record.tshow === true), 
-					(a, b) => a.ts.getTime() - b.ts.getTime(),
+					(!record.tmid || record.tshow === true),
+				(a, b) => a.ts.getTime() - b.ts.getTime(),
 			);
🤖 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/body/hooks/useUnreadMessages.ts` around lines
67 - 72, In useUnreadMessages.ts the second argument comparator "(a, b) =>
a.ts.getTime() - b.ts.getTime()" is indented one level deeper than the predicate
"(record) => ..." making it look nested; align the comparator's indentation so
both arguments to the call start at the same column as the predicate to improve
readability (adjust the line containing the "(a, b) => ..." arrow function to
match the predicate's indentation).
🤖 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/body/hooks/useUnreadMessages.ts`:
- Around line 93-99: The unread count predicate used in filterMessages in
useUnreadMessages.ts is still including thread-only messages, causing a mismatch
with updateFirstUnreadRecordId and handleUnreadBarJumpToButtonClick; modify the
predicate used to compute count so it mirrors the other functions by excluding
thread-only messages (add the same condition: (!record.tmid || record.tshow ===
true)) alongside the existing checks for record.rid, lastMessageDate, and
subscription.ls to ensure the badge and jump target stay in sync.

---

Nitpick comments:
In `@apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts`:
- Around line 67-72: In useUnreadMessages.ts the second argument comparator "(a,
b) => a.ts.getTime() - b.ts.getTime()" is indented one level deeper than the
predicate "(record) => ..." making it look nested; align the comparator's
indentation so both arguments to the call start at the same column as the
predicate to improve readability (adjust the line containing the "(a, b) => ..."
arrow function to match the predicate's indentation).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: def17188-f4c2-4529-8fce-cad4756fca6e

📥 Commits

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

📒 Files selected for processing (2)
  • apps/meteor/client/lib/chats/readStateManager.ts
  • apps/meteor/client/views/room/body/hooks/useUnreadMessages.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). (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • 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/useUnreadMessages.ts
  • apps/meteor/client/lib/chats/readStateManager.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/body/hooks/useUnreadMessages.ts
  • apps/meteor/client/lib/chats/readStateManager.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/useUnreadMessages.ts
  • apps/meteor/client/lib/chats/readStateManager.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/useUnreadMessages.ts
  • apps/meteor/client/lib/chats/readStateManager.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/useUnreadMessages.ts
  • apps/meteor/client/lib/chats/readStateManager.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/useUnreadMessages.ts
  • apps/meteor/client/lib/chats/readStateManager.ts
🔇 Additional comments (1)
apps/meteor/client/lib/chats/readStateManager.ts (1)

75-76: LGTM!

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

@ricardogarim
Copy link
Copy Markdown
Member

ricardogarim commented May 21, 2026

Regarding CORE-2221, while testing, found a case this PR doesn't cover: if the oldest unread message is a thread parent (not a reply), clicking the bubble still opens the thread panel.

Tracing it down, this is a side-effect of #40105. The old useJumpToMessage only moved the page to the message. The new useTryToJumpToThreadMessage does more - for any ?msg=<id> that resolves to a thread reply or a thread parent, it routes into the thread panel. The unread bubble has always just set ?msg=, so it silently picked up that new behavior.

One option is to make the URL source-aware: have the bubble add an extra parameter alongside msg (e.g. unreadJump=1), and let the thread hook skip when that flag is set. Toolbar actions and notification deep links wouldn't set the flag, so their current behavior would be preserved.

Screen.Recording.2026-05-21.at.15.24.15.mov

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5.0@6fb88e1). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-8.5.0   #40644   +/-   ##
================================================
  Coverage                 ?   69.63%           
================================================
  Files                    ?     3338           
  Lines                    ?   123300           
  Branches                 ?    22000           
================================================
  Hits                     ?    85861           
  Misses                   ?    34071           
  Partials                 ?     3368           
Flag Coverage Δ
e2e 59.12% <80.95%> (?)
e2e-api 45.97% <ø> (?)
unit 70.47% <100.00%> (?)

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
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 (2)
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts (2)

62-88: ⚡ Quick win

Consider mocking and verifying goToRoom() behavior.

The test asserts that RoomHistoryManager methods are not called when jumpContext === 'jumpToUnread', which correctly verifies the early return. However, the implementation also calls goToRoom() to navigate to the thread panel in the non-early-return path. While the early return prevents this call, explicitly mocking useGoToRoom() and asserting that the returned function was not called would make the test's "should not navigate" claim more robust and self-documenting.

Example: Mock and verify goToRoom

Add a mock for the hook:

const mockGoToRoom = jest.fn();
jest.mock('../../../../hooks/useGoToRoom', () => ({
  useGoToRoom: () => mockGoToRoom,
}));

Then assert in the test:

expect(mockGoToRoom).not.toHaveBeenCalled();
🤖 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/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts`
around lines 62 - 88, The test for useTryToJumpToThreadMessage should also mock
and verify the navigation function to prove "should not navigate": add a jest
mock for the useGoToRoom hook (returning a jest.fn() like mockGoToRoom) so the
hook used by useTryToJumpToThreadMessage is replaced, then in this test assert
mockGoToRoom was not called; keep the existing assertions that
mockedRoomHistoryManager.getSurroundingMessages and .getMore were not called and
ensure the endpointSpy expectation remains.

48-90: ⚡ Quick win

Consider adding positive-path test coverage.

The current tests verify that the hook correctly skips thread navigation when msg is absent or jumpContext === 'jumpToUnread'. To ensure the fix doesn't regress intended behavior, consider adding a test case where msg is present and jumpContext is undefined or a different value, verifying that goToRoom() is called and messages are loaded as expected.

Example test case
it('should navigate and load messages when jumpContext is not jumpToUnread', async () => {
  const threadMessage = {
    _id: 'msg-1',
    rid: 'room-1',
    tmid: 'parent-msg-1',
    ts: new Date('2024-01-01T00:00:00Z').toISOString(),
    u: { _id: 'user-1', username: 'john' },
    msg: 'Thread reply',
    _updatedAt: new Date('2024-01-01T00:00:00Z').toISOString(),
  };

  const endpointSpy = jest.fn().mockResolvedValue({ message: threadMessage });
  const mockGoToRoom = jest.fn();

  renderHook(() => useTryToJumpToThreadMessage(), {
    wrapper: mockAppRoot()
      .withRouter({ getSearchParameters: () => ({ msg: 'msg-1' }) })
      .withEndpoint('GET', '/v1/chat.getMessage', endpointSpy)
      .build(),
  });

  await waitFor(() => {
    expect(mockGoToRoom).toHaveBeenCalledWith('room-1', expect.objectContaining({
      routeParamsOverrides: { tab: 'thread', context: 'parent-msg-1' },
    }));
  });
});
🤖 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/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts`
around lines 48 - 90, Add a positive-path test for useTryToJumpToThreadMessage:
when the router search parameter includes msg (e.g., { msg: 'msg-1' }) and
jumpContext is absent or not 'jumpToUnread', mock the GET /v1/chat.getMessage
endpoint to return a thread message and stub goToRoom, then assert the endpoint
was called with { msgId: 'msg-1' }, that goToRoom was invoked with the
message.rid and routeParamsOverrides including tab: 'thread' and context equal
to the message.tmid (use the goToRoom spy), and that
mockedRoomHistoryManager.getSurroundingMessages or getMore were called to load
the messages; use the existing renderHook + mockAppRoot setup and waitFor to
await async behavior.
🤖 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/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts`:
- Around line 62-88: The test for useTryToJumpToThreadMessage should also mock
and verify the navigation function to prove "should not navigate": add a jest
mock for the useGoToRoom hook (returning a jest.fn() like mockGoToRoom) so the
hook used by useTryToJumpToThreadMessage is replaced, then in this test assert
mockGoToRoom was not called; keep the existing assertions that
mockedRoomHistoryManager.getSurroundingMessages and .getMore were not called and
ensure the endpointSpy expectation remains.
- Around line 48-90: Add a positive-path test for useTryToJumpToThreadMessage:
when the router search parameter includes msg (e.g., { msg: 'msg-1' }) and
jumpContext is absent or not 'jumpToUnread', mock the GET /v1/chat.getMessage
endpoint to return a thread message and stub goToRoom, then assert the endpoint
was called with { msgId: 'msg-1' }, that goToRoom was invoked with the
message.rid and routeParamsOverrides including tab: 'thread' and context equal
to the message.tmid (use the goToRoom spy), and that
mockedRoomHistoryManager.getSurroundingMessages or getMore were called to load
the messages; use the existing renderHook + mockAppRoot setup and waitFor to
await async behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d7e3e35-211a-41bd-af47-2f18a31da6f2

📥 Commits

Reviewing files that changed from the base of the PR and between 71f4622 and acc4ce6.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.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). (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 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/useTryToJumpToThreadMessage.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts
🧠 Learnings (7)
📚 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/useTryToJumpToThreadMessage.spec.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/useTryToJumpToThreadMessage.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.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/useTryToJumpToThreadMessage.spec.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/useTryToJumpToThreadMessage.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.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/useTryToJumpToThreadMessage.spec.ts
🧬 Code graph analysis (1)
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts (2)
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.ts (1)
  • useTryToJumpToThreadMessage (12-61)
apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts (1)
  • RoomHistoryManager (357-357)
🔇 Additional comments (2)
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.spec.ts (2)

1-46: LGTM!


48-60: LGTM!

Copy link
Copy Markdown
Member

@gabriellsh gabriellsh left a comment

Choose a reason for hiding this comment

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

Noticed the following situation:

  • Open a DM between user A and B
  • Start a thread with user A
  • Read the messages and thead with user B, then switch rooms.
  • With user A, send another message in the thread, with "Also send to channel" marked
  • With user A, flood the main room with enough messages to fill the page so the unread bubble appears for user B
  • With user B, go back to the room and click the unread bubble
  • No scroll happens, but messages are marked as read (the thread message isn't marked as read, but I think that's the proper behavior since the thread shouldn't open)

MartinSchoeler and others added 2 commits May 26, 2026 16:00
Co-authored-by: Douglas Gubert <douglas.gubert@gmail.com>
Co-authored-by: Julio Araujo <julio.araujo@rocket.chat>
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.

2 issues found across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

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.

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/contextualBar/Threads/components/ThreadMessageList.tsx`:
- Around line 145-147: The cleanup predicate is inverted: currently it clears
msgJumpParam when the target message exists; change the condition in
ThreadMessageList so it clears only when the target message is missing. Replace
the if using messages.find((m) => m._id === msgJumpParam) && mainMessage._id !==
msgJumpParam with the inverted check: if (!messages.find((m) => m._id ===
msgJumpParam) && mainMessage._id !== msgJumpParam) {
setMessageJumpQueryStringParameter(null); } to remove stale ?msg= values
correctly.
🪄 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: fa1e6c92-1248-4af8-b6ca-af7cb396a873

📥 Commits

Reviewing files that changed from the base of the PR and between acc4ce6 and 8b1185b.

📒 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). (2)
  • GitHub Check: 📦 Build Packages
  • 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)

15-15: LGTM!

Also applies to: 76-79, 108-111, 134-134

@tassoevan tassoevan merged commit 80b90cd into release-8.5.0 May 26, 2026
117 of 122 checks passed
@tassoevan tassoevan deleted the reg-unread branch May 26, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants