From 00a458543ff89dad0dcce41b2019a3c7ccbfa34f Mon Sep 17 00:00:00 2001
From: DarkSky <25152247+darkskygit@users.noreply.github.com>
Date: Thu, 15 Jan 2026 19:20:55 +0800
Subject: [PATCH] feat: cleanup chat panel (#14258)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
#### PR Dependency Tree
* **PR #14258** 👈
This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
## Summary by CodeRabbit
## Release Notes
* **Removed Features**
* Web search functionality has been removed from AI chat and related AI
features. Users will no longer see network search options or toggles in
chat preferences and panels.
* AI chat requests no longer support external web search capabilities.
✏️ Tip: You can customize this high-level summary in your review
settings.
#### PR Dependency Tree
* **PR #14258** 👈
* **PR #14259**
This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
---
.../src/blocksuite/ai/actions/doc-handler.ts | 19 ++-----
.../blocksuite/ai/actions/edgeless-handler.ts | 19 ++-----
.../core/src/blocksuite/ai/actions/types.ts | 1 -
.../core/src/blocksuite/ai/ai-panel.ts | 11 +---
.../src/blocksuite/ai/chat-panel/ai-title.ts | 5 --
.../src/blocksuite/ai/chat-panel/index.ts | 6 ---
.../ai-chat-composer/ai-chat-composer.ts | 10 +---
.../ai-chat-content/ai-chat-content.ts | 10 +---
.../components/ai-chat-input/ai-chat-input.ts | 24 +--------
.../ai-chat-input/preference-popup.ts | 54 ++++++-------------
.../ai/components/ai-chat-input/type.ts | 6 ---
.../ai-chat-messages/ai-chat-messages.ts | 16 +-----
.../ai/components/playground/chat.ts | 11 +---
.../ai/components/playground/content.ts | 10 +---
.../ai/extensions/ai-edgeless-root.ts | 5 +-
.../blocksuite/ai/extensions/ai-page-root.ts | 5 +-
.../ai/peek-view/chat-block-peek-view.ts | 26 +--------
.../blocksuite/ai/provider/copilot-client.ts | 6 ---
.../src/blocksuite/ai/provider/request.ts | 4 --
.../blocksuite/ai/provider/setup-provider.tsx | 3 +-
.../ai/widgets/ai-panel/ai-panel.ts | 1 -
.../blocksuite/ai/widgets/ai-panel/type.ts | 8 ---
.../blocksuite/view-extensions/ai/index.ts | 4 +-
.../hooks/affine/use-ai-chat-config.ts | 9 ----
.../desktop/pages/workspace/chat/index.tsx | 10 +---
.../pages/workspace/detail-page/tabs/chat.tsx | 3 --
.../core/src/modules/ai-button/index.ts | 8 ---
.../ai-button/services/network-search.ts | 51 ------------------
packages/frontend/core/src/modules/index.ts | 2 -
.../view/ai-chat-block-peek-view/index.tsx | 10 +---
.../e2e/chat-with/network.spec.ts | 1 -
.../e2e/utils/chat-panel-utils.ts | 21 --------
32 files changed, 45 insertions(+), 334 deletions(-)
delete mode 100644 packages/frontend/core/src/modules/ai-button/services/network-search.ts
diff --git a/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts b/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts
index c6c3932ae7..094ab1f667 100644
--- a/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts
+++ b/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts
@@ -24,10 +24,7 @@ import {
} from '../utils/selection-utils';
import { mergeStreamObjects } from '../utils/stream-objects';
import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
-import type {
- AIActionAnswer,
- AINetworkSearchConfig,
-} from '../widgets/ai-panel/type';
+import type { AIActionAnswer } from '../widgets/ai-panel/type';
import { actionToAnswerRenderer } from './answer-renderer';
export function bindTextStream(
@@ -89,8 +86,7 @@ function actionToStream(
Parameters[0],
keyof BlockSuitePresets.AITextActionOptions
>,
- trackerOptions?: BlockSuitePresets.TrackerOptions,
- networkConfig?: AINetworkSearchConfig
+ trackerOptions?: BlockSuitePresets.TrackerOptions
): BlockSuitePresets.TextStream | undefined {
const action = AIProvider.actions[id];
if (!action || typeof action !== 'function') return;
@@ -115,7 +111,6 @@ function actionToStream(
const models = selectedBlocks?.map(block => block.model);
const control = trackerOptions?.control ?? 'format-bar';
const where = trackerOptions?.where ?? 'ai-panel';
- const { visible, enabled } = networkConfig ?? {};
const options = {
...variants,
attachments,
@@ -128,7 +123,6 @@ function actionToStream(
where,
docId: host.store.id,
workspaceId: host.store.workspace.id,
- webSearch: visible?.value && enabled?.value,
} as Parameters[0];
// @ts-expect-error TODO(@Peng): maybe fix this
stream = await action(options);
@@ -145,8 +139,7 @@ function actionToGenerateAnswer(
Parameters[0],
keyof BlockSuitePresets.AITextActionOptions
>,
- trackerOptions?: BlockSuitePresets.TrackerOptions,
- networkConfig?: AINetworkSearchConfig
+ trackerOptions?: BlockSuitePresets.TrackerOptions
) {
return ({
input,
@@ -167,8 +160,7 @@ function actionToGenerateAnswer(
input,
signal,
variants,
- trackerOptions,
- networkConfig
+ trackerOptions
);
if (!stream) return;
bindTextStream(stream, { update, finish, signal });
@@ -196,8 +188,7 @@ function updateAIPanelConfig(
host,
id,
variants,
- trackerOptions,
- config.networkSearchConfig
+ trackerOptions
);
const ctx = new AIContext();
diff --git a/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts b/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts
index 27057213df..fc34c2eb17 100644
--- a/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts
+++ b/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts
@@ -37,10 +37,7 @@ import {
getSelections,
} from '../utils/selection-utils';
import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
-import type {
- AIActionAnswer,
- AINetworkSearchConfig,
-} from '../widgets/ai-panel/type';
+import type { AIActionAnswer } from '../widgets/ai-panel/type';
import type { EdgelessCopilotWidget } from '../widgets/edgeless-copilot';
import { actionToAnswerRenderer } from './answer-renderer';
import { EXCLUDING_COPY_ACTIONS } from './consts';
@@ -179,8 +176,7 @@ function actionToStream(
seed?: string;
} | void>,
trackerOptions?: BlockSuitePresets.TrackerOptions,
- panelInput?: string,
- networkConfig?: AINetworkSearchConfig
+ panelInput?: string
) {
const action = AIProvider.actions[id];
@@ -194,7 +190,6 @@ function actionToStream(
return {
async *[Symbol.asyncIterator]() {
const models = getCopilotSelectedElems(host);
- const { visible, enabled } = networkConfig ?? {};
const options = {
...variants,
signal,
@@ -206,7 +201,6 @@ function actionToStream(
host,
docId: host.store.id,
workspaceId: host.store.workspace.id,
- webSearch: visible?.value && enabled?.value,
} as Parameters[0];
const content = ctx.get().content;
@@ -273,8 +267,7 @@ function actionToGeneration(
attachments?: (string | Blob)[];
seed?: string;
} | void>,
- trackerOptions?: BlockSuitePresets.TrackerOptions,
- networkConfig?: AINetworkSearchConfig
+ trackerOptions?: BlockSuitePresets.TrackerOptions
) {
return (host: EditorHost, ctx: AIContext) => {
return ({
@@ -299,8 +292,7 @@ function actionToGeneration(
variants,
extract,
trackerOptions,
- input,
- networkConfig
+ input
)?.(host, ctx);
if (!stream) return;
@@ -341,8 +333,7 @@ function updateEdgelessAIPanelConfig<
id,
variants,
customInput,
- trackerOptions,
- config.networkSearchConfig
+ trackerOptions
)(host, ctx);
config.finishStateConfig = actionToResponse(id, host, ctx, variants);
config.generatingStateConfig = actionToGenerating(id, generatingIcon);
diff --git a/packages/frontend/core/src/blocksuite/ai/actions/types.ts b/packages/frontend/core/src/blocksuite/ai/actions/types.ts
index b6e8cf1e25..7536a0c332 100644
--- a/packages/frontend/core/src/blocksuite/ai/actions/types.ts
+++ b/packages/frontend/core/src/blocksuite/ai/actions/types.ts
@@ -142,7 +142,6 @@ declare global {
interface ChatOptions extends AITextActionOptions {
sessionId?: string;
isRootSession?: boolean;
- webSearch?: boolean;
reasoning?: boolean;
modelId?: string;
toolsConfig?: AIToolsConfig | undefined;
diff --git a/packages/frontend/core/src/blocksuite/ai/ai-panel.ts b/packages/frontend/core/src/blocksuite/ai/ai-panel.ts
index 89b8df5767..5d4414d9f4 100644
--- a/packages/frontend/core/src/blocksuite/ai/ai-panel.ts
+++ b/packages/frontend/core/src/blocksuite/ai/ai-panel.ts
@@ -1,4 +1,3 @@
-import { AINetworkSearchService } from '@affine/core/modules/ai-button/services/network-search';
import { Bound } from '@blocksuite/affine/global/gfx';
import {
ImageBlockModel,
@@ -22,7 +21,6 @@ import {
ReplaceIcon,
ResetIcon,
} from '@blocksuite/icons/lit';
-import type { FrameworkProvider } from '@toeverything/infra';
import type { TemplateResult } from 'lit';
import { insertFromMarkdown } from '../utils';
@@ -301,11 +299,9 @@ export function buildCopyConfig(panel: AffineAIPanelWidget) {
}
export function buildAIPanelConfig(
- panel: AffineAIPanelWidget,
- framework: FrameworkProvider
+ panel: AffineAIPanelWidget
): AffineAIPanelWidgetConfig {
const ctx = new AIContext();
- const searchService = framework.get(AINetworkSearchService);
return {
answerRenderer: createAIScrollableTextRenderer(
{
@@ -318,10 +314,5 @@ export function buildAIPanelConfig(
generatingStateConfig: buildGeneratingConfig(),
errorStateConfig: buildErrorConfig(panel),
copy: buildCopyConfig(panel),
- networkSearchConfig: {
- visible: searchService.visible,
- enabled: searchService.enabled,
- setEnabled: searchService.setEnabled,
- },
};
}
diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/ai-title.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/ai-title.ts
index 94555259fe..2baad8c4e6 100644
--- a/packages/frontend/core/src/blocksuite/ai/chat-panel/ai-title.ts
+++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/ai-title.ts
@@ -17,7 +17,6 @@ import { property } from 'lit/decorators.js';
import type { SearchMenuConfig } from '../components/ai-chat-add-context';
import type { DocDisplayConfig } from '../components/ai-chat-chips';
import type {
- AINetworkSearchConfig,
AIPlaygroundConfig,
AIReasoningConfig,
} from '../components/ai-chat-input';
@@ -80,9 +79,6 @@ export class AIChatPanelTitle extends SignalWatcher(
@property({ attribute: false })
accessor appSidebarConfig!: AppSidebarConfig;
- @property({ attribute: false })
- accessor networkSearchConfig!: AINetworkSearchConfig;
-
@property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig;
@@ -142,7 +138,6 @@ export class AIChatPanelTitle extends SignalWatcher(
Promise;
- @property({ attribute: false })
- accessor networkSearchConfig!: AINetworkSearchConfig;
-
@property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig;
@@ -401,13 +394,6 @@ export class AIChatInput extends SignalWatcher(
@property({ attribute: false })
accessor portalContainer: HTMLElement | null = null;
- private get _isNetworkActive() {
- return (
- !!this.networkSearchConfig.visible.value &&
- !!this.networkSearchConfig.enabled.value
- );
- }
-
private get _isReasoningActive() {
return !!this.reasoningConfig.enabled.value;
}
@@ -536,9 +522,6 @@ export class AIChatInput extends SignalWatcher(
.session=${this.session}
.extendedThinking=${this._isReasoningActive}
.onExtendedThinkingChange=${this._toggleReasoning}
- .networkSearchVisible=${!!this.networkSearchConfig.visible.value}
- .isNetworkActive=${this._isNetworkActive}
- .onNetworkActiveChange=${this._toggleNetworkSearch}
.serverService=${this.serverService}
.toolsConfigService=${this.aiToolsConfigService}
.notificationService=${this.notificationService}
@@ -634,10 +617,6 @@ export class AIChatInput extends SignalWatcher(
reportResponse('aborted:stop');
};
- private readonly _toggleNetworkSearch = (isNetworkActive: boolean) => {
- this.networkSearchConfig.setEnabled(isNetworkActive);
- };
-
private readonly _toggleReasoning = (extendedThinking: boolean) => {
this.reasoningConfig.setEnabled(extendedThinking);
};
@@ -732,7 +711,6 @@ export class AIChatInput extends SignalWatcher(
isRootSession: this.isRootSession,
where: this.trackOptions?.where,
control: this.trackOptions?.control,
- webSearch: this._isNetworkActive,
reasoning: this._isReasoningActive,
toolsConfig: this.aiToolsConfigService.config.value,
modelId,
diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/preference-popup.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/preference-popup.ts
index 3aedbf8bb8..f4f7296f11 100644
--- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/preference-popup.ts
+++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/preference-popup.ts
@@ -24,7 +24,6 @@ import {
DoneIcon,
LockIcon,
ThinkingIcon,
- WebIcon,
} from '@blocksuite/icons/lit';
import { ShadowlessElement } from '@blocksuite/std';
import { computed } from '@preact/signals-core';
@@ -101,19 +100,6 @@ export class ChatInputPreference extends SignalWatcher(
| undefined;
// --------- extended thinking props end ---------
- // --------- search props start ---------
- @property({ attribute: false })
- accessor networkSearchVisible: boolean = false;
-
- @property({ attribute: false })
- accessor isNetworkActive: boolean = false;
-
- @property({ attribute: false })
- accessor onNetworkActiveChange:
- | ((isNetworkActive: boolean) => void)
- | undefined;
- // --------- search props end ---------
-
@property({ attribute: false })
accessor serverService!: ServerService;
@@ -206,31 +192,21 @@ export class ChatInputPreference extends SignalWatcher(
})
);
- if (this.networkSearchVisible) {
- searchItems.push(
- menu.toggleSwitch({
- name: 'Web Search',
- prefix: WebIcon(),
- on: this.isNetworkActive,
- onChange: (value: boolean) => this.onNetworkActiveChange?.(value),
- class: { 'preference-action': true },
- testId: 'chat-network-search',
- }),
- menu.toggleSwitch({
- name: 'Workspace All Docs',
- prefix: CloudWorkspaceIcon(),
- on:
- !!this.toolsConfigService.config.value.searchWorkspace &&
- !!this.toolsConfigService.config.value.readingDocs,
- onChange: (value: boolean) =>
- this.toolsConfigService.setConfig({
- searchWorkspace: value,
- readingDocs: value,
- }),
- class: { 'preference-action': true },
- })
- );
- }
+ searchItems.push(
+ menu.toggleSwitch({
+ name: 'Workspace All Docs',
+ prefix: CloudWorkspaceIcon(),
+ on:
+ !!this.toolsConfigService.config.value.searchWorkspace &&
+ !!this.toolsConfigService.config.value.readingDocs,
+ onChange: (value: boolean) =>
+ this.toolsConfigService.setConfig({
+ searchWorkspace: value,
+ readingDocs: value,
+ }),
+ class: { 'preference-action': true },
+ })
+ );
popMenu(popupTargetFromElement(element), {
options: {
diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/type.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/type.ts
index 4cb4dac5db..53e70cc779 100644
--- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/type.ts
+++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-input/type.ts
@@ -4,12 +4,6 @@ import type { AIError } from '../../provider';
import type { ChatContextValue } from '../ai-chat-content';
import type { ChatStatus, HistoryMessage } from '../ai-chat-messages';
-export interface AINetworkSearchConfig {
- visible: Signal;
- enabled: Signal;
- setEnabled: (state: boolean) => void;
-}
-
export interface AIReasoningConfig {
enabled: Signal;
setEnabled: (state: boolean) => void;
diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-messages/ai-chat-messages.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-messages/ai-chat-messages.ts
index 131643caed..9b9c6e399b 100644
--- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-messages/ai-chat-messages.ts
+++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-messages/ai-chat-messages.ts
@@ -24,10 +24,7 @@ import { type AIError, AIProvider, UnauthorizedError } from '../../provider';
import { mergeStreamObjects } from '../../utils/stream-objects';
import type { DocDisplayConfig } from '../ai-chat-chips';
import { type ChatContextValue } from '../ai-chat-content/type';
-import type {
- AINetworkSearchConfig,
- AIReasoningConfig,
-} from '../ai-chat-input';
+import type { AIReasoningConfig } from '../ai-chat-input';
import {
type HistoryMessage,
isChatAction,
@@ -196,9 +193,6 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
@property({ attribute: false })
accessor notificationService!: NotificationService;
- @property({ attribute: false })
- accessor networkSearchConfig!: AINetworkSearchConfig;
-
@property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig;
@@ -224,13 +218,6 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
})
accessor testId = 'chat-panel-messages';
- private get _isNetworkActive() {
- return (
- !!this.networkSearchConfig.visible.value &&
- !!this.networkSearchConfig.enabled.value
- );
- }
-
private get _isReasoningActive() {
return !!this.reasoningConfig.enabled.value;
}
@@ -470,7 +457,6 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
control: 'chat-send',
isRootSession: true,
reasoning: this._isReasoningActive,
- webSearch: this._isNetworkActive,
toolsConfig: this.aiToolsConfigService.config.value,
});
diff --git a/packages/frontend/core/src/blocksuite/ai/components/playground/chat.ts b/packages/frontend/core/src/blocksuite/ai/components/playground/chat.ts
index 9246ea751a..a615143b3c 100644
--- a/packages/frontend/core/src/blocksuite/ai/components/playground/chat.ts
+++ b/packages/frontend/core/src/blocksuite/ai/components/playground/chat.ts
@@ -25,11 +25,7 @@ import { AIProvider } from '../../provider';
import type { SearchMenuConfig } from '../ai-chat-add-context';
import type { DocDisplayConfig } from '../ai-chat-chips';
import type { ChatContextValue } from '../ai-chat-content';
-import type {
- AINetworkSearchConfig,
- AIPlaygroundConfig,
- AIReasoningConfig,
-} from '../ai-chat-input';
+import type { AIPlaygroundConfig, AIReasoningConfig } from '../ai-chat-input';
import {
type AIChatMessages,
type ChatAction,
@@ -147,9 +143,6 @@ export class PlaygroundChat extends SignalWatcher(
@property({ attribute: false })
accessor session!: CopilotChatHistoryFragment | null | undefined;
- @property({ attribute: false })
- accessor networkSearchConfig!: AINetworkSearchConfig;
-
@property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig;
@@ -359,7 +352,6 @@ export class PlaygroundChat extends SignalWatcher(
.affineThemeService=${this.affineThemeService}
.notificationService=${this.notificationService}
.aiToolsConfigService=${this.aiToolsConfigService}
- .networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig}
.messages=${this.messages}
>
@@ -372,7 +364,6 @@ export class PlaygroundChat extends SignalWatcher(
.chatContextValue=${this.chatContextValue}
.updateContext=${this.updateContext}
.onEmbeddingProgressChange=${this.onEmbeddingProgressChange}
- .networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig}
.playgroundConfig=${this.playgroundConfig}
.docDisplayConfig=${this.docDisplayConfig}
diff --git a/packages/frontend/core/src/blocksuite/ai/components/playground/content.ts b/packages/frontend/core/src/blocksuite/ai/components/playground/content.ts
index ed7b58fee2..9064ead626 100644
--- a/packages/frontend/core/src/blocksuite/ai/components/playground/content.ts
+++ b/packages/frontend/core/src/blocksuite/ai/components/playground/content.ts
@@ -16,11 +16,7 @@ import type { AppSidebarConfig } from '../../chat-panel/chat-config';
import { AIProvider } from '../../provider';
import type { SearchMenuConfig } from '../ai-chat-add-context';
import type { DocDisplayConfig } from '../ai-chat-chips';
-import type {
- AINetworkSearchConfig,
- AIPlaygroundConfig,
- AIReasoningConfig,
-} from '../ai-chat-input';
+import type { AIPlaygroundConfig, AIReasoningConfig } from '../ai-chat-input';
export class PlaygroundContent extends SignalWatcher(
WithDisposable(ShadowlessElement)
@@ -64,9 +60,6 @@ export class PlaygroundContent extends SignalWatcher(
@property({ attribute: false })
accessor doc!: Store;
- @property({ attribute: false })
- accessor networkSearchConfig!: AINetworkSearchConfig;
-
@property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig;
@@ -347,7 +340,6 @@ export class PlaygroundContent extends SignalWatcher(
.host=${this.host}
.doc=${this.doc}
.session=${session}
- .networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig}
.playgroundConfig=${this.playgroundConfig}
.appSidebarConfig=${this.appSidebarConfig}
diff --git a/packages/frontend/core/src/blocksuite/ai/extensions/ai-edgeless-root.ts b/packages/frontend/core/src/blocksuite/ai/extensions/ai-edgeless-root.ts
index 37820b2b71..a7b65067ce 100644
--- a/packages/frontend/core/src/blocksuite/ai/extensions/ai-edgeless-root.ts
+++ b/packages/frontend/core/src/blocksuite/ai/extensions/ai-edgeless-root.ts
@@ -1,5 +1,4 @@
import { LifeCycleWatcher } from '@blocksuite/affine/std';
-import type { FrameworkProvider } from '@toeverything/infra';
import { buildAIPanelConfig } from '../ai-panel';
import { setupEdgelessCopilot } from '../entries/edgeless/index';
@@ -7,7 +6,7 @@ import { setupSpaceAIEntry } from '../entries/space/setup-space';
import { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
import { EdgelessCopilotWidget } from '../widgets/edgeless-copilot';
-export function getAIEdgelessRootWatcher(framework: FrameworkProvider) {
+export function getAIEdgelessRootWatcher() {
class AIEdgelessRootWatcher extends LifeCycleWatcher {
static override key = 'ai-edgeless-root-watcher';
@@ -21,7 +20,7 @@ export function getAIEdgelessRootWatcher(framework: FrameworkProvider) {
const component = payload.view;
if (component instanceof AffineAIPanelWidget) {
component.style.width = '430px';
- component.config = buildAIPanelConfig(component, framework);
+ component.config = buildAIPanelConfig(component);
setupSpaceAIEntry(component);
}
diff --git a/packages/frontend/core/src/blocksuite/ai/extensions/ai-page-root.ts b/packages/frontend/core/src/blocksuite/ai/extensions/ai-page-root.ts
index 4560198a2f..065b77ae25 100644
--- a/packages/frontend/core/src/blocksuite/ai/extensions/ai-page-root.ts
+++ b/packages/frontend/core/src/blocksuite/ai/extensions/ai-page-root.ts
@@ -1,11 +1,10 @@
import { LifeCycleWatcher } from '@blocksuite/affine/std';
-import type { FrameworkProvider } from '@toeverything/infra';
import { buildAIPanelConfig } from '../ai-panel';
import { setupSpaceAIEntry } from '../entries/space/setup-space';
import { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
-export function getAIPageRootWatcher(framework: FrameworkProvider) {
+export function getAIPageRootWatcher() {
class AIPageRootWatcher extends LifeCycleWatcher {
static override key = 'ai-page-root-watcher';
@@ -19,7 +18,7 @@ export function getAIPageRootWatcher(framework: FrameworkProvider) {
const component = payload.view;
if (component instanceof AffineAIPanelWidget) {
component.style.width = '630px';
- component.config = buildAIPanelConfig(component, framework);
+ component.config = buildAIPanelConfig(component);
setupSpaceAIEntry(component);
}
});
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 10699daed2..e40403b3dd 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
@@ -40,10 +40,7 @@ import {
import { type AIChatBlockModel } from '../blocks';
import type { SearchMenuConfig } from '../components/ai-chat-add-context';
import type { DocDisplayConfig } from '../components/ai-chat-chips';
-import type {
- AINetworkSearchConfig,
- AIReasoningConfig,
-} from '../components/ai-chat-input';
+import type { AIReasoningConfig } from '../components/ai-chat-input';
import type { ChatMessage } from '../components/ai-chat-messages';
import {
ChatMessagesSchema,
@@ -88,13 +85,6 @@ export class AIChatBlockPeekView extends LitElement {
return this.blockModel.props.rootWorkspaceId;
}
- private get _isNetworkActive() {
- return (
- !!this.networkSearchConfig.visible.value &&
- !!this.networkSearchConfig.enabled.value
- );
- }
-
private get _isReasoningActive() {
return !!this.reasoningConfig.enabled.value;
}
@@ -401,7 +391,6 @@ export class AIChatBlockPeekView extends LitElement {
where: 'ai-chat-block',
control: 'chat-send',
reasoning: this._isReasoningActive,
- webSearch: this._isNetworkActive,
toolsConfig: this.aiToolsConfigService.config.value,
});
@@ -573,12 +562,7 @@ export class AIChatBlockPeekView extends LitElement {
const latestHistoryMessage = _historyMessages[_historyMessages.length - 1];
const latestMessageCreatedAt = latestHistoryMessage.createdAt;
- const {
- chatContext,
- updateContext,
- networkSearchConfig,
- _textRendererOptions,
- } = this;
+ const { chatContext, updateContext, _textRendererOptions } = this;
const { messages: currentChatMessages } = chatContext;
const notificationService = this.host.std.get(NotificationProvider);
@@ -613,7 +597,6 @@ export class AIChatBlockPeekView extends LitElement {
.chatContextValue=${chatContext}
.updateContext=${updateContext}
.onEmbeddingProgressChange=${this.onEmbeddingProgressChange}
- .networkSearchConfig=${networkSearchConfig}
.docDisplayConfig=${this.docDisplayConfig}
.searchMenuConfig=${this.searchMenuConfig}
.affineWorkspaceDialogService=${this.affineWorkspaceDialogService}
@@ -644,9 +627,6 @@ export class AIChatBlockPeekView extends LitElement {
@property({ attribute: false })
accessor host!: EditorHost;
- @property({ attribute: false })
- accessor networkSearchConfig!: AINetworkSearchConfig;
-
@property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig;
@@ -713,7 +693,6 @@ export const AIChatBlockPeekViewTemplate = (
host: EditorHost,
docDisplayConfig: DocDisplayConfig,
searchMenuConfig: SearchMenuConfig,
- networkSearchConfig: AINetworkSearchConfig,
reasoningConfig: AIReasoningConfig,
serverService: ServerService,
affineFeatureFlagService: FeatureFlagService,
@@ -727,7 +706,6 @@ export const AIChatBlockPeekViewTemplate = (
return html` string;
reasoning?: boolean;
- webSearch?: boolean;
modelId?: string;
toolsConfig?: AIToolsConfig;
};
@@ -119,7 +118,6 @@ export function textToText({
endpoint = Endpoint.Stream,
postfix,
reasoning,
- webSearch,
modelId,
toolsConfig,
}: TextToTextOptions) {
@@ -142,7 +140,6 @@ export function textToText({
sessionId,
messageId,
reasoning,
- webSearch,
modelId,
toolsConfig,
},
@@ -205,7 +202,6 @@ export function textToText({
sessionId,
messageId,
reasoning,
- webSearch,
modelId,
});
})(),
diff --git a/packages/frontend/core/src/blocksuite/ai/provider/setup-provider.tsx b/packages/frontend/core/src/blocksuite/ai/provider/setup-provider.tsx
index 91248e0d4c..c9cc43c7fc 100644
--- a/packages/frontend/core/src/blocksuite/ai/provider/setup-provider.tsx
+++ b/packages/frontend/core/src/blocksuite/ai/provider/setup-provider.tsx
@@ -83,7 +83,7 @@ export function setupAIProvider(
//#region actions
AIProvider.provide('chat', async options => {
- const { input, contexts, webSearch } = options;
+ const { input, contexts } = options;
const sessionId = await createSession({
promptName: 'Chat With AFFiNE AI',
@@ -102,7 +102,6 @@ export function setupAIProvider(
selectedSnapshot: contexts?.selectedSnapshot,
selectedMarkdown: contexts?.selectedMarkdown,
html: contexts?.html,
- searchMode: webSearch ? 'MUST' : 'AUTO',
},
endpoint: Endpoint.StreamObject,
});
diff --git a/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/ai-panel.ts b/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/ai-panel.ts
index 7c2b3cb3e4..2c8b970c4b 100644
--- a/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/ai-panel.ts
+++ b/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/ai-panel.ts
@@ -523,7 +523,6 @@ export class AffineAIPanelWidget extends WidgetComponent {
.onBlur=${this._discardWithConfirmation}
.onFinish=${this._inputFinish}
.onInput=${this.onInput}
- .networkSearchConfig=${config.networkSearchConfig}
.theme=${theme}
>`,
],
diff --git a/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts b/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts
index 72c6e188e7..08d5a64cdf 100644
--- a/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts
+++ b/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts
@@ -1,4 +1,3 @@
-import type { Signal } from '@preact/signals-core';
import type { nothing, TemplateResult } from 'lit';
import type { StreamObject } from '../../components/ai-chat-messages';
@@ -29,12 +28,6 @@ export interface AIPanelGeneratingConfig {
stages?: string[];
}
-export interface AINetworkSearchConfig {
- visible: Signal;
- enabled: Signal;
- setEnabled: (state: boolean) => void;
-}
-
export type AIActionAnswer = {
content: string;
streamObjects?: StreamObject[];
@@ -56,7 +49,6 @@ export interface AffineAIPanelWidgetConfig {
finishStateConfig: AIPanelAnswerConfig;
generatingStateConfig: AIPanelGeneratingConfig;
errorStateConfig: AIPanelErrorConfig;
- networkSearchConfig: AINetworkSearchConfig;
hideCallback?: () => void;
discardCallback?: () => void;
inputCallback?: (input: string) => void;
diff --git a/packages/frontend/core/src/blocksuite/view-extensions/ai/index.ts b/packages/frontend/core/src/blocksuite/view-extensions/ai/index.ts
index c92299eede..fb54cf9c90 100644
--- a/packages/frontend/core/src/blocksuite/view-extensions/ai/index.ts
+++ b/packages/frontend/core/src/blocksuite/view-extensions/ai/index.ts
@@ -72,7 +72,7 @@ export class AIViewExtension extends ViewExtensionProvider {
context.register([
CopilotTool,
edgelessCopilotWidget,
- getAIEdgelessRootWatcher(framework),
+ getAIEdgelessRootWatcher(),
// In note
ToolbarModuleExtension({
id: BlockFlavourIdentifier('custom:affine:surface:*'),
@@ -84,7 +84,7 @@ export class AIViewExtension extends ViewExtensionProvider {
context.register([
blockDiffWidgetForPage,
blockDiffWidgetForBlock,
- getAIPageRootWatcher(framework),
+ getAIPageRootWatcher(),
BlockDiffService,
BlockDiffWatcher,
]);
diff --git a/packages/frontend/core/src/components/hooks/affine/use-ai-chat-config.ts b/packages/frontend/core/src/components/hooks/affine/use-ai-chat-config.ts
index 211b316a65..a6e2ee50de 100644
--- a/packages/frontend/core/src/components/hooks/affine/use-ai-chat-config.ts
+++ b/packages/frontend/core/src/components/hooks/affine/use-ai-chat-config.ts
@@ -1,5 +1,4 @@
// packages/frontend/core/src/blocksuite/ai/hooks/useChatPanelConfig.ts
-import { AINetworkSearchService } from '@affine/core/modules/ai-button/services/network-search';
import { AIPlaygroundService } from '@affine/core/modules/ai-button/services/playground';
import { AIReasoningService } from '@affine/core/modules/ai-button/services/reasoning';
import { CollectionService } from '@affine/core/modules/collection';
@@ -20,7 +19,6 @@ import { useFramework } from '@toeverything/infra';
export function useAIChatConfig() {
const framework = useFramework();
- const searchService = framework.get(AINetworkSearchService);
const reasoningService = framework.get(AIReasoningService);
const playgroundService = framework.get(AIPlaygroundService);
const docDisplayMetaService = framework.get(DocDisplayMetaService);
@@ -31,12 +29,6 @@ export function useAIChatConfig() {
const collectionService = framework.get(CollectionService);
const docsService = framework.get(DocsService);
- const networkSearchConfig = {
- visible: searchService.visible,
- enabled: searchService.enabled,
- setEnabled: searchService.setEnabled,
- };
-
const reasoningConfig = {
enabled: reasoningService.enabled,
setEnabled: reasoningService.setEnabled,
@@ -126,7 +118,6 @@ export function useAIChatConfig() {
};
return {
- networkSearchConfig,
reasoningConfig,
docDisplayConfig,
searchMenuConfig,
diff --git a/packages/frontend/core/src/desktop/pages/workspace/chat/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/chat/index.tsx
index 7001dd2971..27b85f5eb2 100644
--- a/packages/frontend/core/src/desktop/pages/workspace/chat/index.tsx
+++ b/packages/frontend/core/src/desktop/pages/workspace/chat/index.tsx
@@ -106,12 +106,8 @@ export const Component = () => {
const workspaceId = useService(WorkspaceService).workspace.id;
- const {
- docDisplayConfig,
- searchMenuConfig,
- networkSearchConfig,
- reasoningConfig,
- } = useAIChatConfig();
+ const { docDisplayConfig, searchMenuConfig, reasoningConfig } =
+ useAIChatConfig();
const createSession = useCallback(
async (options: Partial = {}) => {
@@ -218,7 +214,6 @@ export const Component = () => {
content.host = mockStd?.host;
content.docDisplayConfig = docDisplayConfig;
content.searchMenuConfig = searchMenuConfig;
- content.networkSearchConfig = networkSearchConfig;
content.reasoningConfig = reasoningConfig;
content.onContextChange = onContextChange;
content.affineFeatureFlagService = framework.get(FeatureFlagService);
@@ -256,7 +251,6 @@ export const Component = () => {
framework,
isBodyProvided,
mockStd,
- networkSearchConfig,
reasoningConfig,
searchMenuConfig,
workspaceId,
diff --git a/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/chat.tsx b/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/chat.tsx
index f5dd23b6b2..97ae4d35a6 100644
--- a/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/chat.tsx
+++ b/packages/frontend/core/src/desktop/pages/workspace/detail-page/tabs/chat.tsx
@@ -58,7 +58,6 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
const {
docDisplayConfig,
searchMenuConfig,
- networkSearchConfig,
reasoningConfig,
playgroundConfig,
} = useAIChatConfig();
@@ -88,7 +87,6 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
chatPanelRef.current.docDisplayConfig = docDisplayConfig;
chatPanelRef.current.searchMenuConfig = searchMenuConfig;
- chatPanelRef.current.networkSearchConfig = networkSearchConfig;
chatPanelRef.current.reasoningConfig = reasoningConfig;
chatPanelRef.current.playgroundConfig = playgroundConfig;
chatPanelRef.current.extensions = specs;
@@ -139,7 +137,6 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
docDisplayConfig,
editor,
framework,
- networkSearchConfig,
searchMenuConfig,
reasoningConfig,
playgroundConfig,
diff --git a/packages/frontend/core/src/modules/ai-button/index.ts b/packages/frontend/core/src/modules/ai-button/index.ts
index 08f541f813..26fbf585ce 100644
--- a/packages/frontend/core/src/modules/ai-button/index.ts
+++ b/packages/frontend/core/src/modules/ai-button/index.ts
@@ -16,7 +16,6 @@ import { AIButtonProvider } from './provider/ai-button';
import { AIButtonService } from './services/ai-button';
import { AIDraftService } from './services/ai-draft';
import { AIModelService } from './services/models';
-import { AINetworkSearchService } from './services/network-search';
import { AIPlaygroundService } from './services/playground';
import { AIReasoningService } from './services/reasoning';
import { AIToolsConfigService } from './services/tools-config';
@@ -27,13 +26,6 @@ export const configureAIButtonModule = (framework: Framework) => {
});
};
-export function configureAINetworkSearchModule(framework: Framework) {
- framework.service(AINetworkSearchService, [
- GlobalStateService,
- FeatureFlagService,
- ]);
-}
-
export function configureAIReasoningModule(framework: Framework) {
framework.service(AIReasoningService, [GlobalStateService]);
}
diff --git a/packages/frontend/core/src/modules/ai-button/services/network-search.ts b/packages/frontend/core/src/modules/ai-button/services/network-search.ts
deleted file mode 100644
index 4c8885cff1..0000000000
--- a/packages/frontend/core/src/modules/ai-button/services/network-search.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import {
- createSignalFromObservable,
- type Signal,
-} from '@blocksuite/affine/shared/utils';
-import { LiveData, Service } from '@toeverything/infra';
-
-import type { FeatureFlagService } from '../../feature-flag';
-import type { GlobalStateService } from '../../storage';
-
-const AI_NETWORK_SEARCH_KEY = 'AINetworkSearch';
-
-export class AINetworkSearchService extends Service {
- constructor(
- private readonly globalStateService: GlobalStateService,
- private readonly featureFlagService: FeatureFlagService
- ) {
- super();
-
- const { signal: enabled, cleanup: enabledCleanup } =
- createSignalFromObservable(
- this._enabled$,
- undefined
- );
- this.enabled = enabled;
- this.disposables.push(enabledCleanup);
-
- const { signal: visible, cleanup: visibleCleanup } =
- createSignalFromObservable(
- this._visible$,
- undefined
- );
- this.visible = visible;
- this.disposables.push(visibleCleanup);
- }
-
- visible: Signal;
-
- enabled: Signal;
-
- private readonly _visible$ =
- this.featureFlagService.flags.enable_ai_network_search.$;
-
- private readonly _enabled$ = LiveData.from(
- this.globalStateService.globalState.watch(AI_NETWORK_SEARCH_KEY),
- undefined
- );
-
- setEnabled = (enabled: boolean) => {
- this.globalStateService.globalState.set(AI_NETWORK_SEARCH_KEY, enabled);
- };
-}
diff --git a/packages/frontend/core/src/modules/index.ts b/packages/frontend/core/src/modules/index.ts
index 890adefe58..5104cbc98e 100644
--- a/packages/frontend/core/src/modules/index.ts
+++ b/packages/frontend/core/src/modules/index.ts
@@ -5,7 +5,6 @@ import {
configureAIButtonModule,
configureAIDraftModule,
configureAIModelModule,
- configureAINetworkSearchModule,
configureAIPlaygroundModule,
configureAIReasoningModule,
configureAIToolsConfigModule,
@@ -114,7 +113,6 @@ export function configureCommonModules(framework: Framework) {
configSearchMenuModule(framework);
configureDndModule(framework);
configureCommonGlobalStorageImpls(framework);
- configureAINetworkSearchModule(framework);
configureAIReasoningModule(framework);
configureAIPlaygroundModule(framework);
configureAIButtonModule(framework);
diff --git a/packages/frontend/core/src/modules/peek-view/view/ai-chat-block-peek-view/index.tsx b/packages/frontend/core/src/modules/peek-view/view/ai-chat-block-peek-view/index.tsx
index c34b6e3c22..57c5ef1c3b 100644
--- a/packages/frontend/core/src/modules/peek-view/view/ai-chat-block-peek-view/index.tsx
+++ b/packages/frontend/core/src/modules/peek-view/view/ai-chat-block-peek-view/index.tsx
@@ -24,12 +24,8 @@ export const AIChatBlockPeekView = ({
model,
host,
}: AIChatBlockPeekViewProps) => {
- const {
- docDisplayConfig,
- searchMenuConfig,
- networkSearchConfig,
- reasoningConfig,
- } = useAIChatConfig();
+ const { docDisplayConfig, searchMenuConfig, reasoningConfig } =
+ useAIChatConfig();
const framework = useFramework();
const serverService = framework.get(ServerService);
@@ -47,7 +43,6 @@ export const AIChatBlockPeekView = ({
host,
docDisplayConfig,
searchMenuConfig,
- networkSearchConfig,
reasoningConfig,
serverService,
affineFeatureFlagService,
@@ -64,7 +59,6 @@ export const AIChatBlockPeekView = ({
host,
docDisplayConfig,
searchMenuConfig,
- networkSearchConfig,
reasoningConfig,
serverService,
affineFeatureFlagService,
diff --git a/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts b/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts
index 619bdeb01b..a79647bcf9 100644
--- a/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts
+++ b/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts
@@ -10,7 +10,6 @@ test.describe('AIChatWith/Network', () => {
loggedInPage: page,
utils,
}) => {
- await utils.chatPanel.enableNetworkSearch(page);
await utils.chatPanel.makeChat(
page,
'What is the weather like in Shanghai today?'
diff --git a/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts b/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts
index 25b2df1d92..bdf0cc5126 100644
--- a/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts
+++ b/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts
@@ -337,22 +337,6 @@ export class ChatPanelUtils {
});
}
- public static async enableNetworkSearch(page: Page) {
- await this.openChatInputPreference(page);
- const networkSearch = page.getByTestId('chat-network-search');
- if ((await networkSearch.getAttribute('data-active')) === 'false') {
- await networkSearch.click();
- }
- }
-
- public static async disableNetworkSearch(page: Page) {
- await this.openChatInputPreference(page);
- const networkSearch = page.getByTestId('chat-network-search');
- if ((await networkSearch.getAttribute('data-active')) === 'true') {
- await networkSearch.click();
- }
- }
-
public static async enableReasoning(page: Page) {
await this.openChatInputPreference(page);
const reasoning = page.getByTestId('chat-reasoning');
@@ -368,9 +352,4 @@ export class ChatPanelUtils {
await reasoning.click();
}
}
-
- public static async isNetworkSearchEnabled(page: Page) {
- const networkSearch = await page.getByTestId('chat-network-search');
- return (await networkSearch.getAttribute('aria-disabled')) === 'false';
- }
}