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';
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<T extends keyof BlockSuitePresets.AIActions>(
Parameters<BlockSuitePresets.AIActions[T]>[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<T extends keyof BlockSuitePresets.AIActions>(
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<T extends keyof BlockSuitePresets.AIActions>(
where,
docId: host.store.id,
workspaceId: host.store.workspace.id,
webSearch: visible?.value && enabled?.value,
} as Parameters<typeof action>[0];
// @ts-expect-error TODO(@Peng): maybe fix this
stream = await action(options);
@@ -145,8 +139,7 @@ function actionToGenerateAnswer<T extends keyof BlockSuitePresets.AIActions>(
Parameters<BlockSuitePresets.AIActions[T]>[0],
keyof BlockSuitePresets.AITextActionOptions
>,
trackerOptions?: BlockSuitePresets.TrackerOptions,
networkConfig?: AINetworkSearchConfig
trackerOptions?: BlockSuitePresets.TrackerOptions
) {
return ({
input,
@@ -167,8 +160,7 @@ function actionToGenerateAnswer<T extends keyof BlockSuitePresets.AIActions>(
input,
signal,
variants,
trackerOptions,
networkConfig
trackerOptions
);
if (!stream) return;
bindTextStream(stream, { update, finish, signal });
@@ -196,8 +188,7 @@ function updateAIPanelConfig<T extends keyof BlockSuitePresets.AIActions>(
host,
id,
variants,
trackerOptions,
config.networkSearchConfig
trackerOptions
);
const ctx = new AIContext();

View File

@@ -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<T extends keyof BlockSuitePresets.AIActions>(
seed?: string;
} | void>,
trackerOptions?: BlockSuitePresets.TrackerOptions,
panelInput?: string,
networkConfig?: AINetworkSearchConfig
panelInput?: string
) {
const action = AIProvider.actions[id];
@@ -194,7 +190,6 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
return {
async *[Symbol.asyncIterator]() {
const models = getCopilotSelectedElems(host);
const { visible, enabled } = networkConfig ?? {};
const options = {
...variants,
signal,
@@ -206,7 +201,6 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(
host,
docId: host.store.id,
workspaceId: host.store.workspace.id,
webSearch: visible?.value && enabled?.value,
} as Parameters<typeof action>[0];
const content = ctx.get().content;
@@ -273,8 +267,7 @@ function actionToGeneration<T extends keyof BlockSuitePresets.AIActions>(
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<T extends keyof BlockSuitePresets.AIActions>(
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);

View File

@@ -142,7 +142,6 @@ declare global {
interface ChatOptions extends AITextActionOptions {
sessionId?: string;
isRootSession?: boolean;
webSearch?: boolean;
reasoning?: boolean;
modelId?: string;
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 {
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,
},
};
}

View File

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

View File

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

View File

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

View File

@@ -33,11 +33,7 @@ import {
isChatMessage,
StreamObjectSchema,
} from '../ai-chat-messages';
import type {
AIChatInputContext,
AINetworkSearchConfig,
AIReasoningConfig,
} from './type';
import type { AIChatInputContext, AIReasoningConfig } from './type';
function getFirstTwoLines(text: string) {
const lines = text.split('\n');
@@ -350,9 +346,6 @@ export class AIChatInput extends SignalWatcher(
@property({ attribute: false })
accessor addChip!: (chip: ChatChip, silent?: boolean) => Promise<void>;
@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,

View File

@@ -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: {

View File

@@ -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<boolean | undefined>;
enabled: Signal<boolean | undefined>;
setEnabled: (state: boolean) => void;
}
export interface AIReasoningConfig {
enabled: Signal<boolean | undefined>;
setEnabled: (state: boolean) => void;

View File

@@ -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,
});

View File

@@ -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}
></ai-chat-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}

View File

@@ -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}

View File

@@ -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);
}

View File

@@ -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);
}
});

View File

@@ -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`<ai-chat-block-peek-view
.blockModel=${blockModel}
.host=${host}
.networkSearchConfig=${networkSearchConfig}
.docDisplayConfig=${docDisplayConfig}
.searchMenuConfig=${searchMenuConfig}
.reasoningConfig=${reasoningConfig}

View File

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

View File

@@ -21,7 +21,6 @@ export type TextToTextOptions = {
isRootSession?: boolean;
postfix?: (text: string) => 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,
});
})(),

View File

@@ -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,
});

View File

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

View File

@@ -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<boolean | undefined>;
enabled: Signal<boolean | undefined>;
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;

View File

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

View File

@@ -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,

View File

@@ -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<BlockSuitePresets.AICreateSessionOptions> = {}) => {
@@ -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,

View File

@@ -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,

View File

@@ -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]);
}

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,
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);

View File

@@ -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,