The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Joshen/fe 3775 create a larger assistant workspace for observability (#47954)
Joshen Lim72d623f1b7d6
diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsxindex 09e2c1c0b31..9b4c23f424a 100644--- a/apps/studio/components/layouts/DefaultLayout.tsx+++ b/apps/studio/components/layouts/DefaultLayout.tsx@@ -1,7 +1,7 @@import { useBreakpoint, useParams } from 'common'import { useRouter } from 'next/router'import { PropsWithChildren, useEffect, useState } from 'react'-import { ResizablePanel, ResizablePanelGroup, SidebarProvider } from 'ui'+import { ResizablePanel, ResizablePanelGroup, SidebarProvider, usePanelRef } from 'ui'import { BannerStack } from '../ui/BannerStack/BannerStack'import { LayoutHeader } from './Navigation/LayoutHeader/LayoutHeader'@@ -9,7 +9,10 @@ import MobileNavigationBar from './Navigation/NavigationBar/MobileNavigationBar'import { MobileSheetProvider } from './Navigation/NavigationBar/MobileSheetContext'import { StudioMobileSheetNav } from './Navigation/NavigationBar/StudioMobileSheetNav'import { LayoutSidebar } from './ProjectLayout/LayoutSidebar'-import { LayoutSidebarProvider } from './ProjectLayout/LayoutSidebar/LayoutSidebarProvider'+import {+ LayoutSidebarProvider,+ SIDEBAR_KEYS,+} from './ProjectLayout/LayoutSidebar/LayoutSidebarProvider'import { ProjectContextProvider } from './ProjectLayout/ProjectContext'import { AppBannerWrapper } from '@/components/interfaces/App/AppBannerWrapper'import { Sidebar } from '@/components/interfaces/Sidebar'@@ -17,6 +20,7 @@ import { useLastVisitedOrganization } from '@/hooks/misc/useLastVisitedOrganizatimport { useCheckLatestDeploy } from '@/hooks/use-check-latest-deploy'import { IS_PLATFORM } from '@/lib/constants'import { useAppStateSnapshot } from '@/state/app-state'+import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'export interface DefaultLayoutProps {headerTitle?: string@@ -38,12 +42,18 @@ export const DefaultLayout = ({headerTitle,hideMobileMenu,}: PropsWithChildren<DefaultLayoutProps>) => {+ useCheckLatestDeploy()+const { ref } = useParams()const router = useRouter()+ const panelRef = usePanelRef()+ const isMobile = useBreakpoint('md')const appSnap = useAppStateSnapshot()-+ const { isMaximised, activeSidebar } = useSidebarManagerSnapshot()const { lastVisitedOrganization } = useLastVisitedOrganization()+ const [isMounted, setIsMounted] = useState(false)+const backToDashboardURL = router.pathname.startsWith('/account')? appSnap.lastRouteBeforeVisitingAccountPage.length > 0? appSnap.lastRouteBeforeVisitingAccountPage@@ -54,19 +64,22 @@ export const DefaultLayout = ({: '/project/default': undefined- useCheckLatestDeploy()-- const isMobile = useBreakpoint('md')-const contentMinSizePercentage = 50const contentMaxSizePercentage = 70- const [isMounted, setIsMounted] = useState(false)-useEffect(() => {setIsMounted(true)}, [])+ useEffect(() => {+ if (!isMounted || !panelRef.current || !activeSidebar) return+ if (isMaximised) {+ panelRef.current.collapse()+ } else {+ panelRef.current.resize(`${contentMaxSizePercentage}%`)+ }+ }, [isMounted, isMaximised, panelRef, activeSidebar])+// This is required to prevent layout shift when rendering resizable panels (they initially render at 50%, then shift// to whatever is specified).if (!isMounted) {@@ -106,6 +119,8 @@ export const DefaultLayout = ({<ResizablePanelid="panel-content"className="w-full"+ panelRef={panelRef}+ collapsible={activeSidebar?.id === SIDEBAR_KEYS.AI_ASSISTANT}minSize={`${contentMinSizePercentage}`}maxSize={`${contentMaxSizePercentage}`}defaultSize={`${contentMaxSizePercentage}`}@@ -116,7 +131,7 @@ export const DefaultLayout = ({</ResizablePanel><LayoutSidebarminSize={`${100 - contentMaxSizePercentage}`}- maxSize={`${100 - contentMinSizePercentage}`}+ maxSize="100"defaultSize={`${100 - contentMaxSizePercentage}`}/></ResizablePanelGroup>diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsxindex 0c70576cc2d..4c243020fca 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx@@ -24,8 +24,8 @@ export const LayoutSidebar = ({maxSize = '50',defaultSize = '30',}: LayoutSidebarProps) => {- const { activeSidebar } = useSidebarManagerSnapshot()const isMobile = useBreakpoint('md')+ const { activeSidebar } = useSidebarManagerSnapshot()const { content: sheetContent, setContent: setMobileSheetContent } = useMobileSheet()useEffect(() => {diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistantHeader.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistantHeader.tsxindex 131c071d8ae..8725e83dcb1 100644--- a/apps/studio/components/ui/AIAssistantPanel/AIAssistantHeader.tsx+++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistantHeader.tsx@@ -1,4 +1,13 @@-import { Clipboard, Edit, MessageCirclePlus, MoreVertical, Settings, X } from 'lucide-react'+import {+ Clipboard,+ Edit,+ Maximize,+ MessageCirclePlus,+ Minimize,+ MoreVertical,+ Settings,+ X,+} from 'lucide-react'import { KeyboardEvent, useState } from 'react'import { toast } from 'sonner'import {@@ -20,6 +29,7 @@ import { AIOptInModal } from './AIOptInModal'import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'import { SHORTCUT_DEFINITIONS, SHORTCUT_IDS } from '@/state/shortcuts/registry'import { useShortcut } from '@/state/shortcuts/useShortcut'+import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'interface AIAssistantHeaderProps {isChatLoading: boolean@@ -41,6 +51,7 @@ export const AIAssistantHeader = ({aiOptInLevel,}: AIAssistantHeaderProps) => {const snap = useAiAssistantStateSnapshot()+ const { isMaximised, toggleMaximise } = useSidebarManagerSnapshot()const [value, setValue] = useState(snap.activeChat?.name)const [isEditingName, setIsEditingName] = useState(false)const [isOptInModalOpen, setIsOptInModalOpen] = useState(false)@@ -83,6 +94,10 @@ export const AIAssistantHeader = ({enabled: !isChatLoading,})+ useShortcut(SHORTCUT_IDS.AI_ASSISTANT_MAXIMIZE, toggleMaximise, {+ enabled: !isChatLoading,+ })+return (<div className="z-30 sticky top-0"><div className="border-b border-b-muted flex items-center bg-card gap-x-4 px-3 min-h-(--header-height)">@@ -130,6 +145,21 @@ export const AIAssistantHeader = ({/></ShortcutTooltip>+ <ShortcutTooltip+ side="bottom"+ label={isMaximised ? 'Minimize' : 'Maximize'}+ shortcutId={SHORTCUT_IDS.AI_ASSISTANT_MAXIMIZE}+ >+ <Button+ variant="text"+ aria-label={isMaximised ? 'Minimize' : 'Maximize'}+ size="tiny"+ icon={isMaximised ? <Minimize /> : <Maximize />}+ onClick={toggleMaximise}+ className="h-7 w-7 p-0"+ />+ </ShortcutTooltip>+<DropdownMenu><DropdownMenuTrigger asChild><ButtonTooltipdiff --git a/apps/studio/state/shortcuts/registry.ts b/apps/studio/state/shortcuts/registry.tsindex 6f9ddc54950..f5fbdad2e6e 100644--- a/apps/studio/state/shortcuts/registry.ts+++ b/apps/studio/state/shortcuts/registry.ts@@ -71,6 +71,7 @@ export const SHORTCUT_IDS = {COMMAND_MENU_OPEN: 'command-menu.open',AI_ASSISTANT_TOGGLE: 'ai-assistant.toggle',AI_ASSISTANT_NEW_CHAT: 'ai-assistant.new-chat',+ AI_ASSISTANT_MAXIMIZE: 'ai-assistant.maximize',AI_ASSISTANT_COPY_CHAT_ID: 'ai-assistant.copy-chat-id',AI_ASSISTANT_TOGGLE_HISTORY: 'ai-assistant.toggle-history',AI_ASSISTANT_OPEN_PERMISSIONS: 'ai-assistant.open-permissions',@@ -263,6 +264,12 @@ export const SHORTCUT_DEFINITIONS: Record<ShortcutId, ShortcutDefinition> = {sequence: ['A', 'N'],showInSettings: false,},+ [SHORTCUT_IDS.AI_ASSISTANT_MAXIMIZE]: {+ id: SHORTCUT_IDS.AI_ASSISTANT_MAXIMIZE,+ label: 'Maximize assistant',+ sequence: ['A', '='],+ showInSettings: false,+ },[SHORTCUT_IDS.AI_ASSISTANT_COPY_CHAT_ID]: {id: SHORTCUT_IDS.AI_ASSISTANT_COPY_CHAT_ID,label: 'Copy chat ID',diff --git a/apps/studio/state/sidebar-manager-state.tsx b/apps/studio/state/sidebar-manager-state.tsxindex c539eb4fc94..1a3f1f4ac59 100644--- a/apps/studio/state/sidebar-manager-state.tsx+++ b/apps/studio/state/sidebar-manager-state.tsx@@ -17,6 +17,7 @@ type SidebarManagerData = {sidebars: Partial<Record<string, ManagedSidebar>>activeSidebar: ManagedSidebar | undefinedpendingSidebarOpen: string | undefined+ isMaximised: boolean}type SidebarManagerState = SidebarManagerData & {@@ -32,12 +33,14 @@ type SidebarManagerState = SidebarManagerData & {isSidebarOpen: (id: string) => booleancloseActive: () => voidclearActiveSidebar: () => void+ toggleMaximise: () => void}const INITIAL_SIDEBAR_MANAGER_DATA: SidebarManagerData = {sidebars: {},activeSidebar: undefined,pendingSidebarOpen: undefined,+ isMaximised: false,}const createSidebarManagerState = () => {@@ -116,6 +119,10 @@ const createSidebarManagerState = () => {return}+ if (id !== 'ai-assistant' && state.isMaximised) {+ state.toggleMaximise()+ }+if (state.activeSidebar && state.activeSidebar.id !== id) {const previousPanel = state.activeSidebarpreviousPanel?.onClose?.()@@ -149,6 +156,10 @@ const createSidebarManagerState = () => {clearActiveSidebar() {state.activeSidebar = undefined},++ toggleMaximise() {+ state.isMaximised = !state.isMaximised+ },})return state