From ae03bb8363120f24f72c6d4579c36ea1091dec2a Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Sun, 8 Nov 2026 03:02:37 +0100 Subject: [PATCH] fix(chat): show the timeout message instead of an empty bubble (#6764) (#6768) _isAgent was a const inside the try block of handleChatSubmit, but the catch block reads it to pick the timeout message, so a client timeout threw a ReferenceError and left the reply bubble empty. Declare it next to the other catch-visible variables and assign it where it is computed. --- static/js/chat.js | 3 ++- tests/test_chat_timeout_message_static.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/test_chat_timeout_message_static.py diff --git a/static/js/chat.js b/static/js/chat.js index ba87066f1..01c4e8930 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -2588,6 +2588,7 @@ import { invalidateSettings } from './appConfig.js'; currentHolder = null; let abortCtrl = null; + let _isAgent = false; // read by the catch block's timeout message let streamingTTS = false; try { // Re-enable auto-scroll when user sends a message @@ -2985,7 +2986,7 @@ import { invalidateSettings } from './appConfig.js'; currentAbort = abortCtrl; const _tState = Storage.loadToggleState(); - const _isAgent = (_tState.mode || 'chat') === 'agent' || !!_tState.plan_mode || workspaceAgentIntent; + _isAgent = (_tState.mode || 'chat') === 'agent' || !!_tState.plan_mode || workspaceAgentIntent; // Timeout: 6 min for research and agent mode, 3 min otherwise const timeoutMs = el('research-toggle').checked || _isAgent ? RESEARCH_TIMEOUT_MS : DEFAULT_TIMEOUT_MS; diff --git a/tests/test_chat_timeout_message_static.py b/tests/test_chat_timeout_message_static.py new file mode 100644 index 000000000..20a0675ec --- /dev/null +++ b/tests/test_chat_timeout_message_static.py @@ -0,0 +1,13 @@ +from pathlib import Path +import re + + +ROOT = Path(__file__).resolve().parents[1] + + +def test_timeout_catch_can_read_is_agent(): + """The catch block reads _isAgent, so it must not be a try-scoped const (#6764).""" + src = (ROOT / "static/js/chat.js").read_text() + assert re.search(r"^\s*let _isAgent = false;", src, re.M) + assert not re.search(r"\bconst _isAgent\b", src) + assert re.search(r"^\s*_isAgent = \(_tState\.mode", src, re.M)