feat(chat): migrate chat protocol to lock detail
This commit is contained in:
@@ -68,7 +68,7 @@ export const loadHistoryActor = fromPromise<{
|
||||
* HTTP 发送消息(一次发送 = 一次返回)
|
||||
* - 后端响应就是 AI 回复(`ChatSendResponse.reply: string`)
|
||||
* - 不再调 `getLocalMessages()`(多此一举)
|
||||
* - 返回完整 response + 可追加的 reply,方便处理后端 paywall blocked 响应
|
||||
* - 返回完整 response + 可追加的 reply,方便处理后端 lockDetail 响应
|
||||
*/
|
||||
export const sendMessageHttpActor = fromPromise<
|
||||
{ response: ChatSendResponse; reply: UiMessage | null },
|
||||
@@ -79,9 +79,13 @@ export const sendMessageHttpActor = fromPromise<
|
||||
log.error("[chat-machine] sendMessageHttpActor failed", { error: result.error });
|
||||
throw result.error;
|
||||
}
|
||||
const isDailyLimit =
|
||||
result.data.lockDetail.locked &&
|
||||
result.data.lockDetail.showUpgrade &&
|
||||
result.data.lockDetail.reason === "daily_limit";
|
||||
return {
|
||||
response: result.data,
|
||||
reply: result.data.blocked ? null : sendResponseToUiMessage(result.data),
|
||||
reply: isDailyLimit ? null : sendResponseToUiMessage(result.data),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -170,16 +174,13 @@ export const chatWebSocketActor = fromCallback<ChatEvent, { token: string }>(
|
||||
done: p.done,
|
||||
});
|
||||
};
|
||||
ws.onImage = (imageUrl) => {
|
||||
sendBack({ type: "ChatImageReceived", imageUrl });
|
||||
ws.onImage = (url) => {
|
||||
sendBack({ type: "ChatImageReceived", url });
|
||||
};
|
||||
ws.onPaywallStatus = (p) => {
|
||||
sendBack({
|
||||
type: "ChatPaywallStatusReceived",
|
||||
paywallTriggered: p.paywallTriggered,
|
||||
showUpgrade: p.showUpgrade,
|
||||
imageType: p.imageType,
|
||||
imageUrl: p.imageUrl,
|
||||
lockDetail: p,
|
||||
});
|
||||
};
|
||||
ws.onError = (msg) => {
|
||||
|
||||
Reference in New Issue
Block a user