From 1bb5dd0eda00317babe281aa049f69a06c466227 Mon Sep 17 00:00:00 2001 From: akumatus Date: Thu, 27 Feb 2025 09:44:19 +0000 Subject: [PATCH] fix(core): always update session prompt before chat (#10483) Why make this fix? The network search flag is saved locally. If the user opens multiple clients, the local status and server status may be inconsistent. --- .../src/blocksuite/ai/chat-panel/chat-panel-input.ts | 11 +++-------- .../src/blocksuite/ai/peek-view/chat-block-input.ts | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-panel-input.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-panel-input.ts index 55f91f5ff..492333b90 100644 --- a/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-panel-input.ts +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-panel-input.ts @@ -203,8 +203,6 @@ export class ChatPanelInput extends SignalWatcher(WithDisposable(LitElement)) { @property({ attribute: false }) accessor networkSearchConfig!: AINetworkSearchConfig; - private _lastPromptName: string | null = null; - private get _isNetworkActive() { return ( !!this.networkSearchConfig.visible.value && @@ -230,12 +228,9 @@ export class ChatPanelInput extends SignalWatcher(WithDisposable(LitElement)) { } private async _updatePromptName(promptName: string) { - if (this._lastPromptName !== promptName) { - const sessionId = await this.getSessionId(); - if (sessionId && AIProvider.session) { - await AIProvider.session.updateSession(sessionId, promptName); - this._lastPromptName = promptName; - } + const sessionId = await this.getSessionId(); + if (sessionId && AIProvider.session) { + await AIProvider.session.updateSession(sessionId, promptName); } } diff --git a/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-input.ts b/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-input.ts index e34e4635e..b72351b0f 100644 --- a/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-input.ts +++ b/packages/frontend/core/src/blocksuite/ai/peek-view/chat-block-input.ts @@ -239,8 +239,6 @@ export class ChatBlockInput extends SignalWatcher(LitElement) { @state() accessor _focused = false; - private _lastPromptName: string | null = null; - private get _isNetworkActive() { return ( !!this.networkSearchConfig.visible.value && @@ -262,12 +260,9 @@ export class ChatBlockInput extends SignalWatcher(LitElement) { } private async _updatePromptName(promptName: string) { - if (this._lastPromptName !== promptName) { - const { currentSessionId } = this.chatContext; - if (currentSessionId && AIProvider.session) { - await AIProvider.session.updateSession(currentSessionId, promptName); - this._lastPromptName = promptName; - } + const { currentSessionId } = this.chatContext; + if (currentSessionId && AIProvider.session) { + await AIProvider.session.updateSession(currentSessionId, promptName); } }