mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
## Context Supports maximising the AI assistant to fit the content width which will provide a larger workspace for observability work for example <img width="424" height="179" alt="image" src="https://github.com/user-attachments/assets/f2b84571-0188-4d94-9798-a289496ab543" /> <img width="1388" height="960" alt="image" src="https://github.com/user-attachments/assets/07f52b1f-7b95-4d67-9a5c-151ef036fc7c" /> ## To test - [ ] Can maximize/minimize AI Assistant - [ ] Swapping to another sidebar should bring the panel size back to previous - Only the AI Assistant can be maximized (for now at least) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added maximize/minimize controls for the AI assistant panel. * Added a keyboard shortcut to quickly maximize the assistant (hidden from settings). * **Improvements** * The main content panel now collapses/resizes automatically based on assistant maximization. * Switching away from the AI assistant now automatically exits maximized mode; returning restores the maximized experience. * Updated the assistant header UI with dynamic label/icon/accessibility and a maximize shortcut when chat isn’t loading. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { useBreakpoint } from 'common'
|
|
import { useEffect } from 'react'
|
|
import { cn, ResizableHandle, ResizablePanel } from 'ui'
|
|
|
|
import { SIDEBAR_KEYS, type TYPEOF_SIDEBAR_KEYS } from './LayoutSidebarProvider'
|
|
import { useMobileSheet } from '@/components/layouts/Navigation/NavigationBar/MobileSheetContext'
|
|
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
|
|
|
function isSidebarId(content: unknown): content is TYPEOF_SIDEBAR_KEYS {
|
|
return (
|
|
typeof content === 'string' &&
|
|
Object.values(SIDEBAR_KEYS).includes(content as TYPEOF_SIDEBAR_KEYS)
|
|
)
|
|
}
|
|
|
|
interface LayoutSidebarProps {
|
|
minSize?: string | number
|
|
maxSize?: string | number
|
|
defaultSize?: string | number
|
|
}
|
|
|
|
export const LayoutSidebar = ({
|
|
minSize = '30',
|
|
maxSize = '50',
|
|
defaultSize = '30',
|
|
}: LayoutSidebarProps) => {
|
|
const isMobile = useBreakpoint('md')
|
|
const { activeSidebar } = useSidebarManagerSnapshot()
|
|
const { content: sheetContent, setContent: setMobileSheetContent } = useMobileSheet()
|
|
|
|
useEffect(() => {
|
|
if (!isMobile) {
|
|
setMobileSheetContent(null)
|
|
return
|
|
}
|
|
if (activeSidebar?.component) {
|
|
setMobileSheetContent(activeSidebar.id)
|
|
} else if (isSidebarId(sheetContent)) {
|
|
setMobileSheetContent(null)
|
|
}
|
|
}, [isMobile, activeSidebar, sheetContent, setMobileSheetContent])
|
|
|
|
if (!activeSidebar?.component) return null
|
|
if (isMobile) return null
|
|
|
|
return (
|
|
<>
|
|
<ResizableHandle withHandle />
|
|
<ResizablePanel
|
|
id="panel-side"
|
|
key={activeSidebar?.id ?? 'default'}
|
|
defaultSize={defaultSize}
|
|
minSize={minSize}
|
|
maxSize={maxSize}
|
|
className={cn(
|
|
'border-l bg fixed z-40 right-0 top-0 bottom-0',
|
|
'h-dvh',
|
|
'md:absolute md:h-auto md:w-1/2',
|
|
'lg:w-2/5',
|
|
'xl:relative xl:border-l-0'
|
|
)}
|
|
>
|
|
{activeSidebar?.component()}
|
|
</ResizablePanel>
|
|
</>
|
|
)
|
|
}
|