feat(core): integrate realtime features (#15003)

This commit is contained in:
DarkSky
2026-05-20 05:48:03 +08:00
committed by GitHub
parent 3e42bbf4fa
commit 9f33d37add
108 changed files with 3069 additions and 2729 deletions
@@ -46,13 +46,12 @@ const McpServerSetting = () => {
return accessTokens?.find(token => token.name === 'mcp');
}, [accessTokens]);
const displayedToken = revealedAccessToken ?? mcpAccessToken;
const hasMcpToken = Boolean(revealedAccessToken || mcpAccessToken);
const hasCopyableToken = Boolean(revealedAccessToken);
const isRedactedDisplay = hasMcpToken && !hasCopyableToken;
const code = useMemo(() => {
return displayedToken
return revealedAccessToken
? JSON.stringify(
{
mcpServers: {
@@ -61,7 +60,7 @@ const McpServerSetting = () => {
url: `${serverService.server.baseUrl}/api/workspaces/${workspaceService.workspace.id}/mcp`,
note: `Read docs from AFFiNE workspace "${workspaceName}"`,
headers: {
Authorization: `Bearer ${displayedToken.token}`,
Authorization: `Bearer ${revealedAccessToken.token}`,
},
},
},
@@ -70,7 +69,7 @@ const McpServerSetting = () => {
2
)
: null;
}, [displayedToken, workspaceName, workspaceService, serverService]);
}, [revealedAccessToken, workspaceName, workspaceService, serverService]);
const copyJsonDisabled = !code || mutating || isRedactedDisplay;
const copyJsonTooltip = isRedactedDisplay
@@ -31,6 +31,7 @@ import {
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
import { PeekViewService } from '@affine/core/modules/peek-view';
import { NbstoreService } from '@affine/core/modules/storage';
import { AppThemeService } from '@affine/core/modules/theme';
import {
ViewBody,
@@ -55,14 +56,16 @@ import * as styles from './index.css';
function useAIRequestService() {
const graphqlService = useService(GraphQLService);
const eventSourceService = useService(EventSourceService);
const nbstoreService = useService(NbstoreService);
return useMemo(
() =>
createAIRequestService(
graphqlService.gql,
eventSourceService.eventSource
eventSourceService.eventSource,
nbstoreService.realtime
),
[graphqlService, eventSourceService]
[graphqlService, eventSourceService, nbstoreService]
);
}
@@ -36,6 +36,7 @@ import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import { useSignalValue } from '@affine/core/modules/doc-info/utils';
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
import { PeekViewService } from '@affine/core/modules/peek-view';
import { NbstoreService } from '@affine/core/modules/storage';
import { AppThemeService } from '@affine/core/modules/theme';
import { WorkbenchService } from '@affine/core/modules/workbench';
import { useI18n } from '@affine/i18n';
@@ -75,6 +76,7 @@ export const EditorChatPanel = ({
const framework = useFramework();
const graphqlService = useService(GraphQLService);
const eventSourceService = useService(EventSourceService);
const nbstoreService = useService(NbstoreService);
const workbench = useService(WorkbenchService).workbench;
const t = useI18n();
@@ -108,9 +110,10 @@ export const EditorChatPanel = ({
() =>
createAIRequestService(
graphqlService.gql,
eventSourceService.eventSource
eventSourceService.eventSource,
nbstoreService.realtime
),
[eventSourceService.eventSource, graphqlService.gql]
[eventSourceService.eventSource, graphqlService.gql, nbstoreService]
);
const [pendingSessionId] = useState(() => {