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): rollback ai service (#8321)
forehaloe3e15c613431
diff --git a/packages/frontend/core/src/modules/cloud/index.ts b/packages/frontend/core/src/modules/cloud/index.tsindex 85dbae9973..b0225dc0fc 100644--- a/packages/frontend/core/src/modules/cloud/index.ts+++ b/packages/frontend/core/src/modules/cloud/index.ts@@ -35,7 +35,6 @@ import { SubscriptionPrices } from './entities/subscription-prices';import { UserCopilotQuota } from './entities/user-copilot-quota';import { UserFeature } from './entities/user-feature';import { UserQuota } from './entities/user-quota';-import { AIService } from './services/ai';import { AuthService } from './services/auth';import { CloudDocMetaService } from './services/cloud-doc-meta';import { FetchService } from './services/fetch';@@ -69,7 +68,6 @@ export function configureCloudModule(framework: Framework) {.entity(AuthSession, [AuthStore]).service(SubscriptionService, [SubscriptionStore]).store(SubscriptionStore, [GraphQLService, GlobalCache])- .service(AIService, [AuthService]).entity(Subscription, [AuthService, ServerConfigService, SubscriptionStore]).entity(SubscriptionPrices, [ServerConfigService, SubscriptionStore]).service(UserQuotaService)diff --git a/packages/frontend/core/src/modules/cloud/services/ai.ts b/packages/frontend/core/src/modules/cloud/services/ai.tsdeleted file mode 100644index 85f9634eee..0000000000--- a/packages/frontend/core/src/modules/cloud/services/ai.ts+++ /dev/null@@ -1,38 +0,0 @@-import { AIProvider } from '@affine/core/blocksuite/presets/ai';-import { Service } from '@toeverything/infra';-import { distinctUntilChanged, map, skip } from 'rxjs';--import { type AuthAccountInfo } from '../entities/session';-import type { AuthService } from './auth';-function toAIUserInfo(account: AuthAccountInfo | null) {- if (!account) return null;- return {- avatarUrl: account.avatar ?? '',- email: account.email ?? '',- id: account.id,- name: account.label,- };-}--export class AIService extends Service {- constructor(private readonly auth: AuthService) {- super();-- AIProvider.provide('userInfo', () => {- return toAIUserInfo(this.auth.session.account$.value);- });-- this.auth.session.account$- .pipe(- map(a => ({- id: a?.id,- account: a,- })),- distinctUntilChanged((a, b) => a.id === b.id), // only emit when the value changes- skip(1) // skip the initial value- )- .subscribe(({ account }) => {- AIProvider.slots.userInfo.emit(toAIUserInfo(account));- });- }-}diff --git a/packages/frontend/core/src/modules/cloud/services/auth.ts b/packages/frontend/core/src/modules/cloud/services/auth.tsindex 00616b9a6a..b8118c2be3 100644--- a/packages/frontend/core/src/modules/cloud/services/auth.ts+++ b/packages/frontend/core/src/modules/cloud/services/auth.ts@@ -1,4 +1,5 @@import { notify } from '@affine/component';+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { apis, appInfo, events } from '@affine/electron-api';import type { OAuthProviderType } from '@affine/graphql';import { I18n } from '@affine/i18n';@@ -16,6 +17,16 @@ import { type AuthAccountInfo, AuthSession } from '../entities/session';import type { AuthStore } from '../stores/auth';import type { FetchService } from './fetch';+function toAIUserInfo(account: AuthAccountInfo | null) {+ if (!account) return null;+ return {+ avatarUrl: account.avatar ?? '',+ email: account.email ?? '',+ id: account.id,+ name: account.label,+ };+}+// Emit when account changedexport const AccountChanged = createEvent<AuthAccountInfo | null>('AccountChanged'@@ -37,6 +48,11 @@ export class AuthService extends Service {) {super();+ // TODO(@forehalo): make AIProvider a standalone service passed to AI elements by props+ AIProvider.provide('userInfo', () => {+ return toAIUserInfo(this.session.account$.value);+ });+this.session.account$.pipe(map(a => ({@@ -47,6 +63,8 @@ export class AuthService extends Service {skip(1) // skip the initial value).subscribe(({ account }) => {+ AIProvider.slots.userInfo.emit(toAIUserInfo(account));+if (account === null) {this.eventBus.emit(AccountLoggedOut, account);} else {