diff --git a/tools/server/public_simplechat/docs/changelog.md b/tools/server/public_simplechat/docs/changelog.md index b2a40d8a60..e85b9e39da 100644 --- a/tools/server/public_simplechat/docs/changelog.md +++ b/tools/server/public_simplechat/docs/changelog.md @@ -307,6 +307,11 @@ Chat Session specific settings * tables, fenced code blocks, blockquotes * User given control to enable markdown implicitly at a session level, or explicitly set wrt individual msgs. * Rename fetch_web_url_raw to fetch_url_raw, avoids confusion and matchs semantic of access to local and web. +* Now external_ai specific special chat session's and inturn external ai tool call's ai live response stream + is visible in the chat session which triggered external ai, only till one gets respose or the tool call times + out. In turn if the tool call times out, one can send the timeout message as the response to the tool call + or what ever they see fit. Parallely, they can always look into the external ai specific special chat session + tab to see the ai response live stream and the progress wrt the tool call that timed out. ## ToDo diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 9594cf52cb..1c782b60f4 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -537,6 +537,8 @@ class ELDivStream { }); elDiv.appendChild(elDivData) this.divData = elDivData + /** @type {string | undefined} */ + this.styleDisplay = ui.ss_get(0, '.chat-message', 'display') } /** @@ -545,6 +547,9 @@ class ELDivStream { show() { this.div.hidden = false this.div.style.visibility = "visible" + if (this.styleDisplay) { + this.div.style.display = this.styleDisplay + } } /** @@ -556,6 +561,7 @@ class ELDivStream { this.divData.replaceChildren() this.div.hidden = true this.div.style.visibility = "collapse" + this.div.style.display = "none" } } @@ -1621,6 +1627,7 @@ class MultiChatUI { this.elDivChat.replaceChildren(); this.ui_userinput_reset() this.elDivStreams[chatId]?.clear() + this.elDivStreams[AI_TC_SESSIONNAME].clear() } if (bShowOwnDivStream) { this.elDivStreams[chatId]?.show() @@ -1862,6 +1869,9 @@ class MultiChatUI { this.elPopoverChatMsg.addEventListener('beforetoggle', (tev)=>{ let chatSession = this.simpleChats[this.curChatId] let index = chatSession.get_chatmessage_index(this.uniqIdChatMsgPO) + if (index == -1) { + return + } let chat = chatSession.xchat[index] if (chat.ns.has_content()) { this.elPopoverChatMsgFormatSelect.value = chat.textFormat @@ -2021,6 +2031,7 @@ class MultiChatUI { this.chatmsg_addsmart_uishow(chat.chatId, new ChatMessageEx(NSChatMessage.new_tool_response(Roles.ToolTemp, toolCallId, toolname, toolResult))) } else { this.timers.toolcallResponseTimeout = setTimeout(() => { + this.elDivStreams[AI_TC_SESSIONNAME].clear() this.me.toolsMgr.toolcallpending_found_cleared(chat.chatId, toolCallId, 'MCUI:HandleToolRun:TimeOut') this.chatmsg_addsmart_uishow(chat.chatId, new ChatMessageEx(NSChatMessage.new_tool_response(Roles.ToolTemp, toolCallId, toolname, `Tool/Function call ${toolname} taking too much time, aborting...`))) }, chat.cfg.tools.toolCallResponseTimeoutMS) diff --git a/tools/server/public_simplechat/ui.mjs b/tools/server/public_simplechat/ui.mjs index 13eefb4976..69308ab7fa 100644 --- a/tools/server/public_simplechat/ui.mjs +++ b/tools/server/public_simplechat/ui.mjs @@ -374,3 +374,24 @@ export function remove_els(sSelectorsTemplate) { el?.remove() } } + + +/** + * Get value of specified property belonging to specified css rule and stylesheet. + * @param {number} ssIndex + * @param {string} selectorText + * @param {string} property + */ +export function ss_get(ssIndex, selectorText, property) { + for (const rule of document.styleSheets[ssIndex].cssRules) { + if (rule.constructor.name == "CSSStyleRule") { + let sr = /** @type {CSSStyleRule} */(rule) + if (sr.selectorText.trim() != selectorText) { + continue + } + // @ts-ignore + return sr.style[property] + } + } + return undefined +}