@meistrari/chat-nuxt 4.10.0-rc.21 → 4.10.0-rc.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -623,8 +623,13 @@ async function dispatchMessage(outbound, files, resolvedAgentInputs) {
|
|
|
623
623
|
const executionSettings = { model: selectedModel.value, reasoningEffort: selectedReasoningEffort.value };
|
|
624
624
|
if (props.sendBlocked)
|
|
625
625
|
return false;
|
|
626
|
+
const requestedConversationId = activeConversationId.value;
|
|
627
|
+
if (requestedConversationId && currentConversation.value?.id !== requestedConversationId)
|
|
628
|
+
return null;
|
|
626
629
|
let claimedWakeSessionId;
|
|
627
630
|
const sent = await sendMessage(outbound, files.length > 0 ? files : void 0, resolvedAgentInputs, async (signal) => {
|
|
631
|
+
if (requestedConversationId && (activeConversationId.value !== requestedConversationId || currentConversation.value?.id !== requestedConversationId))
|
|
632
|
+
throw new Error("A conversa mudou. Abra o hist\xF3rico novamente.");
|
|
628
633
|
if (!activeConversationId.value || !currentConversation.value) {
|
|
629
634
|
const conversation2 = await createConversation({
|
|
630
635
|
...executionSettings,
|
|
@@ -640,12 +645,17 @@ async function dispatchMessage(outbound, files, resolvedAgentInputs) {
|
|
|
640
645
|
moveUnconfirmedDraft(conversation2.id);
|
|
641
646
|
}
|
|
642
647
|
const conversation = currentConversation.value;
|
|
643
|
-
if (!conversation)
|
|
648
|
+
if (!conversation || requestedConversationId && (activeConversationId.value !== requestedConversationId || conversation.id !== requestedConversationId))
|
|
644
649
|
throw new Error("Erro ao preparar conversa");
|
|
645
650
|
if (!agentWake || chatApi.conversationV2Enabled)
|
|
646
651
|
return { executionSettings };
|
|
652
|
+
const assertConversationStillOpen = () => {
|
|
653
|
+
if (activeConversationId.value !== conversation.id || currentConversation.value?.id !== conversation.id)
|
|
654
|
+
throw new Error("A conversa mudou. Abra o hist\xF3rico novamente.");
|
|
655
|
+
};
|
|
647
656
|
if (conversation.threadSessionId && resolvedFeatures.value.chatOutboundQueue) {
|
|
648
657
|
const wake = await agentWake.ensureReady(conversation.threadSessionId, executionSettings.model);
|
|
658
|
+
assertConversationStillOpen();
|
|
649
659
|
if (wake.status !== "ready") {
|
|
650
660
|
if (wake.wokenSandbox && !wake.wokenSandbox.rewakeable)
|
|
651
661
|
return { defer: true, executionSettings };
|
|
@@ -658,6 +668,7 @@ async function dispatchMessage(outbound, files, resolvedAgentInputs) {
|
|
|
658
668
|
if (agentWake.state.value === "idle")
|
|
659
669
|
await agentWake.wake(void 0, executionSettings.model);
|
|
660
670
|
}
|
|
671
|
+
assertConversationStillOpen();
|
|
661
672
|
claimedWakeSessionId = claimableWakeSessionId();
|
|
662
673
|
if (!conversation.threadSessionId && !claimedWakeSessionId)
|
|
663
674
|
throw new Error("N\xE3o foi poss\xEDvel acordar o agente. Tente novamente.");
|
|
@@ -510,6 +510,7 @@ export function useChat(options = {}, adapter = {}) {
|
|
|
510
510
|
};
|
|
511
511
|
let loadGeneration = 0;
|
|
512
512
|
const loadConversation = async (id) => {
|
|
513
|
+
const scope = chatScope.value;
|
|
513
514
|
if (chatApi.conversationV2Enabled) {
|
|
514
515
|
stopPolling();
|
|
515
516
|
directStream.disconnect();
|
|
@@ -523,8 +524,10 @@ export function useChat(options = {}, adapter = {}) {
|
|
|
523
524
|
chatApi.path(`/conversations/${id}`),
|
|
524
525
|
chatApi.withChatHeaders()
|
|
525
526
|
);
|
|
526
|
-
if (generation !== loadGeneration)
|
|
527
|
+
if (generation !== loadGeneration || scope !== chatScope.value)
|
|
527
528
|
return false;
|
|
529
|
+
if (data.id !== id)
|
|
530
|
+
throw new Error("Conversation binding mismatch");
|
|
528
531
|
options.onMessagesReceived?.({ conversationId: id, messages: data.messages });
|
|
529
532
|
currentConversation.value = data;
|
|
530
533
|
messages.value = data.messages;
|
|
@@ -546,9 +549,9 @@ export function useChat(options = {}, adapter = {}) {
|
|
|
546
549
|
}
|
|
547
550
|
return true;
|
|
548
551
|
} catch (err) {
|
|
549
|
-
|
|
550
|
-
if (generation !== loadGeneration)
|
|
552
|
+
if (generation !== loadGeneration || scope !== chatScope.value)
|
|
551
553
|
return false;
|
|
554
|
+
Sentry.captureException(err);
|
|
552
555
|
currentConversation.value = null;
|
|
553
556
|
messages.value = [];
|
|
554
557
|
const message = err instanceof Error ? err.message : "Erro ao carregar conversa";
|
|
@@ -861,6 +864,8 @@ export function useChat(options = {}, adapter = {}) {
|
|
|
861
864
|
void flushOutboundQueue();
|
|
862
865
|
});
|
|
863
866
|
const clearConversation = () => {
|
|
867
|
+
loadGeneration++;
|
|
868
|
+
loading.value = false;
|
|
864
869
|
const simpleSelection = pendingSimpleSelectionBuckets.value[chatScope.value];
|
|
865
870
|
if (simpleExecutionProfiles.value || simpleSelection?.model || simpleSelection?.reasoningEffort) {
|
|
866
871
|
delete pendingModelBuckets.value[chatScope.value];
|
|
@@ -1106,6 +1111,8 @@ export function useChat(options = {}, adapter = {}) {
|
|
|
1106
1111
|
}
|
|
1107
1112
|
});
|
|
1108
1113
|
onUnmounted(() => {
|
|
1114
|
+
loadGeneration++;
|
|
1115
|
+
gateController?.abort();
|
|
1109
1116
|
stopPolling();
|
|
1110
1117
|
});
|
|
1111
1118
|
return {
|