Skip to content

fix: restore message history loading#1234

Open
Aryan-Verma-999 wants to merge 1 commit intoRocketChat:developfrom
Aryan-Verma-999:fix/message-history-loading
Open

fix: restore message history loading#1234
Aryan-Verma-999 wants to merge 1 commit intoRocketChat:developfrom
Aryan-Verma-999:fix/message-history-loading

Conversation

@Aryan-Verma-999
Copy link

@Aryan-Verma-999 Aryan-Verma-999 commented Mar 22, 2026

fix: resolve 400 Bad Request and restore message loading for public channels

Acceptance Criteria fulfillment

  • Room-scoped state flags (isChannelPrivate, isRoomTeam, isChannelReadOnly, isChannelArchived) correctly reset when switching between channels.
  • API class dynamically resolves the correct REST endpoint (channels.messages vs groups.messages) based on actual room data.
  • Message history successfully loads for public channels (e.g., #general) even after opening a private room.

Fixes #1232

Description

Root Cause:
Previously, room state flags like isChannelPrivate in the Zustand store were only conditionally updated to true when encountering a private room (t === 'p'). Because they were never explicitly reset to false, switching to a public room later would falsely preserve the private state. This caused the EmbeddedChatApi to call the groups.* REST endpoints instead of channels.* for public rooms, resulting in a 400 Bad Request and failing to load message history.

Solution:

  1. Frontend State Fix: We now derive and explicitly set isChannelPrivate and other boolean flags dynamically (setIsChannelPrivate(res.room.t === 'p')) upon every room switch in ChatHeader.js

  2. API Layer Hardening: added a resolveRoomRoute() mechanism to EmbeddedChatApi.ts, which enforces resolution of the correct endpoint ("groups" vs "channels") based on API-level roomInfo caching rather than blindly trusting frontend booleans.

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-1234 after approval. Contributors are requested to replace <pr_number> with the actual PR number.

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: Message history fails to load

1 participant