Zusammenfassung der Fixes:
Textfeld leeren — input.value = '' nach Gateway/RVS senden Duplikate verhindern — seenFinalRuns Set speichert runId für 60s, ignoriert wiederholte final Events mit gleicher runId
This commit is contained in:
parent
6964fdcae1
commit
dd23b6f352
|
|
@ -397,17 +397,21 @@
|
|||
}
|
||||
|
||||
function testGateway() {
|
||||
const text = document.getElementById('chat-input').value.trim();
|
||||
const input = document.getElementById('chat-input');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
addChat('sent', text, 'Gateway direkt');
|
||||
send({ action: 'test_gateway', text });
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
function testRVS() {
|
||||
const text = document.getElementById('chat-input').value.trim();
|
||||
const input = document.getElementById('chat-input');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
addChat('sent', text, 'via RVS');
|
||||
send({ action: 'test_rvs', text });
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
function testProxyBtn() {
|
||||
|
|
|
|||
|
|
@ -280,6 +280,9 @@ function extractChatText(payload) {
|
|||
} catch { return ""; }
|
||||
}
|
||||
|
||||
// Deduplizierung: nur ein chat_final pro runId broadcasten
|
||||
const seenFinalRuns = new Set();
|
||||
|
||||
function handleGatewayMessage(msg) {
|
||||
if (msg.type === "res") {
|
||||
const status = msg.ok ? "OK" : `FEHLER: ${JSON.stringify(msg.error).slice(0, 100)}`;
|
||||
|
|
@ -313,6 +316,9 @@ function handleGatewayMessage(msg) {
|
|||
const text = extractChatText(payload);
|
||||
|
||||
if (state === "final") {
|
||||
const runId = payload.runId || "";
|
||||
if (runId && seenFinalRuns.has(runId)) return; // Duplikat
|
||||
if (runId) { seenFinalRuns.add(runId); setTimeout(() => seenFinalRuns.delete(runId), 60000); }
|
||||
log("info", "gateway", `ANTWORT: "${text.slice(0, 200)}"`);
|
||||
if (pipelineActive) pipelineEnd(true, `"${text.slice(0, 120)}"`);
|
||||
broadcast({ type: "chat_final", text, payload });
|
||||
|
|
@ -343,6 +349,9 @@ function handleGatewayMessage(msg) {
|
|||
return;
|
||||
}
|
||||
if (event === "chat:final") {
|
||||
const runId = payload.runId || "";
|
||||
if (runId && seenFinalRuns.has(runId)) return; // Duplikat
|
||||
if (runId) { seenFinalRuns.add(runId); setTimeout(() => seenFinalRuns.delete(runId), 60000); }
|
||||
const text = extractChatText(payload) || payload.text || "";
|
||||
log("info", "gateway", `ANTWORT: "${text.slice(0, 200)}"`);
|
||||
if (pipelineActive) pipelineEnd(true, `"${text.slice(0, 120)}"`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue