mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
feat(core): add onOpenDoc handler for AFFiNE Intelligence page (#13118)
Close [AI-240](https://linear.app/affine-design/issue/AI-240) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enabled opening specific documents directly from the chat toolbar, automatically displaying the document in the workbench and focusing the chat tab in the sidebar. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -17,7 +17,9 @@ import {
|
||||
ViewBody,
|
||||
ViewHeader,
|
||||
ViewIcon,
|
||||
ViewService,
|
||||
ViewTitle,
|
||||
WorkbenchService,
|
||||
} from '@affine/core/modules/workbench';
|
||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
@@ -212,6 +214,14 @@ export const Component = () => {
|
||||
await togglePin();
|
||||
};
|
||||
|
||||
tool.onOpenDoc = (docId: string, sessionId: string) => {
|
||||
const { workbench } = framework.get(WorkbenchService);
|
||||
const viewService = framework.get(ViewService);
|
||||
workbench.open(`/${docId}?sessionId=${sessionId}`, { at: 'active' });
|
||||
workbench.openSidebar();
|
||||
viewService.view.activeSidebarTab('chat');
|
||||
};
|
||||
|
||||
// initial props
|
||||
if (!chatTool) {
|
||||
// mount
|
||||
@@ -228,6 +238,7 @@ export const Component = () => {
|
||||
togglePin,
|
||||
workspaceId,
|
||||
confirmModal,
|
||||
framework,
|
||||
]);
|
||||
|
||||
const onChatContainerRef = useCallback((node: HTMLDivElement) => {
|
||||
|
||||
Reference in New Issue
Block a user