Skip to content

Commit

Permalink
add delete log
Browse files Browse the repository at this point in the history
  • Loading branch information
Jicheng Lu committed Feb 28, 2024
1 parent eae6d0b commit 6dbb4a0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -610,7 +626,12 @@
<Splitpanes>
{#if isLoadStateLog}
<Pane size={30} minSize={20} maxSize={50} >
<StateLog stateLogs={stateLogs} closeWindow={toggleStateLog} cleanScreen={cleanStateLogScreen} />
<StateLog
bind:this={stateLogComponent}
stateLogs={stateLogs}
closeWindow={toggleStateLog}
cleanScreen={cleanStateLogScreen}
/>
</Pane>
{/if}
<Pane minSize={20}>
Expand Down Expand Up @@ -813,7 +834,12 @@
</Pane>
{#if isLoadContentLog}
<Pane size={30} minSize={20} maxSize={50}>
<ContentLog contentLogs={contentLogs} closeWindow={toggleContentLog} cleanScreen={cleanContentLogScreen} />
<ContentLog
bind:this={contentLogComponent}
contentLogs={contentLogs}
closeWindow={toggleContentLog}
cleanScreen={cleanContentLogScreen}
/>
</Pane>
{/if}
</Splitpanes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]} */
Expand Down Expand Up @@ -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);
// }
</script>

<div class="chat-log">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]} */
Expand Down

0 comments on commit 6dbb4a0

Please sign in to comment.