feat(core): add copilot tags and collections graphql apis (#11076)

Close [BS-2834](https://linear.app/affine-design/issue/BS-2834).

### What Changed?
- Add `addContextCategoryMutation` and `removeContextCategoryMutation` graphql apis.
- Provide tag and collection apis for front-end components.
This commit is contained in:
akumatus
2025-03-22 15:15:42 +00:00
parent 1f0fc9d47a
commit 331dd67e69
17 changed files with 498 additions and 128 deletions
@@ -2,9 +2,11 @@ import { ChatPanel } from '@affine/core/blocksuite/ai';
import type { AffineEditorContainer } from '@affine/core/blocksuite/block-suite-editor';
import { enableFootnoteConfigExtension } from '@affine/core/blocksuite/extensions';
import { AINetworkSearchService } from '@affine/core/modules/ai-button/services/network-search';
import { CollectionService } from '@affine/core/modules/collection';
import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta';
import { DocsSearchService } from '@affine/core/modules/docs-search';
import { SearchMenuService } from '@affine/core/modules/search-menu/services';
import { TagService } from '@affine/core/modules/tag';
import { WorkbenchService } from '@affine/core/modules/workbench';
import { WorkspaceService } from '@affine/core/modules/workspace';
import { RefNodeSlotsProvider } from '@blocksuite/affine/inlines/reference';
@@ -62,7 +64,8 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
const searchMenuService = framework.get(SearchMenuService);
const workbench = framework.get(WorkbenchService).workbench;
const docsSearchService = framework.get(DocsSearchService);
const tagService = framework.get(TagService);
const collectionService = framework.get(CollectionService);
chatPanelRef.current.appSidebarConfig = {
getWidth: () => {
const width$ = workbench.sidebarWidth$;
@@ -96,6 +99,19 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
const docs$ = docsSearchService.watchRefsFrom(docIds);
return createSignalFromObservable(docs$, []);
},
getTags: () => {
const tagMetas$ = tagService.tagList.tagMetas$;
return createSignalFromObservable(tagMetas$, []);
},
getTagPageIds: (tagId: string) => {
const tag$ = tagService.tagList.tagByTagId$(tagId);
if (!tag$) return [];
return tag$.value?.pageIds$.value ?? [];
},
getCollections: () => {
const collections$ = collectionService.collections$;
return createSignalFromObservable(collections$, []);
},
};
chatPanelRef.current.searchMenuConfig = {