Organization Navigation and Switching#
Agenta's sidebar implements a multi-tenant navigation model where the active organization and workspace are always visible at the top of the Sidebar. Users switch between organizations via a hover-triggered Ant Design Dropdown β no click required to open it.
Dropdown Switcher#
The switcher is rendered at the top of the sidebar when both selectedOrg.id and user.id are present . The trigger button displays:
- An avatar generated from
selectedOrg.default_workspace?.name || selectedOrg.name - The org/workspace name and org type as secondary text
- A
CaretDownchevron icon
trigger={["hover"]} is set on the <Dropdown>, so mousing over the button opens the menu immediately . Clicking a non-action item calls changeSelectedOrg(key), where key is the org's ID.
Dropdown Menu Items β useDropdownItems#
The useDropdownItems hook builds the dropdown's item list. It accepts selectedOrg, orgs, user, project, projects, and logout .
Organization list: Only orgs whose organization_id matches a non-demo project are shown β demo projects are filtered out . Each org renders an avatar + name label keyed to org.id.
Fixed action items always appear at the bottom of the list :
| Item | Behavior |
|---|---|
| Settings | <Link href="/settings"> |
| Logout | Opens an AlertPopup confirmation, then calls logout() |
The currently selected org is highlighted via selectedKeys: [selectedOrg.id] on the menu .
useOrgData Context#
The org context (org.context.tsx) is the source of truth for the org list and selection state. Key members:
orgsβ full list ofOrg[]fetched viafetchAllOrgsList()selectedOrgβ the activeOrgDetails | null; persisted to localStorage and restored on page loadchangeSelectedOrg(orgId)β fetches full org data viafetchSingleOrg, updates state, then redirects to/apps. This means switching orgs always resets the current route.
Collapsed / Hover Expansion#
The sidebar can be pinned collapsed (80 px) or expanded (236 px) via a toggle button, with the state persisted in localStorage as sidebarCollapsed . When collapsed, hovering over the <Sider> temporarily expands it to 236 px . The boolean isSidebarExpanded = collapsed && !isHovered controls child visibility throughout the component .
Related Files#
| File | Role |
|---|---|
Sidebar.tsx | Top-level sidebar component; renders dropdown + menus |
useDropdownItems/index.tsx | Builds org-switcher dropdown item list |
useDropdownItems/types.d.ts | UseDropdownItemsProps type definition |
org.context.tsx | Org list, selection, and changeSelectedOrg logic |
project.context.tsx | Project list filtered by selected org's workspace |
useSidebarConfig/index.tsx | Builds the main navigation menu config array |
SidebarMenu.tsx | Renders SidebarConfig[] as Ant Design <Menu> |