From 29f9abede9016692f4be89b06995b3da11053410 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sat, 29 Nov 2025 01:47:45 +0530 Subject: [PATCH] SimpleChatTCRV:UICleanup: Show own divstream mostly, ShowInfo all Always show all the info wihen show_info is called, inturn avoid the corresponding all info enable flag wrt show_info as well as chat_show. Now chat_show gives the option to its caller to enable showing of its own chat session divStream. This is in addition to the handle multipart response also calling corresponding divStream show. Previously chat_show would have not only cleared corresponding chat session's divStream contents but would have also hidden divStream. Now except for the clearChat case, in all other cases own divStream is unhidden, when chat_show is called. Without this, when a tool call takes too much time and inturn a chat session times out the tool call and inturn user switches between chat sessions, if the tool call was external_ai, then its related live ai response would no longer be visible in any of the chat sessions, including the external_ai special chat session, if the user had switched to this external_ai special chat session. But now in the external_ai special chat session, the live response will be visible. TODO: With this new semantic wrt chat_show, where a end user can always peek into a chat session's ai live stream response if any, as long as that chat session's ai server handshake is still active, So now After tool call timeout, which allows users to switch between sessions, it is better to disable the external ai live divStream in other chat sessions, when user switches into them. This ensures that 1. if user doesnt switch out of the chat session which triggered external_ai, for now the user can continue to see the ext ai live response stream. 2. Switching out of the chat session which triggered ext ai, will automatically disable viewing of external ai live response from all chat sessions except for the external ai's special chat session. IE I need to explicitly clear not just the own divStream, but also the external ai related divStream, which is appened to end of all chat session's UI. This will tidy up the usage flow and ui and avoid forcefully showing external ai tool call's ai live response in other chat sessions, which didnt trigger the ext ai tool call. And also in the chat session which triggered ext ai, it will stop showing if user exits out of that chat session. Same time user can always look at the ext ai live response stream in the special chat session corresponding to ext ai. --- tools/server/public_simplechat/simplechat.js | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 8b95eee128..9594cf52cb 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -539,11 +539,18 @@ class ELDivStream { this.divData = elDivData } + /** + * Unhide ElDivStream. + */ show() { this.div.hidden = false this.div.style.visibility = "visible" } + /** + * Clear contents from the immidiate Child (ie Role and Data) elements. + * Hide ElDivStream. + */ clear() { this.divRole.replaceChildren() this.divData.replaceChildren() @@ -1603,9 +1610,9 @@ class MultiChatUI { * * @param {string} chatId * @param {boolean} bClear - * @param {boolean} bShowInfoAll + * @param {boolean} bShowOwnDivStream */ - chat_show(chatId, bClear=true, bShowInfoAll=false) { + chat_show(chatId, bClear=true, bShowOwnDivStream=false) { if (chatId != this.curChatId) { return false } @@ -1615,6 +1622,9 @@ class MultiChatUI { this.ui_userinput_reset() this.elDivStreams[chatId]?.clear() } + if (bShowOwnDivStream) { + this.elDivStreams[chatId]?.show() + } this.ui_toolcallvalidated_as_needed(new ChatMessageEx()); this.elLastChatMessage = null let chatToShow = chat.recent_chat(chat.cfg.chatProps.iRecentUserMsgCnt); @@ -1634,7 +1644,7 @@ class MultiChatUI { if (bClear) { this.elDivChat.innerHTML = usage_note(chat.cfg.get_sRecentUserMsgCnt()); this.me.setup_load(this.elDivChat, chat); - chat.cfg.show_info(this.elDivChat, bShowInfoAll); + chat.cfg.show_info(this.elDivChat); this.me.show_title(this.elDivChat); } } @@ -1842,7 +1852,7 @@ class MultiChatUI { this.elInSystem.value = value.substring(0,value.length-1); let chat = this.simpleChats[this.curChatId]; chat.add_system_anytime(this.elInSystem.value, this.curChatId); - this.chat_show(chat.chatId) + this.chat_show(chat.chatId, true, true) ev.preventDefault(); } }); @@ -2226,13 +2236,9 @@ export class Config { /** * Show the configurable parameters info in the passed Div element. * @param {HTMLDivElement} elDiv - * @param {boolean} bAll */ - show_info(elDiv, bAll=false) { + show_info(elDiv) { let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "chatProps"]; - if (!bAll) { - props = [ "baseURL", "modelInfo", "tools", "chatProps" ]; - } let elInfo = document.createElement("div") elInfo.id = "DefaultInfo" elDiv.appendChild(elInfo)