fix(core): after clearing the history, new chat will report an error (#11549)

Close [BS-3025](https://linear.app/affine-design/issue/BS-3025)
This commit is contained in:
akumatus
2025-04-09 07:22:30 +00:00
parent 82ade96b3f
commit 3bf3068650
3 changed files with 2 additions and 11 deletions
@@ -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}
@@ -58,9 +58,6 @@ export class AIChatComposer extends SignalWatcher(
@property({ attribute: false })
accessor createSessionId!: () => Promise<string | undefined>;
@property({ attribute: false })
accessor createChatSessionId!: () => Promise<string | undefined>;
@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}
@@ -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}