Skip to content

Commit 098b9bf

Browse files
committed
fix(billing): resume held queued sends once Chat is allowed and keep Send now side-effect free
1 parent f26ae1b commit 098b9bf

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • apps/sim/app/workspace/[workspaceId]/home/hooks

‎apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5302,6 +5302,7 @@ export function useChat(
53025302
const msg = id === undefined ? queue?.[0] : queue?.find((queued) => queued.id === id)
53035303
if (!msg || queueState.editing[chatKey] === msg.id) return
53045304
if (queuedMessageDispatchIds.has(msg.id)) return
5305+
if (chatPlanRequired) return
53055306
/* Sent by hand, it still must not run a second turn: if the history shows it
53065307
accepted, it is already in the chat. A history that cannot be read does not
53075308
hold it back here; the user asked to send it, and the server deduplicates it
@@ -5373,6 +5374,7 @@ export function useChat(
53735374
})
53745375
},
53755376
[
5377+
chatPlanRequired,
53765378
dispatchQueuedMessage,
53775379
queryClient,
53785380
stopGeneration,
@@ -5463,7 +5465,7 @@ export function useChat(
54635465
const [sendRetryWakeup, setSendRetryWakeup] = useState(0)
54645466
useEffect(() => {
54655467
if (!scopeKey) return
5466-
if (messageQueue.length === 0 || queueHeadHeld) return
5468+
if (messageQueue.length === 0 || queueHeadHeld || chatPlanRequired) return
54675469
if (queueHeadNotBefore !== undefined && queueHeadNotBefore > Date.now()) {
54685470
const timer = setTimeout(
54695471
() => setSendRetryWakeup((wakeups) => wakeups + 1),
@@ -5482,6 +5484,7 @@ export function useChat(
54825484
scopeKey,
54835485
messageQueue.length,
54845486
queueHeadHeld,
5487+
chatPlanRequired,
54855488
queueHeadNotBefore,
54865489
sendRetryWakeup,
54875490
resolvedChatId,

0 commit comments

Comments
 (0)