SimpleChatTCRV:Cleanup: Efficient ChatMessage Ui Delete

avoid refreshing the full chat session messages ui

also Update readme
This commit is contained in:
hanishkvc 2025-11-14 19:19:57 +05:30
parent 95f79eb8b0
commit f3424d3a2a
2 changed files with 14 additions and 12 deletions

View File

@ -779,9 +779,6 @@ same when saved chat is loaded.
MAYBE make the settings in general chat session specific, rather than the current global config flow. MAYBE make the settings in general chat session specific, rather than the current global config flow.
Have unique id or use the index into chat messages array wrt each chat message in a chat session, so that
it is easy to identify and remove chat messages from the UI even in sliding window mode.
Have a seperate helper to show the user input area, based on set state. And have support for multiple images Have a seperate helper to show the user input area, based on set state. And have support for multiple images
if the models support same. if the models support same.

View File

@ -1346,6 +1346,19 @@ class MultiChatUI {
return true return true
} }
/**
* Remove the specified ChatMessage block in ui, without needing to show full chat session again.
* @param {number} uniqIdChatMsg
*/
ui_chatmessage_delete(uniqIdChatMsg) {
let index = this.simpleChats[this.curChatId].delete(uniqIdChatMsg)
if (index >= 0) {
let el = document.querySelector(`[CMUniqId="${uniqIdChatMsg}"`)
console.log(el)
el?.remove()
}
}
/** /**
* Setup the needed callbacks wrt UI, curChatId to defaultChatId and * Setup the needed callbacks wrt UI, curChatId to defaultChatId and
* optionally switch to specified defaultChatId. * optionally switch to specified defaultChatId.
@ -1442,15 +1455,7 @@ class MultiChatUI {
this.elPopoverChatMsgDelBtn.addEventListener('click', (ev) => { this.elPopoverChatMsgDelBtn.addEventListener('click', (ev) => {
console.log(`DBUG:MCUI:ChatMsgPO:Del:${this.curChatId}:${this.uniqIdChatMsgPO}`) console.log(`DBUG:MCUI:ChatMsgPO:Del:${this.curChatId}:${this.uniqIdChatMsgPO}`)
let index = this.simpleChats[this.curChatId].delete(this.uniqIdChatMsgPO) this.ui_chatmessage_delete(this.uniqIdChatMsgPO)
if (index >= 0) {
this.chat_show(this.curChatId)
let msg = this.simpleChats[this.curChatId].xchat[index]
if (msg) {
let el = document.querySelector(`[CMUniqId="${msg.uniqId}"`)
this.scroll_el_into_view(el)
}
}
}) })
this.elPopoverChatMsgCopyBtn.addEventListener('click', (ev) => { this.elPopoverChatMsgCopyBtn.addEventListener('click', (ev) => {