Skip to content

Replace any with real types in the chat stores and broadcast payloads #272

Description

@HMarzban

Problem

Several chat store fields and two broadcast payload fields are typed any. TypeScript cannot catch a wrong editor, message, or user shape there. Some of these fields also have no reader.

A code trace on 14ab7f9c1 shows:

  • apps/webapp/src/stores/chat/chatroom.ts:9, :27 — headingPath: Array<any>. Nothing reads it. The two breadcrumbs write it with updateChatRoom, but render from their own state.
  • chatroom.ts:15-16 — replyMessageMemory?: any and editMessageMemory?: any. Nothing reads these two fields. The live reply and edit memory is kept per channel in workspaceSettingsStore.
  • chatroom.ts:18-19 — editorInstance?: any and editorRef?: any. Nothing reads editorRef. The composer writes its host HTMLDivElement there and clears it on unmount.
  • chatroom.ts:31, :35 — value: any in updateChatRoom and setOrUpdateChatRoom.
  • chatroom.ts:106 — get() as any.
  • apps/webapp/src/stores/chat/emojiPickerStore.ts:13, :23, :29 — selectedMessage and the message argument of both setters. The editor field (:15) and the editor arguments (:24, :30) are always null, and nothing reads them. toggleEmojiPicker has no caller.
  • apps/webapp/src/types/stores.ts:30, :32 and apps/webapp/src/stores/chat/workspaceSettingsStore.ts:17-18 — the live reply and edit memory, and its two setters, are any. The readers already use ComposerMessageMemory. Four setter calls pass a TMsgRow, which does not fit it: content, medias, and user_details differ.
  • apps/webapp/src/hooks/useBroadcastListener.ts:7, :15 — the broadcast payload's message: any and user: any.

Acceptance criteria

  • Each remaining field has a real type. Use Editor from @tiptap/core for editorInstance, TMsgRow for selectedMessage, and ComposerMessageMemory for the reply and edit memory. The broadcast user gets a named payload type. So does message, unless Remove the unused typing map and the dead pin listener #273 removes the pin listener first.
  • The four chatroom fields with no reader are removed: replyMessageMemory, editMessageMemory, editorRef, and headingPath. The headingPath parameter of setChatRoom goes with them.
  • setOrUpdateChatRoom types value by key, and destroyChatRoom reads get() with no cast. updateChatRoom is removed, because its only calls write headingPath.
  • The emoji picker editor field, its setter arguments, and toggleEmojiPicker are removed.
  • bun run typecheck passes with no new any and no new as casts.

Agent Brief

Category: enhancement
Summary: Replace any in the chat stores and the broadcast payloads with real types, and remove the fields that nothing reads.

Current behavior:
The chatroom slice, the emoji picker slice, the channel settings, and the broadcast payloads type editors, messages, and users as any. Four chatroom fields and the emoji picker editor field have no reader.

Desired behavior:
Every remaining field has a real type. The setter is typed by key. The fields with no reader are gone.

Key interfaces:

  • TChatRoom, setChatRoom, and setOrUpdateChatRoom.
  • The emoji picker slice state.
  • TChannelSettings and ComposerMessageMemory.
  • The broadcast payload types in useBroadcastListener.

Out of scope

Notes

A scratch typecheck shows that immer's Draft type rejects two writes inside a set callback. One writes a TipTap Editor. The other is the key-typed state.chatRoom[key] = value. apps/webapp/src/stores/history.ts:98 uses an as cast for the Editor case, and criterion 5 bans a new one. A set call with a plain object compiles with no cast.

Activity

  1. added a commit that references this issue on Sep 22, 2026
    6e59004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChatRelated to chat featuresRefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions