fixed double message the second, fixed no own message from diagnotic to aria
This commit is contained in:
@@ -204,8 +204,22 @@ const ChatScreen: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eigene Nachrichten ignorieren (werden lokal hinzugefuegt)
|
// Eigene App-Nachrichten ignorieren (werden lokal hinzugefuegt)
|
||||||
if (sender === 'user' || sender === 'diagnostic') return;
|
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 text = (message.payload.text as string) || '';
|
||||||
const ts = message.timestamp;
|
const ts = message.timestamp;
|
||||||
|
|||||||
@@ -217,7 +217,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="chat-box-fs" class="chat-box" style="flex:1;max-height:none;min-height:0;overflow-y:auto;"></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;">
|
<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="testGatewayFS()">Gateway senden</button>
|
||||||
<button class="btn" onclick="testRVSFS()">Via RVS senden</button>
|
<button class="btn" onclick="testRVSFS()">Via RVS senden</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -519,7 +519,9 @@
|
|||||||
if (msg.type === 'rvs_chat') {
|
if (msg.type === 'rvs_chat') {
|
||||||
const p = msg.msg.payload || {};
|
const p = msg.msg.payload || {};
|
||||||
const sender = p.sender || '?';
|
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})`;
|
const label = sender === 'stt' ? '\uD83C\uDFA4 Spracheingabe' : `via RVS (${sender})`;
|
||||||
addChat(chatType, p.text || '?', label);
|
addChat(chatType, p.text || '?', label);
|
||||||
return;
|
return;
|
||||||
@@ -997,7 +999,7 @@
|
|||||||
|
|
||||||
// Enter-Taste sendet via Gateway
|
// Enter-Taste sendet via Gateway
|
||||||
document.getElementById('chat-input').addEventListener('keydown', (e) => {
|
document.getElementById('chat-input').addEventListener('keydown', (e) => {
|
||||||
if (e.key === 'Enter') testGateway();
|
if (e.key === 'Enter') testRVS();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Escape schliesst Lightbox
|
// Escape schliesst Lightbox
|
||||||
|
|||||||
@@ -412,6 +412,15 @@ function sendToGateway(text, isPipeline) {
|
|||||||
gatewayWs.send(payload);
|
gatewayWs.send(payload);
|
||||||
log("info", "gateway", `chat.send [${reqId}]: "${text}"`);
|
log("info", "gateway", `chat.send [${reqId}]: "${text}"`);
|
||||||
if (isPipeline) plog(`chat.send [${reqId}] an Gateway gesendet — warte auf ACK...`);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user