fixed double message the second, fixed no own message from diagnotic to aria

This commit is contained in:
duffyduck 2026-03-29 14:24:13 +02:00
parent 6c7b631cb7
commit b7cecb2a8b
3 changed files with 30 additions and 5 deletions

View File

@ -204,8 +204,22 @@ const ChatScreen: React.FC = () => {
return;
}
// Eigene Nachrichten ignorieren (werden lokal hinzugefuegt)
if (sender === 'user' || sender === 'diagnostic') return;
// Eigene App-Nachrichten ignorieren (werden lokal hinzugefuegt)
if (sender === 'user') return;
// Diagnostic-Nachrichten als User-Nachricht anzeigen
if (sender === 'diagnostic') {
const diagText = (message.payload.text as string) || '';
if (diagText) {
setMessages(prev => [...prev, {
id: nextId(),
sender: 'user',
text: diagText,
timestamp: message.timestamp,
}]);
}
return;
}
const text = (message.payload.text as string) || '';
const ts = message.timestamp;

View File

@ -217,7 +217,7 @@
</div>
<div id="chat-box-fs" class="chat-box" style="flex:1;max-height:none;min-height:0;overflow-y:auto;"></div>
<div class="input-row" style="margin-top:8px;">
<input type="text" id="chat-input-fs" placeholder="Nachricht an ARIA..." onkeydown="if(event.key==='Enter'){testGatewayFS();event.preventDefault();}">
<input type="text" id="chat-input-fs" placeholder="Nachricht an ARIA..." onkeydown="if(event.key==='Enter'){testRVSFS();event.preventDefault();}">
<button class="btn" onclick="testGatewayFS()">Gateway senden</button>
<button class="btn" onclick="testRVSFS()">Via RVS senden</button>
</div>
@ -519,7 +519,9 @@
if (msg.type === 'rvs_chat') {
const p = msg.msg.payload || {};
const sender = p.sender || '?';
const chatType = (sender === 'aria') ? 'received' : 'sent';
// ARIA-Antworten kommen schon via Gateway (chat:final) — nicht nochmal via RVS anzeigen
if (sender === 'aria') return;
const chatType = 'sent';
const label = sender === 'stt' ? '\uD83C\uDFA4 Spracheingabe' : `via RVS (${sender})`;
addChat(chatType, p.text || '?', label);
return;
@ -997,7 +999,7 @@
// Enter-Taste sendet via Gateway
document.getElementById('chat-input').addEventListener('keydown', (e) => {
if (e.key === 'Enter') testGateway();
if (e.key === 'Enter') testRVS();
});
// Escape schliesst Lightbox

View File

@ -412,6 +412,15 @@ function sendToGateway(text, isPipeline) {
gatewayWs.send(payload);
log("info", "gateway", `chat.send [${reqId}]: "${text}"`);
if (isPipeline) plog(`chat.send [${reqId}] an Gateway gesendet — warte auf ACK...`);
// Nachricht auch an RVS senden damit die App sie sieht
if (rvsWs && rvsWs.readyState === WebSocket.OPEN) {
rvsWs.send(JSON.stringify({
type: "chat",
payload: { text, sender: "diagnostic" },
timestamp: Date.now(),
}));
}
return true;
}