You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace any with real types in the chat stores and broadcast payloads #272
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.
Other any types in workspaceSettingsStore, TChannelSettings, and channelPinnedMessagesStore.
Store structure and store names.
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.
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
14ab7f9c1shows:apps/webapp/src/stores/chat/chatroom.ts:9,:27—headingPath: Array<any>. Nothing reads it. The two breadcrumbs write it withupdateChatRoom, but render from their own state.chatroom.ts:15-16—replyMessageMemory?: anyandeditMessageMemory?: any. Nothing reads these two fields. The live reply and edit memory is kept per channel inworkspaceSettingsStore.chatroom.ts:18-19—editorInstance?: anyandeditorRef?: any. Nothing readseditorRef. The composer writes its hostHTMLDivElementthere and clears it on unmount.chatroom.ts:31,:35—value: anyinupdateChatRoomandsetOrUpdateChatRoom.chatroom.ts:106—get() as any.apps/webapp/src/stores/chat/emojiPickerStore.ts:13,:23,:29—selectedMessageand themessageargument of both setters. Theeditorfield (:15) and theeditorarguments (:24,:30) are alwaysnull, and nothing reads them.toggleEmojiPickerhas no caller.apps/webapp/src/types/stores.ts:30,:32andapps/webapp/src/stores/chat/workspaceSettingsStore.ts:17-18— the live reply and edit memory, and its two setters, areany. The readers already useComposerMessageMemory. Four setter calls pass aTMsgRow, which does not fit it:content,medias, anduser_detailsdiffer.apps/webapp/src/hooks/useBroadcastListener.ts:7,:15— the broadcast payload'smessage: anyanduser: any.Acceptance criteria
Editorfrom@tiptap/coreforeditorInstance,TMsgRowforselectedMessage, andComposerMessageMemoryfor the reply and edit memory. The broadcastusergets a named payload type. So doesmessage, unless Remove the unused typing map and the dead pin listener #273 removes the pin listener first.replyMessageMemory,editMessageMemory,editorRef, andheadingPath. TheheadingPathparameter ofsetChatRoomgoes with them.setOrUpdateChatRoomtypesvaluebykey, anddestroyChatRoomreadsget()with no cast.updateChatRoomis removed, because its only calls writeheadingPath.editorfield, its setter arguments, andtoggleEmojiPickerare removed.bun run typecheckpasses with no newanyand no newascasts.Agent Brief
Category: enhancement
Summary: Replace
anyin 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 pickereditorfield 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, andsetOrUpdateChatRoom.TChannelSettingsandComposerMessageMemory.useBroadcastListener.Out of scope
workspaceSettingsStore, tracked in Remove the unused typing map and the dead pin listener #273.anytypes inworkspaceSettingsStore,TChannelSettings, andchannelPinnedMessagesStore.Notes
A scratch typecheck shows that immer's
Drafttype rejects two writes inside asetcallback. One writes a TipTapEditor. The other is the key-typedstate.chatRoom[key] = value.apps/webapp/src/stores/history.ts:98uses anascast for theEditorcase, and criterion 5 bans a new one. Asetcall with a plain object compiles with no cast.