SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
import React, { createContext, useContext, useEffect, useState } from 'react';
import { FRONTEND_USER_SETTINGS } from '../enums';
type SidebarContextType = {
isCollapsed: boolean;
toggleSidebar: () => void;
setIsCollapsed: (isCollapsed: boolean) => void;
}
const SidebarContext = createContext<SidebarContextType | undefined>(undefined);
export const SidebarProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [isCollapsed, setIsCollapsed] = useState(() => {
const stored = localStorage.getItem(FRONTEND_USER_SETTINGS.SIDEBAR_COLLAPSED);
return stored ? JSON.parse(stored) : false;
});
useEffect(() => {
localStorage.setItem(FRONTEND_USER_SETTINGS.SIDEBAR_COLLAPSED, JSON.stringify(isCollapsed));
}, [isCollapsed]);
const toggleSidebar = () => setIsCollapsed(!isCollapsed);
return (
<SidebarContext.Provider value={{ isCollapsed, toggleSidebar, setIsCollapsed }}>
{children}
</SidebarContext.Provider>
);
};
export const useSidebar = () => {
const context = useContext(SidebarContext);
if (context === undefined) {
throw new Error('useSidebar must be used within a SidebarProvider');
}
return context;
};