가드가 초안을 버리고 재생성할 때 draft_reset SSE를 보내 화면·음성 낭독에서 초안 제거(초안+재작성본 이중 낭독 수정)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5f7d4890ae
commit
7a39528d58
3 files changed
+21
No files matched your search
@@ -1525,6 +1525,12 @@ async function handleChat(
|
||||
// Always use streaming so text tokens appear in real-time. The streaming
|
||||
// handler collects tool_calls from chunks and returns them in the final
|
||||
// result, so tool-call rounds work correctly too.
|
||||
// 가드가 직전 초안을 버리고 재생성시킨 라운드(마지막 메시지가 user 넛지): 이미 스트리밍된 초안을 클라이언트가
|
||||
// 지우게 알린다. 안 그러면 음성 통화가 초안과 재작성본을 연달아 읽는다(2026-10-19 "같은 답을 반복").
|
||||
// 도구 라운드 뒤는 마지막 메시지가 tool이라 해당 없음.
|
||||
if (round > 0 && messages.length && (messages[messages.length - 1] as any)?.role === 'user') {
|
||||
try { sendSSE('draft_reset', {}); } catch {}
|
||||
}
|
||||
const generationPromise = ollama.chatWithThinkingStream(messages, 'executor', (token: string) => {
|
||||
try { sendSSE('token', { text: token }); } catch {}
|
||||
}, {
|
||||
|
||||
@@ -208,6 +208,11 @@ async function sendChat(queuedMessage = null) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'draft_reset': // 서버 가드가 직전 초안을 버렸다 — 화면·낭독에서도 지운다
|
||||
partialContent = '';
|
||||
if (window._voiceCallResetDraft) window._voiceCallResetDraft();
|
||||
break;
|
||||
|
||||
case 'token':
|
||||
case 'text_delta': {
|
||||
const token = event.text || event.content || event.delta || '';
|
||||
|
||||
@@ -667,6 +667,16 @@
|
||||
tableLines = [];
|
||||
};
|
||||
|
||||
// 서버 가드가 초안을 버렸을 때: 아직 안 읽은 초안은 지우고 재생 중인 초안은 끊는다.
|
||||
window._voiceCallResetDraft = function () {
|
||||
if (!active) return;
|
||||
spokenUpTo = 0; pendingTts = ''; spokenKeys.clear(); tableLines = []; ttsQueue = [];
|
||||
if (playerNode) playerNode.port.postMessage({ type: 'clear' });
|
||||
playbackActive = false;
|
||||
if (ws && ws.readyState === WebSocket.OPEN && currentTtsId) ws.send(JSON.stringify({ type: 'tts_cancel', id: currentTtsId }));
|
||||
ttsBusy = false; currentTtsId = null;
|
||||
};
|
||||
|
||||
// Hooked from app.js's SSE token handler — only acts while a call is active.
|
||||
window._voiceCallOnToken = function (fullPartialContent) {
|
||||
if (!active) return;
|
||||
|
||||
Reference in new issue
Block a user