There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): online search button status not updated to the search prompt (#11542)
akumatus82ade96b3f40
diff --git a/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts b/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.tsindex c1bb946196..55cc45d764 100644--- a/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts+++ b/packages/frontend/core/src/blocksuite/ai/actions/doc-handler.ts@@ -22,6 +22,7 @@ import {selectAboveBlocks,} from '../utils/selection-utils';import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';+import type { AINetworkSearchConfig } from '../widgets/ai-panel/type';import { actionToAnswerRenderer } from './answer-renderer';export function bindTextStream(@@ -69,7 +70,8 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(Parameters<BlockSuitePresets.AIActions[T]>[0],keyof BlockSuitePresets.AITextActionOptions>,- trackerOptions?: BlockSuitePresets.TrackerOptions+ trackerOptions?: BlockSuitePresets.TrackerOptions,+ networkConfig?: AINetworkSearchConfig): BlockSuitePresets.TextStream | undefined {const action = AIProvider.actions[id];if (!action || typeof action !== 'function') return;@@ -94,10 +96,11 @@ 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,- input: input ? `${markdown}\n${input}` : markdown,+ input: input ? (markdown ? `${markdown}\n${input}` : input) : markdown,stream: true,host,models,@@ -106,6 +109,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(where,docId: host.doc.id,workspaceId: host.doc.workspace.id,+ networkSearch: visible?.value && enabled?.value,} as Parameters<typeof action>[0];// @ts-expect-error TODO(@Peng): maybe fix thisstream = await action(options);@@ -122,7 +126,8 @@ function actionToGenerateAnswer<T extends keyof BlockSuitePresets.AIActions>(Parameters<BlockSuitePresets.AIActions[T]>[0],keyof BlockSuitePresets.AITextActionOptions>,- trackerOptions?: BlockSuitePresets.TrackerOptions+ trackerOptions?: BlockSuitePresets.TrackerOptions,+ networkConfig?: AINetworkSearchConfig) {return ({input,@@ -143,7 +148,8 @@ function actionToGenerateAnswer<T extends keyof BlockSuitePresets.AIActions>(input,signal,variants,- trackerOptions+ trackerOptions,+ networkConfig);if (!stream) return;bindTextStream(stream, { update, finish, signal });@@ -171,7 +177,8 @@ function updateAIPanelConfig<T extends keyof BlockSuitePresets.AIActions>(host,id,variants,- trackerOptions+ trackerOptions,+ config.networkSearchConfig);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.tsindex f1fbce5a32..272d421f1d 100644--- a/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts+++ b/packages/frontend/core/src/blocksuite/ai/actions/edgeless-handler.ts@@ -36,6 +36,7 @@ import {getSelections,} from '../utils/selection-utils';import type { AffineAIPanelWidget } from '../widgets/ai-panel/ai-panel';+import type { AINetworkSearchConfig } from '../widgets/ai-panel/type';import type { EdgelessCopilotWidget } from '../widgets/edgeless-copilot';import { actionToAnswerRenderer } from './answer-renderer';import { EXCLUDING_COPY_ACTIONS } from './consts';@@ -168,7 +169,8 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(seed?: string;} | void>,trackerOptions?: BlockSuitePresets.TrackerOptions,- panelInput?: string+ panelInput?: string,+ networkConfig?: AINetworkSearchConfig) {const action = AIProvider.actions[id];@@ -182,6 +184,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(return {async *[Symbol.asyncIterator]() {const models = getCopilotSelectedElems(host);+ const { visible, enabled } = networkConfig ?? {};const options = {...variants,signal,@@ -193,6 +196,7 @@ function actionToStream<T extends keyof BlockSuitePresets.AIActions>(host,docId: host.doc.id,workspaceId: host.doc.workspace.id,+ networkSearch: visible?.value && enabled?.value,} as Parameters<typeof action>[0];const content = ctx.get().content;@@ -259,7 +263,8 @@ function actionToGeneration<T extends keyof BlockSuitePresets.AIActions>(attachments?: (string | Blob)[];seed?: string;} | void>,- trackerOptions?: BlockSuitePresets.TrackerOptions+ trackerOptions?: BlockSuitePresets.TrackerOptions,+ networkConfig?: AINetworkSearchConfig) {return (host: EditorHost, ctx: AIContext) => {return ({@@ -284,7 +289,8 @@ function actionToGeneration<T extends keyof BlockSuitePresets.AIActions>(variants,extract,trackerOptions,- input+ input,+ networkConfig)?.(host, ctx);if (!stream) return;@@ -325,7 +331,8 @@ function updateEdgelessAIPanelConfig<id,variants,customInput,- trackerOptions+ trackerOptions,+ config.networkSearchConfig)(host, ctx);config.finishStateConfig = actionToResponse(id, host, ctx, variants);config.generatingStateConfig = actionToGenerating(id, generatingIcon);