Skip to content

fix: close thread when its parent message is deleted - #1458

Open
Kulraj69 wants to merge 7 commits into
RocketChat:developfrom
Kulraj69:fix/close-thread-on-parent-delete
Open

Kulraj69 wants to merge 7 commits into
RocketChat:developfrom
Kulraj69:fix/close-thread-on-parent-delete

Conversation

@Kulraj69

@Kulraj69 Kulraj69 commented Nov 22, 2026 •

Copy link
Copy Markdown

Close the thread view when its parent message is deleted

Acceptance Criteria fulfillment

  • Deleting the parent of the active thread closes it and clears its state, including when the parent is absent from the loaded channel messages.
  • Deleting replies or unrelated messages preserves the active thread.
  • Show an informational toast explaining automatic closure after parent deletion.
  • Add a standard React package test command and mock the generated UI parser in the root rendering tests.

Fixes #1080

Changes

removeMessage resets the active parent thread atomically. A ChatBody-mounted hook subscribes to the store and shows the existing info toast only for that deletion transition. It unsubscribes on cleanup and stays quiet for manual closure, repeated events, replies and unrelated deletions. The same store path handles both local deletion and the room's message-deleted listener.

The React package now has a test script. Root rendering tests mock parseGeneratedUiConfigurations with an empty configuration/error result. The earlier test-only Babel override, jsdom configuration, store regressions and patch changeset remain in this PR.

Video/Screenshots

Checked the actual ToastBar/provider, deletion hook and message store in an isolated browser fixture at 900px and 390px widths. The thread disappears and the toast explains why. This is a component fixture, not a live Rocket.Chat session or deployment test.

PR Test Details

Latest revision, November 24:

  • cd packages/react && npm test -- --runInBand --no-cache: 16 passed across 3 suites.
  • Seven notification cases cover active-parent deletion with and without a loaded parent, duplicate events, unrelated/reply/unknown deletion, manual closure after a prior deletion, and subscription cleanup. With a no-op observer, both notification cases fail and the five quiet cases pass.
  • Prettier 2.8.1 passes for all five new/modified files in this revision.
  • Local Chrome fixture checks cover closure, contextual toast, repeated deletion, reply deletion and manual closure, with desktop/mobile visual inspection.

Validation used React 19.0.0, Zustand 4.3.8 and cached Jest 27.3.1 with a bounded dependency installation and local workspace source links. It was not a full lockfile installation. The full workspace build, ESLint, Storybook, live Rocket.Chat end-to-end behavior and remote CI have not been verified for this revision. Earlier build/lint claims are not carried forward as current validation.

AI assistance was used to develop and test these changes. Independent review has not been completed.

@swarnendusahu10-dotcom

Copy link
Copy Markdown
Contributor

Hi @Kulraj69! Great catch on cleaning up the thread view when a parent message gets deleted.

A couple of observations when testing locally:

  1. Test Failure in src/index.test.js: Running Jest in packages/react currently fails on src/index.test.js with:
    TypeError: (0 , _uiKit.parseGeneratedUiConfigurations) is not a function at EmbeddedChat.js:262.
    @embeddedchat/ui-kit needs to be mocked alongside the other dependencies in index.test.js so Jest can resolve it under the test environment.
  2. Missing test script: packages/react/package.json is missing the "test": "jest" script entry, so running standard test commands in the package currently fails.
  3. UX Note: When the thread automatically closes while a user is actively viewing it or typing a reply, it closes abruptly. Showing a brief toast notification indicating that the thread's parent message was deleted would provide clearer context to the user.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Thread UI remains open after parent message is deleted (State Leak)

2 participants