feat(chat): sync multi-role backend APIs
This commit is contained in:
@@ -76,16 +76,30 @@ const appendUserMessageAction = historyMachineSetup.assign(
|
||||
);
|
||||
|
||||
const appendQueuedSendErrorMessageAction = historyMachineSetup.assign(
|
||||
({ context }) => {
|
||||
({ context, event }) => {
|
||||
if (event.type !== "ChatQueuedSendError") return {};
|
||||
const characterErrorCode = event.characterErrorCode ?? null;
|
||||
const unavailable = characterErrorCode === "CHARACTER_STATE_UNAVAILABLE";
|
||||
const messages = [
|
||||
...context.messages,
|
||||
{
|
||||
content: "Something went wrong. Try sending again?",
|
||||
content: unavailable
|
||||
? "This character is temporarily unavailable. Please try again shortly."
|
||||
: "Something went wrong. Try sending again?",
|
||||
isFromAI: true,
|
||||
date: todayString(),
|
||||
},
|
||||
];
|
||||
return { messages, ...finishPendingReply(context) };
|
||||
return {
|
||||
messages,
|
||||
...finishPendingReply(context),
|
||||
characterErrorCode,
|
||||
canSendMessage:
|
||||
characterErrorCode === "CHARACTER_DISABLED" ||
|
||||
characterErrorCode === "CHARACTER_NOT_FOUND"
|
||||
? false
|
||||
: context.canSendMessage,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user