mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
fix(core): ai history of new users is always loading, enable online search by default (#11741)
Close [AI-69](https://linear.app/affine-design/issue/AI-69).
This commit is contained in:
@@ -235,7 +235,10 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
|||||||
@scroll=${() => this._debouncedOnScroll()}
|
@scroll=${() => this._debouncedOnScroll()}
|
||||||
>
|
>
|
||||||
${filteredItems.length === 0
|
${filteredItems.length === 0
|
||||||
? html`<div class="messages-placeholder">
|
? html`<div
|
||||||
|
class="messages-placeholder"
|
||||||
|
data-testid="chat-panel-messages-placeholder"
|
||||||
|
>
|
||||||
${AffineIcon(
|
${AffineIcon(
|
||||||
isLoading
|
isLoading
|
||||||
? 'var(--affine-icon-secondary)'
|
? 'var(--affine-icon-secondary)'
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ export class ChatPanel extends SignalWatcher(
|
|||||||
.createSessionId=${this._createSessionId}
|
.createSessionId=${this._createSessionId}
|
||||||
.updateContext=${this.updateContext}
|
.updateContext=${this.updateContext}
|
||||||
.host=${this.host}
|
.host=${this.host}
|
||||||
.isLoading=${this.isLoading || !this._isInitialized}
|
.isLoading=${this.isLoading}
|
||||||
.previewSpecBuilder=${this.previewSpecBuilder}
|
.previewSpecBuilder=${this.previewSpecBuilder}
|
||||||
></chat-panel-messages>
|
></chat-panel-messages>
|
||||||
<ai-chat-composer
|
<ai-chat-composer
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
type Signal,
|
type Signal,
|
||||||
} from '@blocksuite/affine/shared/utils';
|
} from '@blocksuite/affine/shared/utils';
|
||||||
import { LiveData, Service } from '@toeverything/infra';
|
import { LiveData, Service } from '@toeverything/infra';
|
||||||
|
import { map } from 'rxjs';
|
||||||
|
|
||||||
import type { FeatureFlagService } from '../../feature-flag';
|
import type { FeatureFlagService } from '../../feature-flag';
|
||||||
import type { GlobalStateService } from '../../storage';
|
import type { GlobalStateService } from '../../storage';
|
||||||
@@ -17,12 +18,18 @@ export class AINetworkSearchService extends Service {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
const { signal: enabled, cleanup: enabledCleanup } =
|
const { signal: enabled, cleanup: enabledCleanup } =
|
||||||
createSignalFromObservable<boolean | undefined>(this._enabled$, false);
|
createSignalFromObservable<boolean | undefined>(
|
||||||
|
this._enabled$,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.disposables.push(enabledCleanup);
|
this.disposables.push(enabledCleanup);
|
||||||
|
|
||||||
const { signal: visible, cleanup: visibleCleanup } =
|
const { signal: visible, cleanup: visibleCleanup } =
|
||||||
createSignalFromObservable<boolean | undefined>(this._visible$, false);
|
createSignalFromObservable<boolean | undefined>(
|
||||||
|
this._visible$,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
this.disposables.push(visibleCleanup);
|
this.disposables.push(visibleCleanup);
|
||||||
}
|
}
|
||||||
@@ -35,8 +42,10 @@ export class AINetworkSearchService extends Service {
|
|||||||
this.featureFlagService.flags.enable_ai_network_search.$;
|
this.featureFlagService.flags.enable_ai_network_search.$;
|
||||||
|
|
||||||
private readonly _enabled$ = LiveData.from(
|
private readonly _enabled$ = LiveData.from(
|
||||||
this.globalStateService.globalState.watch<boolean>(AI_NETWORK_SEARCH_KEY),
|
this.globalStateService.globalState
|
||||||
false
|
.watch<boolean>(AI_NETWORK_SEARCH_KEY)
|
||||||
|
.pipe(map(v => (v === undefined ? true : v))),
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
setEnabled = (enabled: boolean) => {
|
setEnabled = (enabled: boolean) => {
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ test.describe('AIBasic/Authority', () => {
|
|||||||
await utils.chatPanel.openChatPanel(page);
|
await utils.chatPanel.openChatPanel(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should show messages placeholder when no login', async ({ page }) => {
|
||||||
|
await expect(
|
||||||
|
page.getByTestId('chat-panel-messages-placeholder')
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
test('should show error & login button when no login', async ({
|
test('should show error & login button when no login', async ({
|
||||||
page,
|
page,
|
||||||
utils,
|
utils,
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ export class ChatPanelUtils {
|
|||||||
}
|
}
|
||||||
await page.getByTestId('sidebar-tab-chat').click();
|
await page.getByTestId('sidebar-tab-chat').click();
|
||||||
await expect(page.getByTestId('sidebar-tab-content-chat')).toBeVisible();
|
await expect(page.getByTestId('sidebar-tab-content-chat')).toBeVisible();
|
||||||
|
// TODO: remove this
|
||||||
|
// after network search is disabled by default
|
||||||
|
await this.disableNetworkSearch(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async typeChat(page: Page, content: string) {
|
public static async typeChat(page: Page, content: string) {
|
||||||
@@ -48,7 +51,6 @@ export class ChatPanelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async makeChat(page: Page, content: string) {
|
public static async makeChat(page: Page, content: string) {
|
||||||
await this.openChatPanel(page);
|
|
||||||
await this.typeChat(page, content);
|
await this.typeChat(page, content);
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user