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:
Cats Juice
2025-07-07 14:35:54 +08:00
committed by GitHub
parent 6175bde86e
commit 563a14d0b3
5 changed files with 52 additions and 11 deletions
@@ -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}