refactor(chat): remove guest history synchronization

This commit is contained in:
2026-07-20 14:02:39 +08:00
parent 1f7ab2be04
commit 4d1c85727a
17 changed files with 10 additions and 300 deletions
@@ -1,7 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import {
ChatSyncRequestSchema,
SendMessageRequestSchema,
UnlockHistoryRequestSchema,
UnlockPrivateRequestSchema,
@@ -74,30 +73,16 @@ describe("multi-character API contract", () => {
});
});
it("loads previews and syncs guest history", async () => {
it("loads chat previews", async () => {
const api = new ChatApi();
httpClientMock
.mockResolvedValueOnce({ success: true, data: { items: [] } })
.mockResolvedValueOnce({ success: true, data: {} });
httpClientMock.mockResolvedValueOnce({
success: true,
data: { items: [] },
});
await api.getPreviews();
const request = ChatSyncRequestSchema.parse({
characterId: CHARACTER_ID,
messages: [
{
role: "user",
content: "Hello",
timestamp: "2026-07-20T00:00:00.000Z",
},
],
});
await api.syncGuestHistory(request);
expect(httpClientMock).toHaveBeenNthCalledWith(1, "/api/chat/previews", {});
expect(httpClientMock).toHaveBeenNthCalledWith(2, "/api/chat/sync", {
method: "POST",
body: request,
});
expect(httpClientMock).toHaveBeenCalledWith("/api/chat/previews", {});
});
it("forwards request cancellation to the HTTP client", async () => {
+1 -2
View File
@@ -26,6 +26,5 @@
"reportUserInfo": { "method": "post", "path": "/api/data/report-user-info" },
"feedback": { "method": "post", "path": "/api/feedback" },
"characters": { "method": "get", "path": "/api/characters" },
"chatPreviews": { "method": "get", "path": "/api/chat/previews" },
"chatSync": { "method": "post", "path": "/api/chat/sync" }
"chatPreviews": { "method": "get", "path": "/api/chat/previews" }
}
-2
View File
@@ -104,6 +104,4 @@ export class ApiPath {
static readonly chatPreviews = apiContract.chatPreviews.path;
static readonly chatSync = apiContract.chatSync.path;
}
-12
View File
@@ -11,7 +11,6 @@ import {
ChatPreviewsResponseSchema,
ChatSendResponse,
ChatSendResponseSchema,
ChatSyncRequest,
SendMessageRequest,
UnlockHistoryRequest,
UnlockHistoryResponse,
@@ -67,17 +66,6 @@ export class ChatApi {
return ChatPreviewsResponseSchema.parse(unwrap(env));
}
async syncGuestHistory(
body: ChatSyncRequest,
options?: { signal?: AbortSignal },
): Promise<void> {
await httpClient<ApiEnvelope<unknown>>(ApiPath.chatSync, {
method: "POST",
body,
...(options?.signal ? { signal: options.signal } : {}),
}).then(unwrap);
}
/**
* 解锁单条历史付费 / 私密消息
*/