fix(chat): isolate pending flows and cancel stale requests

This commit is contained in:
2026-07-17 19:22:01 +08:00
parent 2fc312b5c7
commit 8bb1e21886
27 changed files with 501 additions and 92 deletions
@@ -42,12 +42,21 @@ export interface UnlockPrivateMessageInput {
clientLockId?: string;
}
export interface ChatRequestOptions {
signal?: AbortSignal;
}
export interface ChatSendOptions extends ChatRequestOptions {
image?: string;
useWebSocket?: boolean;
}
export interface IChatRepository {
/** 发送一条消息。 */
sendMessage(
characterId: string,
message: string,
options?: { image?: string; useWebSocket?: boolean },
options?: ChatSendOptions,
): Promise<Result<ChatSendResponse>>;
/** 获取聊天历史,分页参数默认 limit=50, offset=0。 */
@@ -55,15 +64,20 @@ export interface IChatRepository {
characterId: string,
limit?: number,
offset?: number,
options?: ChatRequestOptions,
): Promise<Result<ChatHistoryResponse>>;
/** 解锁单条历史付费 / 私密消息。 */
unlockPrivateMessage(
input: UnlockPrivateMessageInput,
options?: ChatRequestOptions,
): Promise<Result<UnlockPrivateResponse>>;
/** 一键解锁历史锁定消息。 */
unlockHistory(characterId: string): Promise<Result<UnlockHistoryResponse>>;
unlockHistory(
characterId: string,
options?: ChatRequestOptions,
): Promise<Result<UnlockHistoryResponse>>;
/** 把本地缓存中的单条锁定消息标记为已解锁。 */
markPrivateMessageUnlockedInLocal(