SimpleChatTCRV:Cleanup:Delete and Chat UI suitable update
If deleting a non last (and non just before last) message, then just directly remove the corresponding chat message block from the ChatSession UI and be done with it. However if deleting the last (or just before last) message, then one needs to decide on whether tool call edit/trigger ui is shown or removed and so... and similarly wrt tool response edit/submit.
This commit is contained in:
parent
f3424d3a2a
commit
926b5cd8f3
|
|
@ -760,6 +760,13 @@ sliding window based drop off or even before they kick in, this can help in many
|
||||||
* have a del button, which allows one to delete the currently in focus chat message.
|
* have a del button, which allows one to delete the currently in focus chat message.
|
||||||
* have a copy button, which allows one to copy the textual content into system clipboard.
|
* have a copy button, which allows one to copy the textual content into system clipboard.
|
||||||
|
|
||||||
|
* MultiChatUI
|
||||||
|
* chat_show takes care of showing or clearing tool call edit / trigger as well as tool response
|
||||||
|
edit / submit. Also show the currently active tool call and its response before it is submit
|
||||||
|
was previously only shown in the edit / trigger and edit / submit ui elements, now instead it
|
||||||
|
also shows as part of the chat session message blocks, so that user can delete or copy these
|
||||||
|
if needed using the same mechanism as other messages in the chat session.
|
||||||
|
|
||||||
|
|
||||||
#### ToDo
|
#### ToDo
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1212,12 +1212,13 @@ class MultiChatUI {
|
||||||
*/
|
*/
|
||||||
show_message(elParent, msg, iFromLast, nextMsg) {
|
show_message(elParent, msg, iFromLast, nextMsg) {
|
||||||
// Handle ToolTemp
|
// Handle ToolTemp
|
||||||
if (msg.ns.role === Roles.ToolTemp) {
|
|
||||||
if (iFromLast == 0) {
|
if (iFromLast == 0) {
|
||||||
|
if (msg.ns.role === Roles.ToolTemp) {
|
||||||
this.elInUser.value = msg.ns.getContent();
|
this.elInUser.value = msg.ns.getContent();
|
||||||
this.elInUser.dataset.role = Roles.ToolTemp
|
} else {
|
||||||
|
this.elInUser.value = "";
|
||||||
}
|
}
|
||||||
return
|
this.elInUser.dataset.role = msg.ns.role
|
||||||
}
|
}
|
||||||
// Create main section
|
// Create main section
|
||||||
let secMain = document.createElement('section')
|
let secMain = document.createElement('section')
|
||||||
|
|
@ -1274,7 +1275,7 @@ class MultiChatUI {
|
||||||
img.src = msg.ns.image_url
|
img.src = msg.ns.image_url
|
||||||
secContents?.append(img)
|
secContents?.append(img)
|
||||||
}
|
}
|
||||||
// Handle tool call ui, if reqd
|
// Handle tool call edit/trigger ui, if reqd
|
||||||
let bTC = false
|
let bTC = false
|
||||||
let bAuto = false
|
let bAuto = false
|
||||||
if (msg.ns.role === Roles.Assistant) {
|
if (msg.ns.role === Roles.Assistant) {
|
||||||
|
|
@ -1290,8 +1291,8 @@ class MultiChatUI {
|
||||||
this.ui_reset_toolcall_as_needed(msg, bAuto);
|
this.ui_reset_toolcall_as_needed(msg, bAuto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle tool call non ui
|
// Handle tool call message show
|
||||||
if (msg.ns.tool_calls && !bTC) {
|
if (msg.ns.tool_calls) {
|
||||||
for (const tc of msg.ns.tool_calls) {
|
for (const tc of msg.ns.tool_calls) {
|
||||||
this.show_message_toolcall(secContents, tc)
|
this.show_message_toolcall(secContents, tc)
|
||||||
}
|
}
|
||||||
|
|
@ -1322,8 +1323,8 @@ class MultiChatUI {
|
||||||
let chat = this.simpleChats[this.curChatId];
|
let chat = this.simpleChats[this.curChatId];
|
||||||
if (bClear) {
|
if (bClear) {
|
||||||
this.elDivChat.replaceChildren();
|
this.elDivChat.replaceChildren();
|
||||||
this.ui_reset_toolcall_as_needed(new ChatMessageEx());
|
|
||||||
}
|
}
|
||||||
|
this.ui_reset_toolcall_as_needed(new ChatMessageEx());
|
||||||
this.elLastChatMessage = null
|
this.elLastChatMessage = null
|
||||||
let chatToShow = chat.recent_chat(this.me.chatProps.iRecentUserMsgCnt);
|
let chatToShow = chat.recent_chat(this.me.chatProps.iRecentUserMsgCnt);
|
||||||
for(const [i, x] of chatToShow.entries()) {
|
for(const [i, x] of chatToShow.entries()) {
|
||||||
|
|
@ -1348,14 +1349,19 @@ class MultiChatUI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified ChatMessage block in ui, without needing to show full chat session again.
|
* Remove the specified ChatMessage block in ui, without needing to show full chat session again.
|
||||||
|
* @param {string} curChatId
|
||||||
* @param {number} uniqIdChatMsg
|
* @param {number} uniqIdChatMsg
|
||||||
*/
|
*/
|
||||||
ui_chatmessage_delete(uniqIdChatMsg) {
|
ui_chatmessage_delete(curChatId, uniqIdChatMsg) {
|
||||||
let index = this.simpleChats[this.curChatId].delete(uniqIdChatMsg)
|
let index = this.simpleChats[curChatId].delete(uniqIdChatMsg)
|
||||||
if (index >= 0) {
|
if ((index >= 0) && (curChatId == this.curChatId)) {
|
||||||
let el = document.querySelector(`[CMUniqId="${uniqIdChatMsg}"`)
|
let el = document.querySelector(`[CMUniqId="${uniqIdChatMsg}"]`)
|
||||||
console.log(el)
|
|
||||||
el?.remove()
|
el?.remove()
|
||||||
|
if (index >= (this.simpleChats[curChatId].xchat.length-1)) {
|
||||||
|
// so that tool call edit/trigger control etal can be controlled suitably
|
||||||
|
// from a single place - need to add that centrally controlled logic flor still.
|
||||||
|
this.chat_show(curChatId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1455,7 +1461,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}`)
|
||||||
this.ui_chatmessage_delete(this.uniqIdChatMsgPO)
|
this.ui_chatmessage_delete(this.curChatId, this.uniqIdChatMsgPO)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.elPopoverChatMsgCopyBtn.addEventListener('click', (ev) => {
|
this.elPopoverChatMsgCopyBtn.addEventListener('click', (ev) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue