Description
setCurrentChat optimistically writes the whole chat object (a Record with workspace/dashboard/chat slots) into currentChat[page] instead of the ChatVO at chat[page], then fetches the detail and overwrites currentChat[page] in .then(). There is no .catch(): if the detail fetch rejects, currentChat[page] keeps the wrong-shape whole-chat Record, so readers of currentChat[page].id / .title / .chatDetails (e.g. the chat menu list) see undefined → blank title and empty list until the user picks a chat whose fetch succeeds. The wrong-shape set is also published to subscribers before the async resolves.
Location
chat2db-community-client/src/store/chat/slices/common/action.ts:150-169
if (chat[page]?.id) {
const { id } = chat[page];
set({ currentChat: { ...currentChat, [page]: chat } }); // ← whole `chat`, should be chat[page]
return chatService.getChatDetailById({ pageSize: 5, id: id! })
.then((res) => { if (res) { set({ currentChat: { ...currentChat, [page]: res } }); ... } }); // ← no .catch
}
The else branch (line 171) correctly uses chat[page].
Impact
Fetch failure leaves a wrong-shape Record in currentChat[page]; chat title blank, list empty until next successful fetch.
Suggested fix
Set [page]: chat[page] (not chat), and add a .catch() that restores the slot to chat[page] and clears chat details.
Related existing
None. #2346 (rename leaves stale top-level metadata) is a different path/mechanism.
Description
setCurrentChatoptimistically writes the wholechatobject (a Record withworkspace/dashboard/chatslots) intocurrentChat[page]instead of theChatVOatchat[page], then fetches the detail and overwritescurrentChat[page]in.then(). There is no.catch(): if the detail fetch rejects,currentChat[page]keeps the wrong-shape whole-chatRecord, so readers ofcurrentChat[page].id/.title/.chatDetails(e.g. the chat menu list) seeundefined→ blank title and empty list until the user picks a chat whose fetch succeeds. The wrong-shapesetis also published to subscribers before the async resolves.Location
chat2db-community-client/src/store/chat/slices/common/action.ts:150-169The
elsebranch (line 171) correctly useschat[page].Impact
Fetch failure leaves a wrong-shape Record in
currentChat[page]; chat title blank, list empty until next successful fetch.Suggested fix
Set
[page]: chat[page](notchat), and add a.catch()that restores the slot tochat[page]and clears chat details.Related existing
None. #2346 (rename leaves stale top-level metadata) is a different path/mechanism.