fix: append messages locally on send, don't rely solely on WS
Release Desktop Apps / build-linux (push) Successful in 2m49s
Release Desktop Apps / build-windows (push) Successful in 17m47s
Release Desktop Apps / release (push) Successful in 9s

This commit is contained in:
2026-07-20 11:07:57 -04:00
parent 062bdfddc5
commit 478e90d305
2 changed files with 8 additions and 4 deletions
+4 -2
View File
@@ -135,12 +135,14 @@ export const useConversationStore = create<ConversationState>((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<ConversationMessage>(
`/conversations/${conversationId}/messages`,
{ content },
);
// ponytail: local append as fallback for WS MESSAGE_CREATE; remove if WS reliability improves
get().addMessage(message);
return message;
},
+4 -2
View File
@@ -169,12 +169,14 @@ export const useMessageStore = create<MessageState>((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<Message>(
`/channels/${channelId}/messages`,
body,
);
// ponytail: local append as fallback for WS MESSAGE_CREATE; remove if WS reliability improves
get().addMessage(message);
return message;
},