Skip to content

fix(client): auto-close thread sidebar when parent message is unavail…#40238

Open
opaksbyron wants to merge 3 commits into
RocketChat:developfrom
opaksbyron:fix/thread-sidebar-stuck-on-deleted-message
Open

fix(client): auto-close thread sidebar when parent message is unavail…#40238
opaksbyron wants to merge 3 commits into
RocketChat:developfrom
opaksbyron:fix/thread-sidebar-stuck-on-deleted-message

Conversation

@opaksbyron
Copy link
Copy Markdown

@opaksbyron opaksbyron commented Apr 20, 2026

Proposed changes

Closes #40036

Bug

When clicking on a "Message removed" placeholder (or the thread indicator of a deleted parent message), the Threads sidebar opens and becomes stuck — the X button fails to close it, and clicking other thread indicators does not update the content. Only fixable by reloading the page.

Root cause

Thread.tsx only handles isLoading and isSuccess states from useThreadMainMessageQuery. When the query returns isError: true (hard-deleted parent) or successfully fetches a t: 'rm' placeholder (soft-deleted with Message_KeepHistory: true), the component renders with no content and no way to close itself.

Fix

Added a useEffect that detects when the main message is unavailable (either query error, or fetched data is a removed placeholder) and automatically calls closeTab(). Completes the fix attempted in #40042 which only imported useEffect but never actually used it.

Issue(s)

How to test

  1. Send a message in a channel
  2. Reply to it in a thread
  3. Close the thread pane
  4. Delete the parent message (works with both Message_KeepHistory: true and false)
  5. Click the thread indicator / "Message removed" placeholder
  6. Before fix: sidebar opens stuck, X doesn't work
  7. After fix: sidebar auto-closes immediately

Summary by CodeRabbit

  • Bug Fixes

    • Thread sidebar now automatically closes when the thread’s main message becomes unavailable (deleted, error, or removed room), preventing the sidebar from getting stuck and removing the need to reload the page.
  • Chores

    • Prepared a patch release entry documenting the fix.

@opaksbyron opaksbyron requested a review from a team as a code owner April 20, 2026 23:28
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 20, 2026

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

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

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 Apr 20, 2026

🦋 Changeset detected

Latest commit: d9f2f1d

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

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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 20, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c53b5c18-fad8-4170-ab5a-b57efecb8bdb

📥 Commits

Reviewing files that changed from the base of the PR and between 6bee903 and 1f7e571.

📒 Files selected for processing (1)
  • .changeset/fix-thread-sidebar-stuck-on-deleted-message.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fix-thread-sidebar-stuck-on-deleted-message.md

Walkthrough

A useEffect was added to the Threads Thread component to detect when the thread's main message is unavailable (error or marked removed) and automatically close the thread tab to avoid a stuck/unresponsive sidebar.

Changes

Cohort / File(s) Summary
Thread Component Error Handling
apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx
Added useEffect that computes isMainMessageUnavailable from mainMessageQueryResult.isError or mainMessageQueryResult.data?.t === 'rm' and calls closeTab() when true, ensuring the sidebar auto-closes for deleted/errored parent messages.
Changeset
.changeset/fix-thread-sidebar-stuck-on-deleted-message.md
Added a patch changeset documenting the fix for the Threads sidebar getting stuck when the parent message is unavailable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 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 summarizes the main change: auto-closing the thread sidebar when the parent message is unavailable, which directly addresses the primary fix in this PR.
Linked Issues check ✅ Passed The PR implements the core fix required by #40036: auto-closing the Threads sidebar when the parent message is unavailable (deleted or removed), directly addressing all stated objectives.
Out of Scope Changes check ✅ Passed All changes are within scope: the useEffect addition detects unavailable messages and closes the tab, and the changeset documents the fix—no unrelated modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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 removed the type: bug label Apr 20, 2026
@dougfabris dougfabris added this to the 8.5.0 milestone Apr 22, 2026
@scuciatto scuciatto removed this from the 8.5.0 milestone May 14, 2026
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.

Sticky Thread UI Bug on Deleted Messages

4 participants