Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(mothership): guard sendNow against double-click duplicate sends
  • Loading branch information
waleedlatif1 committed Mar 14, 2026
commit d8ad8a457719b9981b9346dda2f36b5c3536cb88
13 changes: 10 additions & 3 deletions apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1006,13 +1006,20 @@ export function useChat(
[setMessageQueue]
)

const sendNowProcessingRef = useRef<string | null>(null)
const sendNow = useCallback(
async (id: string) => {
if (sendNowProcessingRef.current === id) return
const msg = messageQueueRef.current.find((m) => m.id === id)
if (!msg) return
await stopGeneration()
setMessageQueue((prev) => prev.filter((m) => m.id !== id))
await sendMessage(msg.content, msg.fileAttachments, msg.contexts)
sendNowProcessingRef.current = id
try {
await stopGeneration()
setMessageQueue((prev) => prev.filter((m) => m.id !== id))
await sendMessage(msg.content, msg.fileAttachments, msg.contexts)
} finally {
sendNowProcessingRef.current = null
}
},
[stopGeneration, sendMessage, setMessageQueue]
)
Comment thread
waleedlatif1 marked this conversation as resolved.
Expand Down
Loading