Skip to content

Commit 8bc1092

Browse files
committed
Fix queue
1 parent af06c4f commit 8bc1092

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/hooks/use-checkpoint-management.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export function useCheckpointManagement(
9494

9595
setShowRestoreConfirmation(false)
9696
onRevertModeChange?.(false)
97-
onEditModeChange?.(true)
9897

9998
logger.info('Checkpoint reverted and removed from message', {
10099
messageId: message.id,
@@ -108,15 +107,7 @@ export function useCheckpointManagement(
108107
setIsReverting(false)
109108
}
110109
}
111-
}, [
112-
messageCheckpoints,
113-
revertToCheckpoint,
114-
message.id,
115-
messages,
116-
currentChat,
117-
onRevertModeChange,
118-
onEditModeChange,
119-
])
110+
}, [messageCheckpoints, revertToCheckpoint, message.id, messages, currentChat, onRevertModeChange])
120111

121112
/**
122113
* Cancels checkpoint revert
@@ -176,6 +167,7 @@ export function useCheckpointManagement(
176167
fileAttachments: fileAttachments || message.fileAttachments,
177168
contexts: contexts || (message as any).contexts,
178169
messageId: message.id,
170+
queueIfBusy: false,
179171
})
180172
}
181173
pendingEditRef.current = null
@@ -219,6 +211,7 @@ export function useCheckpointManagement(
219211
fileAttachments: fileAttachments || message.fileAttachments,
220212
contexts: contexts || (message as any).contexts,
221213
messageId: message.id,
214+
queueIfBusy: false,
222215
})
223216
}
224217
pendingEditRef.current = null

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/hooks/use-message-editing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export function useMessageEditing(props: UseMessageEditingProps) {
166166
fileAttachments: fileAttachments || message.fileAttachments,
167167
contexts: contexts || (message as any).contexts,
168168
messageId: message.id,
169+
queueIfBusy: false,
169170
})
170171
}
171172
},

apps/sim/stores/panel/copilot/store.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,16 +2562,18 @@ export const useCopilotStore = create<CopilotStore>()(
25622562
fileAttachments,
25632563
contexts,
25642564
messageId,
2565+
queueIfBusy = true,
25652566
} = options as {
25662567
stream?: boolean
25672568
fileAttachments?: MessageFileAttachment[]
25682569
contexts?: ChatContext[]
25692570
messageId?: string
2571+
queueIfBusy?: boolean
25702572
}
25712573

25722574
if (!workflowId) return
25732575

2574-
// If already sending a message, queue this one instead
2576+
// If already sending a message, queue this one instead unless bypassing queue
25752577
if (isSendingMessage && !activeAbortController) {
25762578
logger.warn('[Copilot] sendMessage: stale sending state detected, clearing', {
25772579
originalMessageId: messageId,
@@ -2583,12 +2585,15 @@ export const useCopilotStore = create<CopilotStore>()(
25832585
})
25842586
set({ isSendingMessage: false, abortController: null })
25852587
} else if (isSendingMessage) {
2586-
get().addToQueue(message, { fileAttachments, contexts, messageId })
2587-
logger.info('[Copilot] Message queued (already sending)', {
2588-
queueLength: get().messageQueue.length + 1,
2589-
originalMessageId: messageId,
2590-
})
2591-
return
2588+
if (queueIfBusy) {
2589+
get().addToQueue(message, { fileAttachments, contexts, messageId })
2590+
logger.info('[Copilot] Message queued (already sending)', {
2591+
queueLength: get().messageQueue.length + 1,
2592+
originalMessageId: messageId,
2593+
})
2594+
return
2595+
}
2596+
get().abortMessage({ suppressContinueOption: true })
25922597
}
25932598

25942599
const nextAbortController = new AbortController()

apps/sim/stores/panel/copilot/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export interface CopilotActions {
179179
fileAttachments?: MessageFileAttachment[]
180180
contexts?: ChatContext[]
181181
messageId?: string
182+
queueIfBusy?: boolean
182183
}
183184
) => Promise<void>
184185
abortMessage: (options?: { suppressContinueOption?: boolean }) => void

0 commit comments

Comments
 (0)