From dd23b6f3529eb7f0fe9601d6d46cbc738684efde Mon Sep 17 00:00:00 2001 From: duffyduck Date: Fri, 13 Mar 2026 10:33:58 +0100 Subject: [PATCH] Zusammenfassung der Fixes: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Textfeld leeren — input.value = '' nach Gateway/RVS senden Duplikate verhindern — seenFinalRuns Set speichert runId für 60s, ignoriert wiederholte final Events mit gleicher runId --- diagnostic/index.html | 8 ++++++-- diagnostic/server.js | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/diagnostic/index.html b/diagnostic/index.html index 85ab718..94c3490 100644 --- a/diagnostic/index.html +++ b/diagnostic/index.html @@ -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() { diff --git a/diagnostic/server.js b/diagnostic/server.js index cddc5ed..3b4fc12 100644 --- a/diagnostic/server.js +++ b/diagnostic/server.js @@ -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)}"`);