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:
Wu Yue
2025-07-09 20:55:31 +08:00
committed by GitHub
parent f54cb5c296
commit 1f87cd8752

View File

@@ -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) => {