diff --git a/web/src/stores/conversation.ts b/web/src/stores/conversation.ts index b54dfde..eeaf73f 100644 --- a/web/src/stores/conversation.ts +++ b/web/src/stores/conversation.ts @@ -135,12 +135,14 @@ export const useConversationStore = create((set, get) => ({ }, sendMessage: async (conversationId, content) => { - // don't append here — WS MESSAGE_CREATE broadcast is the single source of truth. - // Appending in both places caused double messages when the WS event arrived before the HTTP response. + // Add locally so the message appears immediately even if WS lags. + // addMessage dedupes, so a late WS event won't double it. const message = await api.post( `/conversations/${conversationId}/messages`, { content }, ); + // ponytail: local append as fallback for WS MESSAGE_CREATE; remove if WS reliability improves + get().addMessage(message); return message; }, diff --git a/web/src/stores/message.ts b/web/src/stores/message.ts index 987486a..834dc05 100644 --- a/web/src/stores/message.ts +++ b/web/src/stores/message.ts @@ -169,12 +169,14 @@ export const useMessageStore = create((set, get) => ({ sendMessage: async (channelId, content, replyTo) => { const body: { content: string; reply_to?: string } = { content }; if (replyTo) body.reply_to = replyTo; - // ponytail: don't append here — WS MESSAGE_CREATE broadcast is the single source of truth. - // Appending in both places caused double messages when the WS event arrived before the HTTP response. + // Add locally so the message appears immediately even if WS lags. + // addMessage dedupes, so a late WS event won't double it. const message = await api.post( `/channels/${channelId}/messages`, body, ); + // ponytail: local append as fallback for WS MESSAGE_CREATE; remove if WS reliability improves + get().addMessage(message); return message; },