Refactor: consolidate fragmented Zustand stores using slice pattern

Open
#1,282 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sudorishabh is already working on this.

Since Apr 17, 2026.

  • #1283 by @sudorishabh — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript, react
Domain
frontend

Research direction

Start in the @embeddedchat/react package by locating sidebarStore, pinnedMessageStore, searchMessageStore, fileStore, and the auth and starred-message stores, then trace their imports and usages. Consolidate the specified state while preserving exclusive sidebar behavior, auth modal and loading behavior, and starred-message loading and rendering; verify that no removed store or hook usages remain.

Written by the indexing model from the issue text.

Description

Problem

The React package currently uses Zustand with multiple tiny stores (e.g. sidebarStore, pinnedMessageStore, searchMessageStore, fileStore, etc.). Many of these are single-boolean + setter stores and require importing/subscribing to many stores in central components.

This “store fragmentation” makes cross-panel logic harder (e.g. opening one panel should close others) and increases maintenance overhead.

Proposed improvement

Adopt a slice / consolidated-store approach in @embeddedchat/react:

  • Group all sidebar/panel visibility flags into a single store (useChatLayoutStore) with an openExclusivePanel(panelKey) API.
  • Group chat “meta/data” (starting with starred messages) into a single store (useChatDataStore).
  • Consolidate auth modal state (isLoginIn, isLoginModalOpen, isTotpModalOpen) into one auth store (useAuthStore).

Acceptance criteria

  • No remaining imports/usages of removed stores/hook.
  • Sidebar panel toggling remains exclusive and behavior-preserving.
  • Auth modals and login loading state work as before.
  • Starred messages continue to load and render correctly.
Dominant language
JavaScript
Stars
171
Forks
421
Avg merge
3d 6h
Merged PRs (30d)
4

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/EmbeddedChat

All issues in RocketChat/EmbeddedChat

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.