mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
9a9228a9f8
### Context As per PR title - currently the assistant panel's maximize CTA defaults to opening in explorer, which might be confusing for users who don't have the explorer feature preview enabled <img width="581" height="190" alt="image" src="https://github.com/user-attachments/assets/9a9b6129-164e-4e3e-a14e-66ecafe8e5ff" /> <img width="574" height="157" alt="image" src="https://github.com/user-attachments/assets/ffff0a49-3357-4e5f-8cc0-be2f94263128" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Updated the AI assistant’s maximize control with context-sensitive actions. * When Explorer preview is enabled, the control opens the active conversation in Explorer. * When Explorer preview is disabled, the control maximizes or minimizes the assistant panel. * Updated the control’s label, accessibility text, and keyboard shortcut to reflect the available action. * Maximized AI Assistant panels now use the full available width, while other sidebars retain responsive sizing. * **Bug Fixes** * Improved sidebar behavior on mobile and overlay layouts to prevent unwanted resizing or collapsing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
71 lines
2.1 KiB
TypeScript
71 lines
2.1 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, isMaximised } = 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
|
|
|
|
// `isMaximised` only has meaning for the AI Assistant sidebar
|
|
const isMaximisedSidebar = isMaximised && activeSidebar?.id === SIDEBAR_KEYS.AI_ASSISTANT
|
|
|
|
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',
|
|
isMaximisedSidebar ? 'md:absolute md:h-auto md:w-full' : 'md:absolute md:h-auto md:w-1/2',
|
|
!isMaximisedSidebar && 'lg:w-2/5',
|
|
'xl:relative xl:border-l-0'
|
|
)}
|
|
>
|
|
{activeSidebar?.component()}
|
|
</ResizablePanel>
|
|
</>
|
|
)
|
|
}
|