mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 08:38:34 +00:00
fix: cannot clean chat panel histories (#7673)
This commit is contained in:
@@ -97,8 +97,6 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
||||
private readonly _chatMessages: Ref<ChatPanelMessages> =
|
||||
createRef<ChatPanelMessages>();
|
||||
|
||||
private _chatSessionId = '';
|
||||
|
||||
private _resettingCounter = 0;
|
||||
|
||||
private readonly _resetItems = debounce(() => {
|
||||
@@ -119,7 +117,6 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
||||
if (histories?.at(-1)) {
|
||||
const history = histories.at(-1);
|
||||
if (!history) return;
|
||||
this._chatSessionId = history.sessionId;
|
||||
this.chatContextValue.chatSessionId = history.sessionId;
|
||||
items.push(...history.messages);
|
||||
AIProvider.LAST_ROOT_SESSION_ID = history.sessionId;
|
||||
@@ -175,13 +172,14 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
||||
})
|
||||
) {
|
||||
await AIProvider.histories?.cleanup(this.doc.collection.id, this.doc.id, [
|
||||
this._chatSessionId,
|
||||
this.chatContextValue.chatSessionId ?? '',
|
||||
...(
|
||||
this.chatContextValue.items.filter(
|
||||
item => 'sessionId' in item
|
||||
) as ChatAction[]
|
||||
).map(item => item.sessionId),
|
||||
]);
|
||||
this.chatContextValue.chatSessionId = null;
|
||||
notification.toast('History cleared');
|
||||
this._resetItems();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user