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)}"`);