refactor(chat): wire sendMessageHttpActor for HTTP message sending and update response handling

This commit is contained in:
2026-06-12 11:45:46 +08:00
parent 38f060bbd8
commit a9938b8dae
3 changed files with 117 additions and 30 deletions
+15
View File
@@ -19,6 +19,8 @@ import { chatRepository } from "@/data/repositories/chat_repository";
import type { IChatRepository } from "@/data/repositories/interfaces";
import { ChatStorage } from "@/data/storage/chat/chat_storage";
import { AuthStorage } from "@/data/storage/auth/auth_storage";
import { ChatSendResponse } from "@/data/dto/chat/chat_send_response";
import { formatDate } from "@/utils/date";
import { Result } from "@/utils/result";
// ============================================================// Constants
@@ -52,6 +54,19 @@ export function localMessagesToUi(
}));
}
/**
* ChatSendResponse → UiMessage**纯函数**
* - 业务事实:后端响应**就是** AI 的回复
* - 用后端 `timestamp`**不**用本地 time)—— 多设备/时区**一致**
*/
export function sendResponseToUiMessage(response: ChatSendResponse): UiMessage {
return {
content: response.reply,
isFromAI: true,
date: formatDate(new Date(response.timestamp)),
};
}
// ============================================================// Result → number 映射
// ============================================================
/** 日配额 Result → number**纯函数** */