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:
@@ -397,17 +397,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testGateway() {
|
function testGateway() {
|
||||||
const text = document.getElementById('chat-input').value.trim();
|
const input = document.getElementById('chat-input');
|
||||||
|
const text = input.value.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
addChat('sent', text, 'Gateway direkt');
|
addChat('sent', text, 'Gateway direkt');
|
||||||
send({ action: 'test_gateway', text });
|
send({ action: 'test_gateway', text });
|
||||||
|
input.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRVS() {
|
function testRVS() {
|
||||||
const text = document.getElementById('chat-input').value.trim();
|
const input = document.getElementById('chat-input');
|
||||||
|
const text = input.value.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
addChat('sent', text, 'via RVS');
|
addChat('sent', text, 'via RVS');
|
||||||
send({ action: 'test_rvs', text });
|
send({ action: 'test_rvs', text });
|
||||||
|
input.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testProxyBtn() {
|
function testProxyBtn() {
|
||||||
|
|||||||
@@ -280,6 +280,9 @@ function extractChatText(payload) {
|
|||||||
} catch { return ""; }
|
} catch { return ""; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deduplizierung: nur ein chat_final pro runId broadcasten
|
||||||
|
const seenFinalRuns = new Set();
|
||||||
|
|
||||||
function handleGatewayMessage(msg) {
|
function handleGatewayMessage(msg) {
|
||||||
if (msg.type === "res") {
|
if (msg.type === "res") {
|
||||||
const status = msg.ok ? "OK" : `FEHLER: ${JSON.stringify(msg.error).slice(0, 100)}`;
|
const status = msg.ok ? "OK" : `FEHLER: ${JSON.stringify(msg.error).slice(0, 100)}`;
|
||||||
@@ -313,6 +316,9 @@ function handleGatewayMessage(msg) {
|
|||||||
const text = extractChatText(payload);
|
const text = extractChatText(payload);
|
||||||
|
|
||||||
if (state === "final") {
|
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)}"`);
|
log("info", "gateway", `ANTWORT: "${text.slice(0, 200)}"`);
|
||||||
if (pipelineActive) pipelineEnd(true, `"${text.slice(0, 120)}"`);
|
if (pipelineActive) pipelineEnd(true, `"${text.slice(0, 120)}"`);
|
||||||
broadcast({ type: "chat_final", text, payload });
|
broadcast({ type: "chat_final", text, payload });
|
||||||
@@ -343,6 +349,9 @@ function handleGatewayMessage(msg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event === "chat:final") {
|
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 || "";
|
const text = extractChatText(payload) || payload.text || "";
|
||||||
log("info", "gateway", `ANTWORT: "${text.slice(0, 200)}"`);
|
log("info", "gateway", `ANTWORT: "${text.slice(0, 200)}"`);
|
||||||
if (pipelineActive) pipelineEnd(true, `"${text.slice(0, 120)}"`);
|
if (pipelineActive) pipelineEnd(true, `"${text.slice(0, 120)}"`);
|
||||||
|
|||||||
Reference in New Issue
Block a user