fix(chat): track replies by queued batch

This commit is contained in:
2026-06-26 11:42:17 +08:00
parent ceaa3ebfcf
commit 58236453ed
6 changed files with 126 additions and 34 deletions
+13 -4
View File
@@ -111,7 +111,7 @@ export const chatMachine = setup({
contentLength: event.content.length,
contentPreview: event.content.slice(0, 50),
quotaMode: "server controlled",
isReplyingAI: true,
isReplyingAI: context.isReplyingAI,
});
return {
@@ -123,7 +123,6 @@ export const chatMachine = setup({
date: today,
},
],
...beginPendingReply(context),
upgradePromptVisible: false,
upgradeReason: null,
upgradeHint: null,
@@ -139,7 +138,7 @@ export const chatMachine = setup({
contentLength: event.content.length,
contentPreview: event.content.slice(0, 50),
wsConnected: context.wsConnected,
isReplyingAI: true,
isReplyingAI: context.isReplyingAI,
});
return {
@@ -151,7 +150,6 @@ export const chatMachine = setup({
date: today,
},
],
...beginPendingReply(context),
upgradePromptVisible: false,
upgradeReason: null,
upgradeHint: null,
@@ -261,6 +259,8 @@ export const chatMachine = setup({
return { messages, ...finishPendingReply(context) };
}),
markQueuedSendStarted: assign(({ context }) => beginPendingReply(context)),
applyQueuedHttpOutput: assign(({ context, event }) => {
if (event.type !== "ChatQueuedHttpDone") return {};
return applyHttpSendOutput(context, event.output);
@@ -423,6 +423,9 @@ export const chatMachine = setup({
target: "#chat.vipUserSession",
actions: "startUserSession",
},
ChatQueuedSendStarted: {
actions: "markQueuedSendStarted",
},
ChatQueuedHttpDone: {
actions: "applyQueuedHttpOutput",
},
@@ -533,6 +536,9 @@ export const chatMachine = setup({
target: "#chat.vipUserSession",
actions: "startUserSession",
},
ChatQueuedSendStarted: {
actions: "markQueuedSendStarted",
},
ChatQueuedHttpDone: {
actions: "applyQueuedHttpOutput",
},
@@ -666,6 +672,9 @@ export const chatMachine = setup({
ChatPaywallStatusReceived: { actions: "applyPaywallStatus" },
ChatWebSocketError: { actions: "appendSocketErrorMessage" },
ChatWebSocketConnected: { actions: "setWsConnected" },
ChatQueuedSendStarted: {
actions: "markQueuedSendStarted",
},
ChatQueuedHttpDone: {
actions: "applyQueuedHttpOutput",
},