mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 11:06:25 +08:00
feat(core): auto expand workbench sidebar when opening ai preview panel (#13058)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added the ability to programmatically open and close the AI chat preview panel, with improved control over its visibility and content. * Introduced event notifications for preview panel open/close actions, enabling responsive UI updates. * **Enhancements** * Automatically adjusts the sidebar width to a minimum value when the preview panel is opened for optimal viewing. * Improved synchronization between sidebar width and external changes, ensuring a consistent user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -117,6 +117,7 @@ const WorkbenchSidebar = () => {
|
||||
const [resizing, setResizing] = useState(false);
|
||||
|
||||
const workbench = useService(WorkbenchService).workbench;
|
||||
const sidebarWidth = useLiveData(workbench.sidebarWidth$);
|
||||
const [width, setWidth] = useState(workbench.sidebarWidth$.value ?? 0);
|
||||
|
||||
const views = useLiveData(workbench.views$);
|
||||
@@ -152,6 +153,11 @@ const WorkbenchSidebar = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (resizing) return;
|
||||
setWidth(sidebarWidth ?? 0);
|
||||
}, [resizing, sidebarWidth]);
|
||||
|
||||
return (
|
||||
<ResizePanel
|
||||
floating={floating}
|
||||
|
||||
Reference in New Issue
Block a user