mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
feat(editor): extract chat runtime (#14937)
#### PR Dependency Tree * **PR #14937** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Centralized AI event system and a runtime powering chat sessions and actions. * **Improvements** * Chat UI (composer, messages, toolbar, tabs, panels) now syncs with runtime snapshots for more consistent state. * Improved session/tab lifecycle (create, fork, delete), context embedding status, and history handling. * More reliable send/stop/retry flows, better telemetry scoping, and clearer upgrade/login/insert-template prompts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -4,8 +4,8 @@ import {
|
||||
resolveGlobalLoadingEventAtom,
|
||||
} from '@affine/component/global-loading';
|
||||
import {
|
||||
AIProvider,
|
||||
CopilotClient,
|
||||
AIAppEvents,
|
||||
createAIRequestService,
|
||||
setupAIProvider,
|
||||
} from '@affine/core/blocksuite/ai';
|
||||
import { useRegisterFindInPageCommands } from '@affine/core/components/hooks/affine/use-register-find-in-page-commands';
|
||||
@@ -103,7 +103,7 @@ export const WorkspaceSideEffects = () => {
|
||||
})
|
||||
);
|
||||
|
||||
const disposable = AIProvider.slots.requestInsertTemplate.subscribe(
|
||||
const disposable = AIAppEvents.requestInsertTemplate.subscribe(
|
||||
({ template, mode }) => {
|
||||
insertTemplate({ template, mode });
|
||||
}
|
||||
@@ -126,7 +126,7 @@ export const WorkspaceSideEffects = () => {
|
||||
const globalDialogService = useService(GlobalDialogService);
|
||||
|
||||
useEffect(() => {
|
||||
const disposable = AIProvider.slots.requestUpgradePlan.subscribe(() => {
|
||||
const disposable = AIAppEvents.requestUpgradePlan.subscribe(() => {
|
||||
workspaceDialogService.open('setting', {
|
||||
activeTab: 'billing',
|
||||
});
|
||||
@@ -143,7 +143,10 @@ export const WorkspaceSideEffects = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const dispose = setupAIProvider(
|
||||
new CopilotClient(graphqlService.gql, eventSourceService.eventSource),
|
||||
createAIRequestService(
|
||||
graphqlService.gql,
|
||||
eventSourceService.eventSource
|
||||
),
|
||||
globalDialogService,
|
||||
authService
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user