Self-hosted AI workspace.
Python
fix(sessions): retry resumeStream in poll loop when chatModule loads late
Giuseppe8664d3452435
diff --git a/static/js/sessions.js b/static/js/sessions.jsindex 23310d36c..15dfde08a 100644--- a/static/js/sessions.js+++ b/static/js/sessions.js@@ -2184,6 +2184,10 @@ async function _checkServerStream(sessionId) {box.appendChild(holder);uiModule.scrollHistory();+ // sessions.js executes before chat.js in module order, so window.chatModule+ // may not be set yet when _checkServerStream first runs. Retry resumeStream+ // on the first poll tick where it becomes available.+ let _resumeRetried = false;const pollId = setInterval(async () => {if (getCurrentSessionId() !== sessionId) {clearInterval(pollId);@@ -2191,6 +2195,16 @@ async function _checkServerStream(sessionId) {if (holder.parentNode) holder.remove();return;}+ if (!_resumeRetried && window.chatModule && window.chatModule.resumeStream) {+ _resumeRetried = true;+ const attached = await window.chatModule.resumeStream(sessionId);+ if (attached) {+ clearInterval(pollId);+ spinner.destroy();+ if (holder.parentNode) holder.remove();+ return;+ }+ }try {const r = await fetch(`${API_BASE}/api/chat/stream_status/${sessionId}`);if (!r.ok || (await r.json()).status !== 'streaming') {