From 3bf3068650a97360b2aa1613e267d59687fd8f13 Mon Sep 17 00:00:00 2001 From: akumatus Date: Wed, 9 Apr 2025 07:22:30 +0000 Subject: [PATCH] fix(core): after clearing the history, new chat will report an error (#11549) Close [BS-3025](https://linear.app/affine-design/issue/BS-3025) --- .../frontend/core/src/blocksuite/ai/chat-panel/index.ts | 1 - .../ai/components/ai-chat-composer/ai-chat-composer.ts | 5 +---- .../src/blocksuite/ai/peek-view/chat-block-peek-view.ts | 7 +------ 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts index 146331259f..132807866d 100644 --- a/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts @@ -408,7 +408,6 @@ export class ChatPanel extends SignalWatcher( .doc=${this.doc} .getSessionId=${this._getSessionId} .createSessionId=${this._createSessionId} - .createChatSessionId=${this._createSessionId} .chatContextValue=${this.chatContextValue} .updateContext=${this.updateContext} .updateEmbeddingProgress=${this._updateEmbeddingProgress} diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts index ff8c2cd62d..43f18be5f0 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts @@ -58,9 +58,6 @@ export class AIChatComposer extends SignalWatcher( @property({ attribute: false }) accessor createSessionId!: () => Promise; - @property({ attribute: false }) - accessor createChatSessionId!: () => Promise; - @property({ attribute: false }) accessor chatContextValue!: AIChatInputContext; @@ -123,7 +120,7 @@ export class AIChatComposer extends SignalWatcher( .host=${this.host} .chips=${this.chips} .getSessionId=${this.getSessionId} - .createSessionId=${this.createChatSessionId} + .createSessionId=${this.createSessionId} .getContextId=${this._getContextId} .chatContextValue=${this.chatContextValue} .updateContext=${this.updateContext} diff --git a/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-peek-view.ts b/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-peek-view.ts index fcfde665bc..14a4552f6a 100644 --- a/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-peek-view.ts +++ b/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-peek-view.ts @@ -141,14 +141,10 @@ export class AIChatBlockPeekView extends LitElement { }; private readonly _getSessionId = async () => { - return this._sessionId; + return this._forkSessionId ?? this._sessionId; }; private readonly _createSessionId = async () => { - return this._sessionId; - }; - - private readonly _createForkSessionId = async () => { if (this._forkSessionId) { return this._forkSessionId; } @@ -506,7 +502,6 @@ export class AIChatBlockPeekView extends LitElement { .doc=${this.host.doc} .getSessionId=${this._getSessionId} .createSessionId=${this._createSessionId} - .createChatSessionId=${this._createForkSessionId} .chatContextValue=${chatContext} .updateContext=${updateContext} .onHistoryCleared=${this._onHistoryCleared}