feat: cleanup chat panel (#14258)

#### PR Dependency Tree


* **PR #14258** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->


#### PR Dependency Tree


* **PR #14258** 👈
  * **PR #14259**

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
DarkSky
2026-01-15 19:20:55 +08:00
committed by GitHub
parent ac7a95e708
commit 00a458543f
32 changed files with 45 additions and 334 deletions

View File

@@ -24,10 +24,7 @@ import {
} from '../utils/selection-utils'; } from '../utils/selection-utils';
import { mergeStreamObjects } from '../utils/stream-objects'; import { mergeStreamObjects } from '../utils/stream-objects';
import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel'; import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
import type { import type { AIActionAnswer } from '../widgets/ai-panel/type';
AIActionAnswer,
AINetworkSearchConfig,
} from '../widgets/ai-panel/type';
import { actionToAnswerRenderer } from './answer-renderer'; import { actionToAnswerRenderer } from './answer-renderer';
export function bindTextStream( export function bindTextStream(
@@ -89,8 +86,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
Parameters<BlockSuitePresets.AIActions[T]>[0], Parameters<BlockSuitePresets.AIActions[T]>[0],
keyof BlockSuitePresets.AITextActionOptions keyof BlockSuitePresets.AITextActionOptions
>, >,
trackerOptions?: BlockSuitePresets.TrackerOptions, trackerOptions?: BlockSuitePresets.TrackerOptions
networkConfig?: AINetworkSearchConfig
): BlockSuitePresets.TextStream | undefined { ): BlockSuitePresets.TextStream | undefined {
const action = AIProvider.actions[id]; const action = AIProvider.actions[id];
if (!action || typeof action !== 'function') return; if (!action || typeof action !== 'function') return;
@@ -115,7 +111,6 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
const models = selectedBlocks?.map(block => block.model); const models = selectedBlocks?.map(block => block.model);
const control = trackerOptions?.control ?? 'format-bar'; const control = trackerOptions?.control ?? 'format-bar';
const where = trackerOptions?.where ?? 'ai-panel'; const where = trackerOptions?.where ?? 'ai-panel';
const { visible, enabled } = networkConfig ?? {};
const options = { const options = {
...variants, ...variants,
attachments, attachments,
@@ -128,7 +123,6 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
where, where,
docId: host.store.id, docId: host.store.id,
workspaceId: host.store.workspace.id, workspaceId: host.store.workspace.id,
webSearch: visible?.value && enabled?.value,
} as Parameters<typeof action>[0]; } as Parameters<typeof action>[0];
// @ts-expect-error TODO(@Peng): maybe fix this // @ts-expect-error TODO(@Peng): maybe fix this
stream = await action(options); stream = await action(options);
@@ -145,8 +139,7 @@ function actionToGenerateAnswer<T extends keyof BlockSuitePresets.AIActions>(
Parameters<BlockSuitePresets.AIActions[T]>[0], Parameters<BlockSuitePresets.AIActions[T]>[0],
keyof BlockSuitePresets.AITextActionOptions keyof BlockSuitePresets.AITextActionOptions
>, >,
trackerOptions?: BlockSuitePresets.TrackerOptions, trackerOptions?: BlockSuitePresets.TrackerOptions
networkConfig?: AINetworkSearchConfig
) { ) {
return ({ return ({
input, input,
@@ -167,8 +160,7 @@ function actionToGenerateAnswer<T extends keyof BlockSuitePresets.AIActions>(
input, input,
signal, signal,
variants, variants,
trackerOptions, trackerOptions
networkConfig
); );
if (!stream) return; if (!stream) return;
bindTextStream(stream, { update, finish, signal }); bindTextStream(stream, { update, finish, signal });
@@ -196,8 +188,7 @@ function updateAIPanelConfig<T extends keyof BlockSuitePresets.AIActions>(
host, host,
id, id,
variants, variants,
trackerOptions, trackerOptions
config.networkSearchConfig
); );
const ctx = new AIContext(); const ctx = new AIContext();

View File

@@ -37,10 +37,7 @@ import {
getSelections, getSelections,
} from '../utils/selection-utils'; } from '../utils/selection-utils';
import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel'; import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
import type { import type { AIActionAnswer } from '../widgets/ai-panel/type';
AIActionAnswer,
AINetworkSearchConfig,
} from '../widgets/ai-panel/type';
import type { EdgelessCopilotWidget } from '../widgets/edgeless-copilot'; import type { EdgelessCopilotWidget } from '../widgets/edgeless-copilot';
import { actionToAnswerRenderer } from './answer-renderer'; import { actionToAnswerRenderer } from './answer-renderer';
import { EXCLUDING_COPY_ACTIONS } from './consts'; import { EXCLUDING_COPY_ACTIONS } from './consts';
@@ -179,8 +176,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
seed?: string; seed?: string;
} | void>, } | void>,
trackerOptions?: BlockSuitePresets.TrackerOptions, trackerOptions?: BlockSuitePresets.TrackerOptions,
panelInput?: string, panelInput?: string
networkConfig?: AINetworkSearchConfig
) { ) {
const action = AIProvider.actions[id]; const action = AIProvider.actions[id];
@@ -194,7 +190,6 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
return { return {
async *[Symbol.asyncIterator]() { async *[Symbol.asyncIterator]() {
const models = getCopilotSelectedElems(host); const models = getCopilotSelectedElems(host);
const { visible, enabled } = networkConfig ?? {};
const options = { const options = {
...variants, ...variants,
signal, signal,
@@ -206,7 +201,6 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
host, host,
docId: host.store.id, docId: host.store.id,
workspaceId: host.store.workspace.id, workspaceId: host.store.workspace.id,
webSearch: visible?.value && enabled?.value,
} as Parameters<typeof action>[0]; } as Parameters<typeof action>[0];
const content = ctx.get().content; const content = ctx.get().content;
@@ -273,8 +267,7 @@ function actionToGeneration<T extends keyof BlockSuitePresets.AIActions>(
attachments?: (string | Blob)[]; attachments?: (string | Blob)[];
seed?: string; seed?: string;
} | void>, } | void>,
trackerOptions?: BlockSuitePresets.TrackerOptions, trackerOptions?: BlockSuitePresets.TrackerOptions
networkConfig?: AINetworkSearchConfig
) { ) {
return (host: EditorHost, ctx: AIContext) => { return (host: EditorHost, ctx: AIContext) => {
return ({ return ({
@@ -299,8 +292,7 @@ function actionToGeneration<T extends keyof BlockSuitePresets.AIActions>(
variants, variants,
extract, extract,
trackerOptions, trackerOptions,
input, input
networkConfig
)?.(host, ctx); )?.(host, ctx);
if (!stream) return; if (!stream) return;
@@ -341,8 +333,7 @@ function updateEdgelessAIPanelConfig<
id, id,
variants, variants,
customInput, customInput,
trackerOptions, trackerOptions
config.networkSearchConfig
)(host, ctx); )(host, ctx);
config.finishStateConfig = actionToResponse(id, host, ctx, variants); config.finishStateConfig = actionToResponse(id, host, ctx, variants);
config.generatingStateConfig = actionToGenerating(id, generatingIcon); config.generatingStateConfig = actionToGenerating(id, generatingIcon);

View File

@@ -142,7 +142,6 @@ declare global {
interface ChatOptions extends AITextActionOptions { interface ChatOptions extends AITextActionOptions {
sessionId?: string; sessionId?: string;
isRootSession?: boolean; isRootSession?: boolean;
webSearch?: boolean;
reasoning?: boolean; reasoning?: boolean;
modelId?: string; modelId?: string;
toolsConfig?: AIToolsConfig | undefined; toolsConfig?: AIToolsConfig | undefined;

View File

@@ -1,4 +1,3 @@
import { AINetworkSearchService } from '@affine/core/modules/ai-button/services/network-search';
import { Bound } from '@blocksuite/affine/global/gfx'; import { Bound } from '@blocksuite/affine/global/gfx';
import { import {
ImageBlockModel, ImageBlockModel,
@@ -22,7 +21,6 @@ import {
ReplaceIcon, ReplaceIcon,
ResetIcon, ResetIcon,
} from '@blocksuite/icons/lit'; } from '@blocksuite/icons/lit';
import type { FrameworkProvider } from '@toeverything/infra';
import type { TemplateResult } from 'lit'; import type { TemplateResult } from 'lit';
import { insertFromMarkdown } from '../utils'; import { insertFromMarkdown } from '../utils';
@@ -301,11 +299,9 @@ export function buildCopyConfig(panel: AffineAIPanelWidget) {
} }
export function buildAIPanelConfig( export function buildAIPanelConfig(
panel: AffineAIPanelWidget, panel: AffineAIPanelWidget
framework: FrameworkProvider
): AffineAIPanelWidgetConfig { ): AffineAIPanelWidgetConfig {
const ctx = new AIContext(); const ctx = new AIContext();
const searchService = framework.get(AINetworkSearchService);
return { return {
answerRenderer: createAIScrollableTextRenderer( answerRenderer: createAIScrollableTextRenderer(
{ {
@@ -318,10 +314,5 @@ export function buildAIPanelConfig(
generatingStateConfig: buildGeneratingConfig(), generatingStateConfig: buildGeneratingConfig(),
errorStateConfig: buildErrorConfig(panel), errorStateConfig: buildErrorConfig(panel),
copy: buildCopyConfig(panel), copy: buildCopyConfig(panel),
networkSearchConfig: {
visible: searchService.visible,
enabled: searchService.enabled,
setEnabled: searchService.setEnabled,
},
}; };
} }

View File

@@ -17,7 +17,6 @@ import { property } from 'lit/decorators.js';
import type { SearchMenuConfig } from '../components/ai-chat-add-context'; import type { SearchMenuConfig } from '../components/ai-chat-add-context';
import type { DocDisplayConfig } from '../components/ai-chat-chips'; import type { DocDisplayConfig } from '../components/ai-chat-chips';
import type { import type {
AINetworkSearchConfig,
AIPlaygroundConfig, AIPlaygroundConfig,
AIReasoningConfig, AIReasoningConfig,
} from '../components/ai-chat-input'; } from '../components/ai-chat-input';
@@ -80,9 +79,6 @@ export class AIChatPanelTitle extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor appSidebarConfig!: AppSidebarConfig; accessor appSidebarConfig!: AppSidebarConfig;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -142,7 +138,6 @@ export class AIChatPanelTitle extends SignalWatcher(
<playground-content <playground-content
.host=${this.host} .host=${this.host}
.doc=${this.doc} .doc=${this.doc}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.playgroundConfig=${this.playgroundConfig} .playgroundConfig=${this.playgroundConfig}
.appSidebarConfig=${this.appSidebarConfig} .appSidebarConfig=${this.appSidebarConfig}

View File

@@ -32,7 +32,6 @@ import type { SearchMenuConfig } from '../components/ai-chat-add-context';
import type { DocDisplayConfig } from '../components/ai-chat-chips'; import type { DocDisplayConfig } from '../components/ai-chat-chips';
import type { ChatContextValue } from '../components/ai-chat-content'; import type { ChatContextValue } from '../components/ai-chat-content';
import type { import type {
AINetworkSearchConfig,
AIPlaygroundConfig, AIPlaygroundConfig,
AIReasoningConfig, AIReasoningConfig,
} from '../components/ai-chat-input'; } from '../components/ai-chat-input';
@@ -95,9 +94,6 @@ export class ChatPanel extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor appSidebarConfig!: AppSidebarConfig; accessor appSidebarConfig!: AppSidebarConfig;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -430,7 +426,6 @@ export class ChatPanel extends SignalWatcher(
.doc=${this.doc} .doc=${this.doc}
.playgroundConfig=${this.playgroundConfig} .playgroundConfig=${this.playgroundConfig}
.appSidebarConfig=${this.appSidebarConfig} .appSidebarConfig=${this.appSidebarConfig}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.searchMenuConfig=${this.searchMenuConfig} .searchMenuConfig=${this.searchMenuConfig}
.docDisplayConfig=${this.docDisplayConfig} .docDisplayConfig=${this.docDisplayConfig}
@@ -458,7 +453,6 @@ export class ChatPanel extends SignalWatcher(
.createSession=${this.createSession} .createSession=${this.createSession}
.workspaceId=${this.doc.workspace.id} .workspaceId=${this.doc.workspace.id}
.docId=${this.doc.id} .docId=${this.doc.id}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.searchMenuConfig=${this.searchMenuConfig} .searchMenuConfig=${this.searchMenuConfig}
.docDisplayConfig=${this.docDisplayConfig} .docDisplayConfig=${this.docDisplayConfig}

View File

@@ -55,11 +55,7 @@ import {
isTagChip, isTagChip,
omitChip, omitChip,
} from '../ai-chat-chips'; } from '../ai-chat-chips';
import type { import type { AIChatInputContext, AIReasoningConfig } from '../ai-chat-input';
AIChatInputContext,
AINetworkSearchConfig,
AIReasoningConfig,
} from '../ai-chat-input';
import { MAX_IMAGE_COUNT } from '../ai-chat-input/const'; import { MAX_IMAGE_COUNT } from '../ai-chat-input/const';
export const EMBEDDING_STATUS_CHECK_INTERVAL = 10000; export const EMBEDDING_STATUS_CHECK_INTERVAL = 10000;
@@ -113,9 +109,6 @@ export class AIChatComposer extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor docDisplayConfig!: DocDisplayConfig; accessor docDisplayConfig!: DocDisplayConfig;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -199,7 +192,6 @@ export class AIChatComposer extends SignalWatcher(
.createSession=${this.createSession} .createSession=${this.createSession}
.chatContextValue=${this.chatContextValue} .chatContextValue=${this.chatContextValue}
.updateContext=${this.updateContext} .updateContext=${this.updateContext}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.docDisplayConfig=${this.docDisplayConfig} .docDisplayConfig=${this.docDisplayConfig}
.searchMenuConfig=${this.searchMenuConfig} .searchMenuConfig=${this.searchMenuConfig}

View File

@@ -33,10 +33,7 @@ import { type AIChatParams, AIProvider } from '../../provider/ai-provider';
import { extractSelectedContent } from '../../utils/extract'; import { extractSelectedContent } from '../../utils/extract';
import type { SearchMenuConfig } from '../ai-chat-add-context'; import type { SearchMenuConfig } from '../ai-chat-add-context';
import type { DocDisplayConfig } from '../ai-chat-chips'; import type { DocDisplayConfig } from '../ai-chat-chips';
import type { import type { AIReasoningConfig } from '../ai-chat-input';
AINetworkSearchConfig,
AIReasoningConfig,
} from '../ai-chat-input';
import { import {
type AIChatMessages, type AIChatMessages,
type ChatAction, type ChatAction,
@@ -139,9 +136,6 @@ export class AIChatContent extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor docId: string | undefined; accessor docId: string | undefined;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -450,7 +444,6 @@ export class AIChatContent extends SignalWatcher(
.affineThemeService=${this.affineThemeService} .affineThemeService=${this.affineThemeService}
.notificationService=${this.notificationService} .notificationService=${this.notificationService}
.aiToolsConfigService=${this.aiToolsConfigService} .aiToolsConfigService=${this.aiToolsConfigService}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.width=${this.width} .width=${this.width}
.independentMode=${this.independentMode} .independentMode=${this.independentMode}
@@ -474,7 +467,6 @@ export class AIChatContent extends SignalWatcher(
.chatContextValue=${this.chatContextValue} .chatContextValue=${this.chatContextValue}
.updateContext=${this.updateContext} .updateContext=${this.updateContext}
.onEmbeddingProgressChange=${this.onEmbeddingProgressChange} .onEmbeddingProgressChange=${this.onEmbeddingProgressChange}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.docDisplayConfig=${this.docDisplayConfig} .docDisplayConfig=${this.docDisplayConfig}
.searchMenuConfig=${this.searchMenuConfig} .searchMenuConfig=${this.searchMenuConfig}

View File

@@ -33,11 +33,7 @@ import {
isChatMessage, isChatMessage,
StreamObjectSchema, StreamObjectSchema,
} from '../ai-chat-messages'; } from '../ai-chat-messages';
import type { import type { AIChatInputContext, AIReasoningConfig } from './type';
AIChatInputContext,
AINetworkSearchConfig,
AIReasoningConfig,
} from './type';
function getFirstTwoLines(text: string) { function getFirstTwoLines(text: string) {
const lines = text.split('\n'); const lines = text.split('\n');
@@ -350,9 +346,6 @@ export class AIChatInput extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor addChip!: (chip: ChatChip, silent?: boolean) => Promise<void>; accessor addChip!: (chip: ChatChip, silent?: boolean) => Promise<void>;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -401,13 +394,6 @@ export class AIChatInput extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor portalContainer: HTMLElement | null = null; accessor portalContainer: HTMLElement | null = null;
private get _isNetworkActive() {
return (
!!this.networkSearchConfig.visible.value &&
!!this.networkSearchConfig.enabled.value
);
}
private get _isReasoningActive() { private get _isReasoningActive() {
return !!this.reasoningConfig.enabled.value; return !!this.reasoningConfig.enabled.value;
} }
@@ -536,9 +522,6 @@ export class AIChatInput extends SignalWatcher(
.session=${this.session} .session=${this.session}
.extendedThinking=${this._isReasoningActive} .extendedThinking=${this._isReasoningActive}
.onExtendedThinkingChange=${this._toggleReasoning} .onExtendedThinkingChange=${this._toggleReasoning}
.networkSearchVisible=${!!this.networkSearchConfig.visible.value}
.isNetworkActive=${this._isNetworkActive}
.onNetworkActiveChange=${this._toggleNetworkSearch}
.serverService=${this.serverService} .serverService=${this.serverService}
.toolsConfigService=${this.aiToolsConfigService} .toolsConfigService=${this.aiToolsConfigService}
.notificationService=${this.notificationService} .notificationService=${this.notificationService}
@@ -634,10 +617,6 @@ export class AIChatInput extends SignalWatcher(
reportResponse('aborted:stop'); reportResponse('aborted:stop');
}; };
private readonly _toggleNetworkSearch = (isNetworkActive: boolean) => {
this.networkSearchConfig.setEnabled(isNetworkActive);
};
private readonly _toggleReasoning = (extendedThinking: boolean) => { private readonly _toggleReasoning = (extendedThinking: boolean) => {
this.reasoningConfig.setEnabled(extendedThinking); this.reasoningConfig.setEnabled(extendedThinking);
}; };
@@ -732,7 +711,6 @@ export class AIChatInput extends SignalWatcher(
isRootSession: this.isRootSession, isRootSession: this.isRootSession,
where: this.trackOptions?.where, where: this.trackOptions?.where,
control: this.trackOptions?.control, control: this.trackOptions?.control,
webSearch: this._isNetworkActive,
reasoning: this._isReasoningActive, reasoning: this._isReasoningActive,
toolsConfig: this.aiToolsConfigService.config.value, toolsConfig: this.aiToolsConfigService.config.value,
modelId, modelId,

View File

@@ -24,7 +24,6 @@ import {
DoneIcon, DoneIcon,
LockIcon, LockIcon,
ThinkingIcon, ThinkingIcon,
WebIcon,
} from '@blocksuite/icons/lit'; } from '@blocksuite/icons/lit';
import { ShadowlessElement } from '@blocksuite/std'; import { ShadowlessElement } from '@blocksuite/std';
import { computed } from '@preact/signals-core'; import { computed } from '@preact/signals-core';
@@ -101,19 +100,6 @@ export class ChatInputPreference extends SignalWatcher(
| undefined; | undefined;
// --------- extended thinking props end --------- // --------- 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 }) @property({ attribute: false })
accessor serverService!: ServerService; accessor serverService!: ServerService;
@@ -206,31 +192,21 @@ export class ChatInputPreference extends SignalWatcher(
}) })
); );
if (this.networkSearchVisible) { searchItems.push(
searchItems.push( menu.toggleSwitch({
menu.toggleSwitch({ name: 'Workspace All Docs',
name: 'Web Search', prefix: CloudWorkspaceIcon(),
prefix: WebIcon(), on:
on: this.isNetworkActive, !!this.toolsConfigService.config.value.searchWorkspace &&
onChange: (value: boolean) => this.onNetworkActiveChange?.(value), !!this.toolsConfigService.config.value.readingDocs,
class: { 'preference-action': true }, onChange: (value: boolean) =>
testId: 'chat-network-search', this.toolsConfigService.setConfig({
}), searchWorkspace: value,
menu.toggleSwitch({ readingDocs: value,
name: 'Workspace All Docs', }),
prefix: CloudWorkspaceIcon(), class: { 'preference-action': true },
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), { popMenu(popupTargetFromElement(element), {
options: { options: {

View File

@@ -4,12 +4,6 @@ import type { AIError } from '../../provider';
import type { ChatContextValue } from '../ai-chat-content'; import type { ChatContextValue } from '../ai-chat-content';
import type { ChatStatus, HistoryMessage } from '../ai-chat-messages'; import type { ChatStatus, HistoryMessage } from '../ai-chat-messages';
export interface AINetworkSearchConfig {
visible: Signal<boolean | undefined>;
enabled: Signal<boolean | undefined>;
setEnabled: (state: boolean) => void;
}
export interface AIReasoningConfig { export interface AIReasoningConfig {
enabled: Signal<boolean | undefined>; enabled: Signal<boolean | undefined>;
setEnabled: (state: boolean) => void; setEnabled: (state: boolean) => void;

View File

@@ -24,10 +24,7 @@ import { type AIError, AIProvider, UnauthorizedError } from '../../provider';
import { mergeStreamObjects } from '../../utils/stream-objects'; import { mergeStreamObjects } from '../../utils/stream-objects';
import type { DocDisplayConfig } from '../ai-chat-chips'; import type { DocDisplayConfig } from '../ai-chat-chips';
import { type ChatContextValue } from '../ai-chat-content/type'; import { type ChatContextValue } from '../ai-chat-content/type';
import type { import type { AIReasoningConfig } from '../ai-chat-input';
AINetworkSearchConfig,
AIReasoningConfig,
} from '../ai-chat-input';
import { import {
type HistoryMessage, type HistoryMessage,
isChatAction, isChatAction,
@@ -196,9 +193,6 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
@property({ attribute: false }) @property({ attribute: false })
accessor notificationService!: NotificationService; accessor notificationService!: NotificationService;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -224,13 +218,6 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
}) })
accessor testId = 'chat-panel-messages'; accessor testId = 'chat-panel-messages';
private get _isNetworkActive() {
return (
!!this.networkSearchConfig.visible.value &&
!!this.networkSearchConfig.enabled.value
);
}
private get _isReasoningActive() { private get _isReasoningActive() {
return !!this.reasoningConfig.enabled.value; return !!this.reasoningConfig.enabled.value;
} }
@@ -470,7 +457,6 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
control: 'chat-send', control: 'chat-send',
isRootSession: true, isRootSession: true,
reasoning: this._isReasoningActive, reasoning: this._isReasoningActive,
webSearch: this._isNetworkActive,
toolsConfig: this.aiToolsConfigService.config.value, toolsConfig: this.aiToolsConfigService.config.value,
}); });

View File

@@ -25,11 +25,7 @@ import { AIProvider } from '../../provider';
import type { SearchMenuConfig } from '../ai-chat-add-context'; import type { SearchMenuConfig } from '../ai-chat-add-context';
import type { DocDisplayConfig } from '../ai-chat-chips'; import type { DocDisplayConfig } from '../ai-chat-chips';
import type { ChatContextValue } from '../ai-chat-content'; import type { ChatContextValue } from '../ai-chat-content';
import type { import type { AIPlaygroundConfig, AIReasoningConfig } from '../ai-chat-input';
AINetworkSearchConfig,
AIPlaygroundConfig,
AIReasoningConfig,
} from '../ai-chat-input';
import { import {
type AIChatMessages, type AIChatMessages,
type ChatAction, type ChatAction,
@@ -147,9 +143,6 @@ export class PlaygroundChat extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor session!: CopilotChatHistoryFragment | null | undefined; accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -359,7 +352,6 @@ export class PlaygroundChat extends SignalWatcher(
.affineThemeService=${this.affineThemeService} .affineThemeService=${this.affineThemeService}
.notificationService=${this.notificationService} .notificationService=${this.notificationService}
.aiToolsConfigService=${this.aiToolsConfigService} .aiToolsConfigService=${this.aiToolsConfigService}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.messages=${this.messages} .messages=${this.messages}
></ai-chat-messages> ></ai-chat-messages>
@@ -372,7 +364,6 @@ export class PlaygroundChat extends SignalWatcher(
.chatContextValue=${this.chatContextValue} .chatContextValue=${this.chatContextValue}
.updateContext=${this.updateContext} .updateContext=${this.updateContext}
.onEmbeddingProgressChange=${this.onEmbeddingProgressChange} .onEmbeddingProgressChange=${this.onEmbeddingProgressChange}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.playgroundConfig=${this.playgroundConfig} .playgroundConfig=${this.playgroundConfig}
.docDisplayConfig=${this.docDisplayConfig} .docDisplayConfig=${this.docDisplayConfig}

View File

@@ -16,11 +16,7 @@ import type { AppSidebarConfig } from '../../chat-panel/chat-config';
import { AIProvider } from '../../provider'; import { AIProvider } from '../../provider';
import type { SearchMenuConfig } from '../ai-chat-add-context'; import type { SearchMenuConfig } from '../ai-chat-add-context';
import type { DocDisplayConfig } from '../ai-chat-chips'; import type { DocDisplayConfig } from '../ai-chat-chips';
import type { import type { AIPlaygroundConfig, AIReasoningConfig } from '../ai-chat-input';
AINetworkSearchConfig,
AIPlaygroundConfig,
AIReasoningConfig,
} from '../ai-chat-input';
export class PlaygroundContent extends SignalWatcher( export class PlaygroundContent extends SignalWatcher(
WithDisposable(ShadowlessElement) WithDisposable(ShadowlessElement)
@@ -64,9 +60,6 @@ export class PlaygroundContent extends SignalWatcher(
@property({ attribute: false }) @property({ attribute: false })
accessor doc!: Store; accessor doc!: Store;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -347,7 +340,6 @@ export class PlaygroundContent extends SignalWatcher(
.host=${this.host} .host=${this.host}
.doc=${this.doc} .doc=${this.doc}
.session=${session} .session=${session}
.networkSearchConfig=${this.networkSearchConfig}
.reasoningConfig=${this.reasoningConfig} .reasoningConfig=${this.reasoningConfig}
.playgroundConfig=${this.playgroundConfig} .playgroundConfig=${this.playgroundConfig}
.appSidebarConfig=${this.appSidebarConfig} .appSidebarConfig=${this.appSidebarConfig}

View File

@@ -1,5 +1,4 @@
import { LifeCycleWatcher } from '@blocksuite/affine/std'; import { LifeCycleWatcher } from '@blocksuite/affine/std';
import type { FrameworkProvider } from '@toeverything/infra';
import { buildAIPanelConfig } from '../ai-panel'; import { buildAIPanelConfig } from '../ai-panel';
import { setupEdgelessCopilot } from '../entries/edgeless/index'; 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 { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
import { EdgelessCopilotWidget } from '../widgets/edgeless-copilot'; import { EdgelessCopilotWidget } from '../widgets/edgeless-copilot';
export function getAIEdgelessRootWatcher(framework: FrameworkProvider) { export function getAIEdgelessRootWatcher() {
class AIEdgelessRootWatcher extends LifeCycleWatcher { class AIEdgelessRootWatcher extends LifeCycleWatcher {
static override key = 'ai-edgeless-root-watcher'; static override key = 'ai-edgeless-root-watcher';
@@ -21,7 +20,7 @@ export function getAIEdgelessRootWatcher(framework: FrameworkProvider) {
const component = payload.view; const component = payload.view;
if (component instanceof AffineAIPanelWidget) { if (component instanceof AffineAIPanelWidget) {
component.style.width = '430px'; component.style.width = '430px';
component.config = buildAIPanelConfig(component, framework); component.config = buildAIPanelConfig(component);
setupSpaceAIEntry(component); setupSpaceAIEntry(component);
} }

View File

@@ -1,11 +1,10 @@
import { LifeCycleWatcher } from '@blocksuite/affine/std'; import { LifeCycleWatcher } from '@blocksuite/affine/std';
import type { FrameworkProvider } from '@toeverything/infra';
import { buildAIPanelConfig } from '../ai-panel'; import { buildAIPanelConfig } from '../ai-panel';
import { setupSpaceAIEntry } from '../entries/space/setup-space'; import { setupSpaceAIEntry } from '../entries/space/setup-space';
import { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel'; import { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';
export function getAIPageRootWatcher(framework: FrameworkProvider) { export function getAIPageRootWatcher() {
class AIPageRootWatcher extends LifeCycleWatcher { class AIPageRootWatcher extends LifeCycleWatcher {
static override key = 'ai-page-root-watcher'; static override key = 'ai-page-root-watcher';
@@ -19,7 +18,7 @@ export function getAIPageRootWatcher(framework: FrameworkProvider) {
const component = payload.view; const component = payload.view;
if (component instanceof AffineAIPanelWidget) { if (component instanceof AffineAIPanelWidget) {
component.style.width = '630px'; component.style.width = '630px';
component.config = buildAIPanelConfig(component, framework); component.config = buildAIPanelConfig(component);
setupSpaceAIEntry(component); setupSpaceAIEntry(component);
} }
}); });

View File

@@ -40,10 +40,7 @@ import {
import { type AIChatBlockModel } from '../blocks'; import { type AIChatBlockModel } from '../blocks';
import type { SearchMenuConfig } from '../components/ai-chat-add-context'; import type { SearchMenuConfig } from '../components/ai-chat-add-context';
import type { DocDisplayConfig } from '../components/ai-chat-chips'; import type { DocDisplayConfig } from '../components/ai-chat-chips';
import type { import type { AIReasoningConfig } from '../components/ai-chat-input';
AINetworkSearchConfig,
AIReasoningConfig,
} from '../components/ai-chat-input';
import type { ChatMessage } from '../components/ai-chat-messages'; import type { ChatMessage } from '../components/ai-chat-messages';
import { import {
ChatMessagesSchema, ChatMessagesSchema,
@@ -88,13 +85,6 @@ export class AIChatBlockPeekView extends LitElement {
return this.blockModel.props.rootWorkspaceId; return this.blockModel.props.rootWorkspaceId;
} }
private get _isNetworkActive() {
return (
!!this.networkSearchConfig.visible.value &&
!!this.networkSearchConfig.enabled.value
);
}
private get _isReasoningActive() { private get _isReasoningActive() {
return !!this.reasoningConfig.enabled.value; return !!this.reasoningConfig.enabled.value;
} }
@@ -401,7 +391,6 @@ export class AIChatBlockPeekView extends LitElement {
where: 'ai-chat-block', where: 'ai-chat-block',
control: 'chat-send', control: 'chat-send',
reasoning: this._isReasoningActive, reasoning: this._isReasoningActive,
webSearch: this._isNetworkActive,
toolsConfig: this.aiToolsConfigService.config.value, toolsConfig: this.aiToolsConfigService.config.value,
}); });
@@ -573,12 +562,7 @@ export class AIChatBlockPeekView extends LitElement {
const latestHistoryMessage = _historyMessages[_historyMessages.length - 1]; const latestHistoryMessage = _historyMessages[_historyMessages.length - 1];
const latestMessageCreatedAt = latestHistoryMessage.createdAt; const latestMessageCreatedAt = latestHistoryMessage.createdAt;
const { const { chatContext, updateContext, _textRendererOptions } = this;
chatContext,
updateContext,
networkSearchConfig,
_textRendererOptions,
} = this;
const { messages: currentChatMessages } = chatContext; const { messages: currentChatMessages } = chatContext;
const notificationService = this.host.std.get(NotificationProvider); const notificationService = this.host.std.get(NotificationProvider);
@@ -613,7 +597,6 @@ export class AIChatBlockPeekView extends LitElement {
.chatContextValue=${chatContext} .chatContextValue=${chatContext}
.updateContext=${updateContext} .updateContext=${updateContext}
.onEmbeddingProgressChange=${this.onEmbeddingProgressChange} .onEmbeddingProgressChange=${this.onEmbeddingProgressChange}
.networkSearchConfig=${networkSearchConfig}
.docDisplayConfig=${this.docDisplayConfig} .docDisplayConfig=${this.docDisplayConfig}
.searchMenuConfig=${this.searchMenuConfig} .searchMenuConfig=${this.searchMenuConfig}
.affineWorkspaceDialogService=${this.affineWorkspaceDialogService} .affineWorkspaceDialogService=${this.affineWorkspaceDialogService}
@@ -644,9 +627,6 @@ export class AIChatBlockPeekView extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
accessor host!: EditorHost; accessor host!: EditorHost;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@property({ attribute: false }) @property({ attribute: false })
accessor reasoningConfig!: AIReasoningConfig; accessor reasoningConfig!: AIReasoningConfig;
@@ -713,7 +693,6 @@ export const AIChatBlockPeekViewTemplate = (
host: EditorHost, host: EditorHost,
docDisplayConfig: DocDisplayConfig, docDisplayConfig: DocDisplayConfig,
searchMenuConfig: SearchMenuConfig, searchMenuConfig: SearchMenuConfig,
networkSearchConfig: AINetworkSearchConfig,
reasoningConfig: AIReasoningConfig, reasoningConfig: AIReasoningConfig,
serverService: ServerService, serverService: ServerService,
affineFeatureFlagService: FeatureFlagService, affineFeatureFlagService: FeatureFlagService,
@@ -727,7 +706,6 @@ export const AIChatBlockPeekViewTemplate = (
return html`<ai-chat-block-peek-view return html`<ai-chat-block-peek-view
.blockModel=${blockModel} .blockModel=${blockModel}
.host=${host} .host=${host}
.networkSearchConfig=${networkSearchConfig}
.docDisplayConfig=${docDisplayConfig} .docDisplayConfig=${docDisplayConfig}
.searchMenuConfig=${searchMenuConfig} .searchMenuConfig=${searchMenuConfig}
.reasoningConfig=${reasoningConfig} .reasoningConfig=${reasoningConfig}

View File

@@ -446,7 +446,6 @@ export class CopilotClient {
sessionId, sessionId,
messageId, messageId,
reasoning, reasoning,
webSearch,
modelId, modelId,
toolsConfig, toolsConfig,
signal, signal,
@@ -454,7 +453,6 @@ export class CopilotClient {
sessionId: string; sessionId: string;
messageId?: string; messageId?: string;
reasoning?: boolean; reasoning?: boolean;
webSearch?: boolean;
modelId?: string; modelId?: string;
toolsConfig?: AIToolsConfig; toolsConfig?: AIToolsConfig;
signal?: AbortSignal; signal?: AbortSignal;
@@ -463,7 +461,6 @@ export class CopilotClient {
const queryString = this.paramsToQueryString({ const queryString = this.paramsToQueryString({
messageId, messageId,
reasoning, reasoning,
webSearch,
modelId, modelId,
toolsConfig, toolsConfig,
}); });
@@ -480,14 +477,12 @@ export class CopilotClient {
sessionId, sessionId,
messageId, messageId,
reasoning, reasoning,
webSearch,
modelId, modelId,
toolsConfig, toolsConfig,
}: { }: {
sessionId: string; sessionId: string;
messageId?: string; messageId?: string;
reasoning?: boolean; reasoning?: boolean;
webSearch?: boolean;
modelId?: string; modelId?: string;
toolsConfig?: AIToolsConfig; toolsConfig?: AIToolsConfig;
}, },
@@ -497,7 +492,6 @@ export class CopilotClient {
const queryString = this.paramsToQueryString({ const queryString = this.paramsToQueryString({
messageId, messageId,
reasoning, reasoning,
webSearch,
modelId, modelId,
toolsConfig, toolsConfig,
}); });

View File

@@ -21,7 +21,6 @@ export type TextToTextOptions = {
isRootSession?: boolean; isRootSession?: boolean;
postfix?: (text: string) => string; postfix?: (text: string) => string;
reasoning?: boolean; reasoning?: boolean;
webSearch?: boolean;
modelId?: string; modelId?: string;
toolsConfig?: AIToolsConfig; toolsConfig?: AIToolsConfig;
}; };
@@ -119,7 +118,6 @@ export function textToText({
endpoint = Endpoint.Stream, endpoint = Endpoint.Stream,
postfix, postfix,
reasoning, reasoning,
webSearch,
modelId, modelId,
toolsConfig, toolsConfig,
}: TextToTextOptions) { }: TextToTextOptions) {
@@ -142,7 +140,6 @@ export function textToText({
sessionId, sessionId,
messageId, messageId,
reasoning, reasoning,
webSearch,
modelId, modelId,
toolsConfig, toolsConfig,
}, },
@@ -205,7 +202,6 @@ export function textToText({
sessionId, sessionId,
messageId, messageId,
reasoning, reasoning,
webSearch,
modelId, modelId,
}); });
})(), })(),

View File

@@ -83,7 +83,7 @@ export function setupAIProvider(
//#region actions //#region actions
AIProvider.provide('chat', async options => { AIProvider.provide('chat', async options => {
const { input, contexts, webSearch } = options; const { input, contexts } = options;
const sessionId = await createSession({ const sessionId = await createSession({
promptName: 'Chat With AFFiNE AI', promptName: 'Chat With AFFiNE AI',
@@ -102,7 +102,6 @@ export function setupAIProvider(
selectedSnapshot: contexts?.selectedSnapshot, selectedSnapshot: contexts?.selectedSnapshot,
selectedMarkdown: contexts?.selectedMarkdown, selectedMarkdown: contexts?.selectedMarkdown,
html: contexts?.html, html: contexts?.html,
searchMode: webSearch ? 'MUST' : 'AUTO',
}, },
endpoint: Endpoint.StreamObject, endpoint: Endpoint.StreamObject,
}); });

View File

@@ -523,7 +523,6 @@ export class AffineAIPanelWidget extends WidgetComponent {
.onBlur=${this._discardWithConfirmation} .onBlur=${this._discardWithConfirmation}
.onFinish=${this._inputFinish} .onFinish=${this._inputFinish}
.onInput=${this.onInput} .onInput=${this.onInput}
.networkSearchConfig=${config.networkSearchConfig}
.theme=${theme} .theme=${theme}
></ai-panel-input>`, ></ai-panel-input>`,
], ],

View File

@@ -1,4 +1,3 @@
import type { Signal } from '@preact/signals-core';
import type { nothing, TemplateResult } from 'lit'; import type { nothing, TemplateResult } from 'lit';
import type { StreamObject } from '../../components/ai-chat-messages'; import type { StreamObject } from '../../components/ai-chat-messages';
@@ -29,12 +28,6 @@ export interface AIPanelGeneratingConfig {
stages?: string[]; stages?: string[];
} }
export interface AINetworkSearchConfig {
visible: Signal<boolean | undefined>;
enabled: Signal<boolean | undefined>;
setEnabled: (state: boolean) => void;
}
export type AIActionAnswer = { export type AIActionAnswer = {
content: string; content: string;
streamObjects?: StreamObject[]; streamObjects?: StreamObject[];
@@ -56,7 +49,6 @@ export interface AffineAIPanelWidgetConfig {
finishStateConfig: AIPanelAnswerConfig; finishStateConfig: AIPanelAnswerConfig;
generatingStateConfig: AIPanelGeneratingConfig; generatingStateConfig: AIPanelGeneratingConfig;
errorStateConfig: AIPanelErrorConfig; errorStateConfig: AIPanelErrorConfig;
networkSearchConfig: AINetworkSearchConfig;
hideCallback?: () => void; hideCallback?: () => void;
discardCallback?: () => void; discardCallback?: () => void;
inputCallback?: (input: string) => void; inputCallback?: (input: string) => void;

View File

@@ -72,7 +72,7 @@ export class AIViewExtension extends ViewExtensionProvider<AIViewOptions> {
context.register([ context.register([
CopilotTool, CopilotTool,
edgelessCopilotWidget, edgelessCopilotWidget,
getAIEdgelessRootWatcher(framework), getAIEdgelessRootWatcher(),
// In note // In note
ToolbarModuleExtension({ ToolbarModuleExtension({
id: BlockFlavourIdentifier('custom:affine:surface:*'), id: BlockFlavourIdentifier('custom:affine:surface:*'),
@@ -84,7 +84,7 @@ export class AIViewExtension extends ViewExtensionProvider<AIViewOptions> {
context.register([ context.register([
blockDiffWidgetForPage, blockDiffWidgetForPage,
blockDiffWidgetForBlock, blockDiffWidgetForBlock,
getAIPageRootWatcher(framework), getAIPageRootWatcher(),
BlockDiffService, BlockDiffService,
BlockDiffWatcher, BlockDiffWatcher,
]); ]);

View File

@@ -1,5 +1,4 @@
// packages/frontend/core/src/blocksuite/ai/hooks/useChatPanelConfig.ts // 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 { AIPlaygroundService } from '@affine/core/modules/ai-button/services/playground';
import { AIReasoningService } from '@affine/core/modules/ai-button/services/reasoning'; import { AIReasoningService } from '@affine/core/modules/ai-button/services/reasoning';
import { CollectionService } from '@affine/core/modules/collection'; import { CollectionService } from '@affine/core/modules/collection';
@@ -20,7 +19,6 @@ import { useFramework } from '@toeverything/infra';
export function useAIChatConfig() { export function useAIChatConfig() {
const framework = useFramework(); const framework = useFramework();
const searchService = framework.get(AINetworkSearchService);
const reasoningService = framework.get(AIReasoningService); const reasoningService = framework.get(AIReasoningService);
const playgroundService = framework.get(AIPlaygroundService); const playgroundService = framework.get(AIPlaygroundService);
const docDisplayMetaService = framework.get(DocDisplayMetaService); const docDisplayMetaService = framework.get(DocDisplayMetaService);
@@ -31,12 +29,6 @@ export function useAIChatConfig() {
const collectionService = framework.get(CollectionService); const collectionService = framework.get(CollectionService);
const docsService = framework.get(DocsService); const docsService = framework.get(DocsService);
const networkSearchConfig = {
visible: searchService.visible,
enabled: searchService.enabled,
setEnabled: searchService.setEnabled,
};
const reasoningConfig = { const reasoningConfig = {
enabled: reasoningService.enabled, enabled: reasoningService.enabled,
setEnabled: reasoningService.setEnabled, setEnabled: reasoningService.setEnabled,
@@ -126,7 +118,6 @@ export function useAIChatConfig() {
}; };
return { return {
networkSearchConfig,
reasoningConfig, reasoningConfig,
docDisplayConfig, docDisplayConfig,
searchMenuConfig, searchMenuConfig,

View File

@@ -106,12 +106,8 @@ export const Component = () => {
const workspaceId = useService(WorkspaceService).workspace.id; const workspaceId = useService(WorkspaceService).workspace.id;
const { const { docDisplayConfig, searchMenuConfig, reasoningConfig } =
docDisplayConfig, useAIChatConfig();
searchMenuConfig,
networkSearchConfig,
reasoningConfig,
} = useAIChatConfig();
const createSession = useCallback( const createSession = useCallback(
async (options: Partial<BlockSuitePresets.AICreateSessionOptions> = {}) => { async (options: Partial<BlockSuitePresets.AICreateSessionOptions> = {}) => {
@@ -218,7 +214,6 @@ export const Component = () => {
content.host = mockStd?.host; content.host = mockStd?.host;
content.docDisplayConfig = docDisplayConfig; content.docDisplayConfig = docDisplayConfig;
content.searchMenuConfig = searchMenuConfig; content.searchMenuConfig = searchMenuConfig;
content.networkSearchConfig = networkSearchConfig;
content.reasoningConfig = reasoningConfig; content.reasoningConfig = reasoningConfig;
content.onContextChange = onContextChange; content.onContextChange = onContextChange;
content.affineFeatureFlagService = framework.get(FeatureFlagService); content.affineFeatureFlagService = framework.get(FeatureFlagService);
@@ -256,7 +251,6 @@ export const Component = () => {
framework, framework,
isBodyProvided, isBodyProvided,
mockStd, mockStd,
networkSearchConfig,
reasoningConfig, reasoningConfig,
searchMenuConfig, searchMenuConfig,
workspaceId, workspaceId,

View File

@@ -58,7 +58,6 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
const { const {
docDisplayConfig, docDisplayConfig,
searchMenuConfig, searchMenuConfig,
networkSearchConfig,
reasoningConfig, reasoningConfig,
playgroundConfig, playgroundConfig,
} = useAIChatConfig(); } = useAIChatConfig();
@@ -88,7 +87,6 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
chatPanelRef.current.docDisplayConfig = docDisplayConfig; chatPanelRef.current.docDisplayConfig = docDisplayConfig;
chatPanelRef.current.searchMenuConfig = searchMenuConfig; chatPanelRef.current.searchMenuConfig = searchMenuConfig;
chatPanelRef.current.networkSearchConfig = networkSearchConfig;
chatPanelRef.current.reasoningConfig = reasoningConfig; chatPanelRef.current.reasoningConfig = reasoningConfig;
chatPanelRef.current.playgroundConfig = playgroundConfig; chatPanelRef.current.playgroundConfig = playgroundConfig;
chatPanelRef.current.extensions = specs; chatPanelRef.current.extensions = specs;
@@ -139,7 +137,6 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
docDisplayConfig, docDisplayConfig,
editor, editor,
framework, framework,
networkSearchConfig,
searchMenuConfig, searchMenuConfig,
reasoningConfig, reasoningConfig,
playgroundConfig, playgroundConfig,

View File

@@ -16,7 +16,6 @@ import { AIButtonProvider } from './provider/ai-button';
import { AIButtonService } from './services/ai-button'; import { AIButtonService } from './services/ai-button';
import { AIDraftService } from './services/ai-draft'; import { AIDraftService } from './services/ai-draft';
import { AIModelService } from './services/models'; import { AIModelService } from './services/models';
import { AINetworkSearchService } from './services/network-search';
import { AIPlaygroundService } from './services/playground'; import { AIPlaygroundService } from './services/playground';
import { AIReasoningService } from './services/reasoning'; import { AIReasoningService } from './services/reasoning';
import { AIToolsConfigService } from './services/tools-config'; 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) { export function configureAIReasoningModule(framework: Framework) {
framework.service(AIReasoningService, [GlobalStateService]); framework.service(AIReasoningService, [GlobalStateService]);
} }

View File

@@ -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<boolean | undefined>(
this._enabled$,
undefined
);
this.enabled = enabled;
this.disposables.push(enabledCleanup);
const { signal: visible, cleanup: visibleCleanup } =
createSignalFromObservable<boolean | undefined>(
this._visible$,
undefined
);
this.visible = visible;
this.disposables.push(visibleCleanup);
}
visible: Signal<boolean | undefined>;
enabled: Signal<boolean | undefined>;
private readonly _visible$ =
this.featureFlagService.flags.enable_ai_network_search.$;
private readonly _enabled$ = LiveData.from(
this.globalStateService.globalState.watch<boolean>(AI_NETWORK_SEARCH_KEY),
undefined
);
setEnabled = (enabled: boolean) => {
this.globalStateService.globalState.set(AI_NETWORK_SEARCH_KEY, enabled);
};
}

View File

@@ -5,7 +5,6 @@ import {
configureAIButtonModule, configureAIButtonModule,
configureAIDraftModule, configureAIDraftModule,
configureAIModelModule, configureAIModelModule,
configureAINetworkSearchModule,
configureAIPlaygroundModule, configureAIPlaygroundModule,
configureAIReasoningModule, configureAIReasoningModule,
configureAIToolsConfigModule, configureAIToolsConfigModule,
@@ -114,7 +113,6 @@ export function configureCommonModules(framework: Framework) {
configSearchMenuModule(framework); configSearchMenuModule(framework);
configureDndModule(framework); configureDndModule(framework);
configureCommonGlobalStorageImpls(framework); configureCommonGlobalStorageImpls(framework);
configureAINetworkSearchModule(framework);
configureAIReasoningModule(framework); configureAIReasoningModule(framework);
configureAIPlaygroundModule(framework); configureAIPlaygroundModule(framework);
configureAIButtonModule(framework); configureAIButtonModule(framework);

View File

@@ -24,12 +24,8 @@ export const AIChatBlockPeekView = ({
model, model,
host, host,
}: AIChatBlockPeekViewProps) => { }: AIChatBlockPeekViewProps) => {
const { const { docDisplayConfig, searchMenuConfig, reasoningConfig } =
docDisplayConfig, useAIChatConfig();
searchMenuConfig,
networkSearchConfig,
reasoningConfig,
} = useAIChatConfig();
const framework = useFramework(); const framework = useFramework();
const serverService = framework.get(ServerService); const serverService = framework.get(ServerService);
@@ -47,7 +43,6 @@ export const AIChatBlockPeekView = ({
host, host,
docDisplayConfig, docDisplayConfig,
searchMenuConfig, searchMenuConfig,
networkSearchConfig,
reasoningConfig, reasoningConfig,
serverService, serverService,
affineFeatureFlagService, affineFeatureFlagService,
@@ -64,7 +59,6 @@ export const AIChatBlockPeekView = ({
host, host,
docDisplayConfig, docDisplayConfig,
searchMenuConfig, searchMenuConfig,
networkSearchConfig,
reasoningConfig, reasoningConfig,
serverService, serverService,
affineFeatureFlagService, affineFeatureFlagService,

View File

@@ -10,7 +10,6 @@ test.describe('AIChatWith/Network', () => {
loggedInPage: page, loggedInPage: page,
utils, utils,
}) => { }) => {
await utils.chatPanel.enableNetworkSearch(page);
await utils.chatPanel.makeChat( await utils.chatPanel.makeChat(
page, page,
'What is the weather like in Shanghai today?' 'What is the weather like in Shanghai today?'

View File

@@ -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) { public static async enableReasoning(page: Page) {
await this.openChatInputPreference(page); await this.openChatInputPreference(page);
const reasoning = page.getByTestId('chat-reasoning'); const reasoning = page.getByTestId('chat-reasoning');
@@ -368,9 +352,4 @@ export class ChatPanelUtils {
await reasoning.click(); await reasoning.click();
} }
} }
public static async isNetworkSearchEnabled(page: Page) {
const networkSearch = await page.getByTestId('chat-network-search');
return (await networkSearch.getAttribute('aria-disabled')) === 'false';
}
} }