agentgui 1.0.259 → 1.0.260
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/package.json +1 -1
- package/static/js/voice.js +12 -3
package/package.json
CHANGED
package/static/js/voice.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
var isLoadingHistory = false;
|
|
18
18
|
var _lastVoiceBlockText = null;
|
|
19
19
|
var _lastVoiceBlockTime = 0;
|
|
20
|
+
var _voiceBreakNext = false;
|
|
20
21
|
var selectedVoiceId = localStorage.getItem('voice-selected-id') || 'default';
|
|
21
22
|
var ttsAudioCache = new Map();
|
|
22
23
|
var TTS_CLIENT_CACHE_MAX = 50;
|
|
@@ -549,7 +550,7 @@
|
|
|
549
550
|
var emptyMsg = container.querySelector('.voice-empty');
|
|
550
551
|
if (emptyMsg) emptyMsg.remove();
|
|
551
552
|
var lastChild = container.lastElementChild;
|
|
552
|
-
if (!isUser && lastChild && lastChild.classList.contains('voice-block') && !lastChild.classList.contains('voice-block-user')) {
|
|
553
|
+
if (!isUser && !_voiceBreakNext && lastChild && lastChild.classList.contains('voice-block') && !lastChild.classList.contains('voice-block-user')) {
|
|
553
554
|
var contentSpan = lastChild.querySelector('.voice-block-content');
|
|
554
555
|
if (contentSpan) {
|
|
555
556
|
contentSpan.textContent += '\n' + stripHtml(text);
|
|
@@ -558,6 +559,7 @@
|
|
|
558
559
|
return lastChild;
|
|
559
560
|
}
|
|
560
561
|
}
|
|
562
|
+
_voiceBreakNext = false;
|
|
561
563
|
var div = document.createElement('div');
|
|
562
564
|
div.className = 'voice-block' + (isUser ? ' voice-block-user' : '');
|
|
563
565
|
if (isUser) {
|
|
@@ -666,6 +668,7 @@
|
|
|
666
668
|
if (data.conversationId && data.conversationId !== currentConversationId) return;
|
|
667
669
|
spokenChunks = new Set();
|
|
668
670
|
renderedSeqs = new Set();
|
|
671
|
+
_voiceBreakNext = false;
|
|
669
672
|
}
|
|
670
673
|
});
|
|
671
674
|
window.addEventListener('conversation-selected', function(e) {
|
|
@@ -682,7 +685,6 @@
|
|
|
682
685
|
function handleVoiceBlock(block, isNew) {
|
|
683
686
|
if (!block || !block.type) return;
|
|
684
687
|
if (block.type === 'text' && block.text) {
|
|
685
|
-
// Deduplicate: prevent rendering the same text block twice within 500ms
|
|
686
688
|
var now = Date.now();
|
|
687
689
|
if (_lastVoiceBlockText === block.text && (now - _lastVoiceBlockTime) < 500) {
|
|
688
690
|
return;
|
|
@@ -697,7 +699,10 @@
|
|
|
697
699
|
setTimeout(function() { div.classList.remove('speaking'); }, 2000);
|
|
698
700
|
}
|
|
699
701
|
} else if (block.type === 'result') {
|
|
702
|
+
_voiceBreakNext = true;
|
|
700
703
|
addVoiceResultBlock(block, isNew);
|
|
704
|
+
} else {
|
|
705
|
+
_voiceBreakNext = true;
|
|
701
706
|
}
|
|
702
707
|
}
|
|
703
708
|
|
|
@@ -705,9 +710,9 @@
|
|
|
705
710
|
var container = document.getElementById('voiceMessages');
|
|
706
711
|
if (!container) return;
|
|
707
712
|
container.innerHTML = '';
|
|
708
|
-
// Reset dedup state when loading a new conversation
|
|
709
713
|
_lastVoiceBlockText = null;
|
|
710
714
|
_lastVoiceBlockTime = 0;
|
|
715
|
+
_voiceBreakNext = false;
|
|
711
716
|
if (!conversationId) {
|
|
712
717
|
showVoiceEmpty(container);
|
|
713
718
|
return;
|
|
@@ -722,6 +727,7 @@
|
|
|
722
727
|
return;
|
|
723
728
|
}
|
|
724
729
|
var hasContent = false;
|
|
730
|
+
_voiceBreakNext = false;
|
|
725
731
|
data.chunks.forEach(function(chunk) {
|
|
726
732
|
if (chunk.sequence !== undefined) renderedSeqs.add(chunk.sequence);
|
|
727
733
|
var block = typeof chunk.data === 'string' ? JSON.parse(chunk.data) : chunk.data;
|
|
@@ -730,8 +736,11 @@
|
|
|
730
736
|
addVoiceBlock(block.text, false);
|
|
731
737
|
hasContent = true;
|
|
732
738
|
} else if (block.type === 'result') {
|
|
739
|
+
_voiceBreakNext = true;
|
|
733
740
|
addVoiceResultBlock(block, false);
|
|
734
741
|
hasContent = true;
|
|
742
|
+
} else {
|
|
743
|
+
_voiceBreakNext = true;
|
|
735
744
|
}
|
|
736
745
|
});
|
|
737
746
|
if (!hasContent) showVoiceEmpty(container);
|