feat(chat): send idempotent client message ids
Docker Image / Build and Push Docker Image (push) Successful in 2m18s

This commit is contained in:
Codex
2026-07-27 10:58:51 +08:00
parent 0d5b5c17fa
commit bb1f0d225c
6 changed files with 92 additions and 2 deletions
+6 -2
View File
@@ -18,6 +18,7 @@ import {
type ChatAction,
type CommercialAction,
} from "@/data/schemas/chat";
import { createClientMessageId } from "@/lib/chat/client_message_id";
const log = new Logger("ChatWebSocket");
const RECONNECT_DELAY_MS = 3000;
@@ -101,8 +102,11 @@ export class ChatWebSocket {
}
}
sendMessage(content: string): boolean {
const payload = { type: "message", content };
sendMessage(
content: string,
clientMessageId: string = createClientMessageId(),
): boolean {
const payload = { type: "message", content, clientMessageId };
if (!this.isConnected) {
logWebSocketWarn("→ WS SEND SKIPPED: socket is not open", payload);
return false;