From 1d2ef9dddb073bc5bb430c21849bf3d2a2ad0dbe Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Thu, 13 Nov 2025 17:34:26 +0530 Subject: [PATCH] SimpleChatTCRV:ChatMessage: UniqId, Delete logic, edit popover ui --- tools/server/public_simplechat/index.html | 5 ++++ tools/server/public_simplechat/readme.md | 7 +++-- tools/server/public_simplechat/simplechat.css | 9 ++++++ tools/server/public_simplechat/simplechat.js | 28 +++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tools/server/public_simplechat/index.html b/tools/server/public_simplechat/index.html index c6f380eca2..658e2385a9 100644 --- a/tools/server/public_simplechat/index.html +++ b/tools/server/public_simplechat/index.html @@ -44,6 +44,11 @@

You need to have javascript enabled.

+
+ + +
+

diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index 5ad0b61531..55e93f5d92 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -743,13 +743,16 @@ sliding window based drop off or even before they kick in, this can help in many * add open, transact, put and get. Use for chat session save and load * getKeys used to show Restore/Load button wrt chat sessions. +* ChatMessage + * assign a globally unique (ie across sessions) id to each chat message instance. + * add support for deleting chat message based on its uniquie id in SimpleChat. + * add a popover div block in html, which contains the edit menu wrt chat messages + #### ToDo Is the tool call promise land trap deep enough, need to think through and explore around this once later. -Handle multimodal handshaking with ai models [WIP]. - Add fetch_rss and may be different document formats processing related tool calling, in turn through the simpleproxy.py if and where needed. diff --git a/tools/server/public_simplechat/simplechat.css b/tools/server/public_simplechat/simplechat.css index 491b9272b0..40dbb582ce 100644 --- a/tools/server/public_simplechat/simplechat.css +++ b/tools/server/public_simplechat/simplechat.css @@ -92,6 +92,15 @@ max-width: 20vmin; max-height: 20vmin; } +#popover-edit { + position:absolute; + background-color: transparent; + padding: 0; + border-width: 0; +} +#popover-edit button { + padding: 0; +} .gridx2 { diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 14403c18ab..4e1855e7c1 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -257,6 +257,16 @@ class NSChatMessage { class ChatMessageEx { + static uniqCounter = 0 + + /** + * Get a globally (ie across chat sessions) unique id wrt chat messages. + */ + static getUniqId() { + this.uniqCounter += 1 + return this.uniqCounter + } + /** * Represent a Message in the Chat. * @param {NSChatMessage|undefined} nsChatMsg - will create a default NSChatMessage instance, if undefined @@ -268,6 +278,7 @@ class ChatMessageEx { } else { this.ns = new NSChatMessage() } + this.uniqId = ChatMessageEx.getUniqId() this.trimmedContent = trimmedContent; } @@ -651,6 +662,22 @@ class SimpleChat { return true; } + /** + * Delete a chat message in place using chat message uniqId. + * @param {number} uniqId + */ + delete(uniqId) { + let index = this.xchat.findIndex((msg)=>{ + if (msg.uniqId == uniqId) { + return true + } + return false + }) + if (index >= 0) { + this.xchat.splice(index, 1) + } + } + /** * Check if the last message in the chat history is a ToolTemp role based one. * If so, then @@ -1000,6 +1027,7 @@ class MultiChatUI { this.elBtnTool = /** @type{HTMLButtonElement} */(document.getElementById("tool-btn")); this.elInToolName = /** @type{HTMLInputElement} */(document.getElementById("toolname-in")); this.elInToolArgs = /** @type{HTMLInputElement} */(document.getElementById("toolargs-in")); + this.elPopoverEdit = /** @type{HTMLElement} */(document.getElementById("popover-edit")); // Save any placeholder set by default like through html, to restore where needed this.elInUser.dataset.placeholder = this.elInUser.placeholder