mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 18:41:52 +08:00
feat(core): integrate realtime features (#15003)
This commit is contained in:
+3
-4
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user