Self-hosted AI workspace.
Python
Chat: fix mode-tag breakage — toggleState wasn't in scope at those sites
pewdiepie-archdaemon793ad88fe1da
diff --git a/static/js/chat.js b/static/js/chat.jsindex 12df53973..802fedca5 100644--- a/static/js/chat.js+++ b/static/js/chat.js@@ -630,7 +630,12 @@ import { wireArrowUpRecall, getLastUserMessageFromChatHistory } from './composerlet _userMsgEl = null;// Capture which mode the user picked at send time so the message// header can show "Chat" or "Agent" next to the timestamp.- const _sendMode = (toggleState.mode || 'chat') === 'agent' ? 'agent' : 'chat';+ // toggleState is declared later in this function — load fresh here.+ let _sendMode = 'chat';+ try {+ const _ts = Storage.loadToggleState();+ if ((_ts.mode || 'chat') === 'agent') _sendMode = 'agent';+ } catch (_) {}if (!skipBubble) {const _userMeta = { mode: _sendMode };if (_pendingAttachInfo) _userMeta.attachments = _pendingAttachInfo;@@ -3429,8 +3434,12 @@ import { wireArrowUpRecall, getLastUserMessageFromChatHistory } from './composerconst model = meta && meta.model;const meta_ = metricsData ? Object.assign({ model }, metricsData) : { model };// Carry the send-time mode through so the assistant header gets- // the same Chat/Agent tag next to its timestamp.- meta_.mode = (toggleState.mode || 'chat') === 'agent' ? 'agent' : 'chat';+ // the same Chat/Agent tag next to its timestamp. toggleState+ // isn't in scope here — read fresh.+ try {+ const _ts = Storage.loadToggleState();+ meta_.mode = ((_ts.mode || 'chat') === 'agent') ? 'agent' : 'chat';+ } catch (_) {}chatRenderer.addMessage('assistant', roundText, model, meta_);uiModule.scrollHistory();return true;