diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index d7cdfe5f..90fa1b66 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -93,6 +93,10 @@ let isLite = false; let isFrame = false; + /** @type {any} */ + let contentLogComponent; + /** @type {any} */ + let stateLogComponent; onMount(async () => { dialogs = await GetDialogs(params.conversationId); @@ -532,10 +536,22 @@ const foundIdx = dialogs.findIndex(x => x.message_id === messageId); if (foundIdx < 0) return false; dialogs = dialogs.filter((x, idx) => idx < foundIdx); + truncateLogs(messageId); refresh(); return true; } + /** @param {string} messageId */ + function truncateLogs(messageId) { + if (contentLogComponent && contentLogComponent.onDeleteMessage) { + contentLogComponent.onDeleteMessage(messageId); + } + + if (stateLogComponent && stateLogComponent.onDeleteMessage) { + stateLogComponent.onDeleteMessage(messageId); + } + } + /** @param {string} messageId */ function directToLog(messageId) { if (!!!messageId || isLite) return; @@ -610,7 +626,12 @@ {#if isLoadStateLog} - + {/if} @@ -813,7 +834,12 @@ {#if isLoadContentLog} - + {/if} diff --git a/src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log.svelte b/src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log.svelte index 6508f5d0..6f548810 100644 --- a/src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log.svelte @@ -15,6 +15,11 @@ /** @type {() => void} */ export let cleanScreen; + export const onDeleteMessage = (/** @type {string} */ messageId) => { + const targetIdx = allLogs.findIndex(x => x.message_id === messageId); + allLogs = allLogs.filter((x, idx) => idx < targetIdx); + } + // @ts-ignore let scrollbar; /** @type {import('$types').ConversationContentLogModel[]} */ @@ -67,6 +72,12 @@ cleanLogs(); cleanScreen && cleanScreen(); } + + // /** @param {string} messageId */ + // function onDeleteMessage(messageId) { + // const targetIdx = allLogs.findIndex(x => x.message_id === messageId); + // allLogs = allLogs.filter((x, idx) => idx < targetIdx); + // }
diff --git a/src/routes/chat/[agentId]/[conversationId]/stateLogs/state-log.svelte b/src/routes/chat/[agentId]/[conversationId]/stateLogs/state-log.svelte index 70f17a40..1f583e4e 100644 --- a/src/routes/chat/[agentId]/[conversationId]/stateLogs/state-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/stateLogs/state-log.svelte @@ -15,6 +15,11 @@ /** @type {() => void} */ export let cleanScreen; + export const onDeleteMessage = (/** @type {string} */ messageId) => { + const targetIdx = allLogs.findIndex(x => x.message_id === messageId); + allLogs = allLogs.filter((x, idx) => idx < targetIdx); + } + // @ts-ignore let scrollbar; /** @type {any[]} */