From afd6365ecc27caca6941e503c9148ea0a9cc9348 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Fri, 28 Nov 2025 20:12:17 +0530 Subject: [PATCH] SimpleChatTCRV:CMTextFormat: Common flow accounting User and Auto If user explicitly makes a content text format selection, the same will be used. Else based on session settings, a format will be used. Now when the popover menu is shown, the current message's format type is reflected in the popover menu. --- tools/server/public_simplechat/docs/changelog.md | 1 + tools/server/public_simplechat/docs/details.md | 3 ++- tools/server/public_simplechat/index.html | 1 + tools/server/public_simplechat/readme.md | 3 ++- tools/server/public_simplechat/simplechat.js | 16 +++++++++++++--- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/server/public_simplechat/docs/changelog.md b/tools/server/public_simplechat/docs/changelog.md index 98010de0d9..b2a40d8a60 100644 --- a/tools/server/public_simplechat/docs/changelog.md +++ b/tools/server/public_simplechat/docs/changelog.md @@ -305,6 +305,7 @@ Chat Session specific settings * lists (ordered, unordered, intermixed at diff leves) accomodate lines without list markers inbetween list items to some extent, hopefully in a sane way. * 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. diff --git a/tools/server/public_simplechat/docs/details.md b/tools/server/public_simplechat/docs/details.md index 7be58683da..022aaffe86 100644 --- a/tools/server/public_simplechat/docs/details.md +++ b/tools/server/public_simplechat/docs/details.md @@ -268,7 +268,8 @@ It is attached to the document object. Some of these can also be updated using t * Markdown - - enabled: whether markdown support is enabled or not. + - enabled: whether auto markdown support is enabled or not at a session level. + - user can always override explicitly wrt any chat message, as they see fit. - always: if true, all messages text content interpreted as Markdown based text and converted to html for viewing. if false, then interpret only ai assistant's text content as markdown. - htmlSanitize: text content sanitized using browser's dom parser, so html/xml tags get converted to normal visually equivalent text representation, before processing by markdown to html conversion logic. diff --git a/tools/server/public_simplechat/index.html b/tools/server/public_simplechat/index.html index d99489a24a..8bc582459a 100644 --- a/tools/server/public_simplechat/index.html +++ b/tools/server/public_simplechat/index.html @@ -48,6 +48,7 @@
diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index 99707d5dff..e33e0e2c11 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -133,7 +133,8 @@ A lightweight simple minded ai chat client with a web front-end that supports mu - Client side Sliding window Context control, using `iRecentUserMsgCnt`, helps limit context sent to ai model - Optional - - simple minded markdown parsing of chat message text contents (default) + - simple minded markdown parsing of chat message text contents (default wrt assistant messages/responses) + - user can override, if needed globally or at a individual message level - auto trimming of trailing garbage from model outputs - Follows responsive design to try adapt to any screen size diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index f61fa5780a..8b95eee128 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -277,6 +277,7 @@ export class NSChatMessage { class Format { static Text = { + Default: "default", Plain: "plain", Html: "html", Markdown: "markdown", @@ -309,7 +310,7 @@ export class ChatMessageEx { } this.uniqId = ChatMessageEx.getUniqId() this.trimmedContent = trimmedContent; - this.textFormat = Format.Text.Plain + this.textFormat = Format.Text.Default } /** @@ -325,7 +326,7 @@ export class ChatMessageEx { clear() { this.ns = new NSChatMessage() this.trimmedContent = undefined; - this.textFormat = Format.Text.Plain + this.textFormat = Format.Text.Default } /** @@ -1531,7 +1532,7 @@ class MultiChatUI { for (const [name, stype, content] of showList) { let sftype = stype if (content.length > 0) { - if ((name == "content") && (chatSessionMarkdown.enabled)) { + if ((name == "content") && (sftype == Format.Text.Default) && (chatSessionMarkdown.enabled)) { if (chatSessionMarkdown.always) { sftype = Format.Text.Markdown } else { @@ -1848,6 +1849,15 @@ class MultiChatUI { // ChatMessage edit popover menu + this.elPopoverChatMsg.addEventListener('beforetoggle', (tev)=>{ + let chatSession = this.simpleChats[this.curChatId] + let index = chatSession.get_chatmessage_index(this.uniqIdChatMsgPO) + let chat = chatSession.xchat[index] + if (chat.ns.has_content()) { + this.elPopoverChatMsgFormatSelect.value = chat.textFormat + } + }) + this.elPopoverChatMsgDelBtn.addEventListener('click', (ev) => { console.log(`DBUG:SimpleChat:MCUI:ChatMsgPO:Del:${this.curChatId}:${this.uniqIdChatMsgPO}`) this.chatmsg_del_uiupdate(this.curChatId, this.uniqIdChatMsgPO)