fix: Streaming-Navigation-Bugs (doppelte Messages, client_disconnected), Tool-Result ohne Truncation
- _chatAbandoned-Flag statt AbortController: Backend-Stream läuft bei Navigation weiter, Frontend ignoriert Events - stopHistoryPolling() während Streaming-Poll aktiv, verhindert parallele Polls - _pollLock in pollHistory() gegen Race-Conditions bei gleichzeitigen Poll-Aufrufen - Tool-Result truncate(300) im Live-Chat entfernt, in History beibehalten - Dashboard Badge-Styling verfeinert
This commit is contained in:
1 parent
6f800e2d50
commit
7c0e5d180a
5 files changed
+30
-7
No files matched your search
+8
-1
@@ -33,6 +33,7 @@ let isStreaming = false;
|
||||
let pendingFiles = []; // [{ name, type, base64 }]
|
||||
let pendingRefs = []; // [{ path, from, to }] - Workspace-Dateireferenzen
|
||||
let _lastDoneChainData = null; // Chain-Daten vom letzten done-Event
|
||||
let _chatAbandoned = false; // true wenn User weg-navigiert während Stream läuft
|
||||
|
||||
async function clearChat() {
|
||||
const archive = await apiArchive(getCurrentSessionId());
|
||||
@@ -102,6 +103,8 @@ async function sendMessage() {
|
||||
let fullText = '';
|
||||
let currentToolBox = null;
|
||||
|
||||
_chatAbandoned = false;
|
||||
|
||||
try {
|
||||
const resp = await apiChat(messages, getCurrentSessionId());
|
||||
const reader = resp.body.getReader();
|
||||
@@ -111,7 +114,7 @@ async function sendMessage() {
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
if (done || _chatAbandoned) break;
|
||||
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
const lines = buffer.split('\n');
|
||||
@@ -184,6 +187,8 @@ async function sendMessage() {
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// Bei Navigation nichts tun – der neue Page-Init übernimmt
|
||||
if (_chatAbandoned) return;
|
||||
endStreamBubble();
|
||||
// Prüfen ob Backend noch streamt (z.B. bei Netzwerkfehler)
|
||||
try {
|
||||
@@ -197,6 +202,8 @@ async function sendMessage() {
|
||||
} catch (_) {}
|
||||
addErrorBubble('Netzwerk-Fehler: ' + e.message);
|
||||
} finally {
|
||||
// Bei Navigation nichts aufräumen – der neue Page-Init übernimmt
|
||||
if (_chatAbandoned) return;
|
||||
if (!isStreaming || !_streamingPollInterval) {
|
||||
btn.disabled = false;
|
||||
isStreaming = false;
|
||||
|
||||
Reference in new issue
Block a user