The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
assistant button in help popover (#36184)
Saxon Fletcher908444c37822
diff --git a/apps/studio/components/interfaces/Support/AIAssistantOption.tsx b/apps/studio/components/interfaces/Support/AIAssistantOption.tsxindex 8549b831b2c..debff627760 100644--- a/apps/studio/components/interfaces/Support/AIAssistantOption.tsx+++ b/apps/studio/components/interfaces/Support/AIAssistantOption.tsx@@ -9,10 +9,15 @@ import { Button } from 'ui'interface AIAssistantOptionProps {projectRef: stringorganizationSlug: string+ isCondensed?: boolean}-export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantOptionProps) => {- const [isVisible, setIsVisible] = useState(false)+export const AIAssistantOption = ({+ projectRef,+ organizationSlug,+ isCondensed = false,+}: AIAssistantOptionProps) => {+ const [isVisible, setIsVisible] = useState(isCondensed ? true : false)const { data: projects } = useProjectsQuery()const { mutate: sendEvent } = useSendEventMutation()@@ -55,15 +60,8 @@ export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantOexit={{ height: 0, opacity: 0 }}className="w-full overflow-hidden border rounded-md relative">- <div className="flex flex-col xl:flex-row py-8 px-10">- <Button- type="text"- size="tiny"- className="absolute top-3 right-3 hover:bg-background-surface-300 z-[2] px-1"- icon={<X size={14} strokeWidth={2} />}- onClick={() => setIsVisible(false)}- />- <div className="flex flex-col gap-3 z-[2] flex-shrink-0">+ <div className={`flex flex-col xl:flex-row ${isCondensed ? 'py-4 px-5' : 'py-8 px-10'}`}>+ <div className="flex flex-col gap-3 z-[2] flex-shrink-0 w-full"><div><p className="text-sm text-foreground">Try the AI Assistant</p><p className="text-sm text-foreground-lighter">@@ -78,29 +76,31 @@ export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantO</Link></div></div>- <div className="absolute z-[1] scale-75 -right-24 top-0">- <div className="relative grow flex flex-col gap-3 w-[400px]">- <div className="flex items-start gap-3 pl-12">- <div className="w-8 h-8 rounded-full bg-background-surface-300 flex items-center justify-center">- <MessageSquare size={16} className="text-foreground-lighter" />+ {!isCondensed && (+ <div className="absolute z-[1] scale-75 -right-24 top-0">+ <div className="relative grow flex flex-col gap-3 w-[400px]">+ <div className="flex items-start gap-3 pl-12">+ <div className="w-8 h-8 rounded-full bg-background-surface-300 flex items-center justify-center">+ <MessageSquare size={16} className="text-foreground-lighter" />+ </div>+ <div className="flex-1 bg-background-surface-200 rounded-lg p-4 max-w-[280px]">+ <p className="text-sm text-foreground-lighter">+ Hi! I'm your AI assistant. How can I help you today?+ </p>+ </div></div>- <div className="flex-1 bg-background-surface-200 rounded-lg p-4 max-w-[280px]">- <p className="text-sm text-foreground-lighter">- Hi! I'm your AI assistant. How can I help you today?- </p>- </div>- </div>- <div className="flex items-start justify-end gap-3 pr-10">- <div className="bg-background-surface-200 rounded-lg p-4 max-w-[280px]">- <p className="text-sm text-foreground-lighter">- I can help you with database queries, API endpoints, or any other technical- questions you might have.- </p>+ <div className="flex items-start justify-end gap-3 pr-10">+ <div className="bg-background-surface-200 rounded-lg p-4 max-w-[280px]">+ <p className="text-sm text-foreground-lighter">+ I can help you with database queries, API endpoints, or any other technical+ questions you might have.+ </p>+ </div></div></div>+ <div className="absolute -inset-2 bg-gradient-to-l from-transparent via-background-200 via-[95%] to-background-200 to-[100%] z-[1]" /></div>- <div className="absolute -inset-2 bg-gradient-to-l from-transparent via-background-200 via-[95%] to-background-200 to-[100%] z-[1]" />- </div>+ )}</div></motion.div>)}diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPopover.tsxindex fffa63a611d..65c7eef80dd 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPopover.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPopover.tsx@@ -7,8 +7,12 @@ import SVG from 'react-inlinesvg'import { ButtonTooltip } from 'components/ui/ButtonTooltip'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'import {+ AiIconAnimation,Button,+ ButtonGroup,+ ButtonGroupItem,Popover,PopoverContent_Shadcn_,PopoverTrigger_Shadcn_,@@ -20,6 +24,7 @@ export const HelpPopover = () => {const router = useRouter()const { project } = useProjectContext()const org = useSelectedOrganization()+ const snap = useAiAssistantStateSnapshot()const { mutate: sendEvent } = useSendEventMutation()@@ -44,42 +49,62 @@ export const HelpPopover = () => {/></PopoverTrigger_Shadcn_><PopoverContent_Shadcn_ className="w-[400px] space-y-4 p-0 py-5" align="end" side="bottom">- <div className="mb-5 space-y-4 px-5">- <h5 className="text-foreground">Need help with your project?</h5>+ <div className="mb-5 px-5">+ <h5 className="text-foreground mb-2">Need help with your project?</h5><p className="text-sm text-foreground-lighter">- For issues with your project hosted on supabase.com, or other inquiries about our hosted- services.+ For issues with your project hosted on supabase.com or other hosted service inquiries.+ Response times are based on your billing plan, with paid plans prioritized.</p>- <div className="space-x-1">- <Button asChild type="default" icon={<Wrench />}>- <Link+ </div>+ <div className="px-5">+ <ButtonGroup className="w-full">+ {projectRef && (+ <ButtonGroupItem+ size="tiny"+ icon={<AiIconAnimation allowHoverEffect size={14} />}+ onClick={() => {+ snap.newChat({+ name: 'Support',+ open: true,+ initialInput: `I need help with my project`,+ suggestions: {+ title:+ 'I can help you with your project, here are some example prompts to get you started:',+ prompts: [+ 'Summarise my database health and performance',+ 'View and debug my edge function logs',+ 'Implement row level security for my tables',+ ],+ },+ })+ }}+ >+ Supabase Assistant+ </ButtonGroupItem>+ )}+ <ButtonGroupItem size="tiny" icon={<Wrench strokeWidth={1.5} size={14} />} asChild>+ <ahref="https://supabase.com/docs/guides/platform/troubleshooting"target="_blank"rel="noreferrer">Troubleshooting- </Link>- </Button>- <Button asChild type="text" size="tiny" icon={<BookOpen />}>- <Link href="https://supabase.com/docs/" target="_blank" rel="noreferrer">+ </a>+ </ButtonGroupItem>+ <ButtonGroupItem size="tiny" icon={<BookOpen strokeWidth={1.5} size={14} />} asChild>+ <a href="https://supabase.com/docs/" target="_blank" rel="noreferrer">Docs- </Link>- </Button>- <Button asChild type="text" size="tiny" icon={<Activity />}>- <Link href="https://status.supabase.com/" target="_blank" rel="noreferrer">+ </a>+ </ButtonGroupItem>+ <ButtonGroupItem size="tiny" icon={<Activity strokeWidth={1.5} size={14} />} asChild>+ <a href="https://status.supabase.com/" target="_blank" rel="noreferrer">Supabase Status- </Link>- </Button>- </div>- <p className="text-sm text-foreground-lighter">- Expected response time is based on your billing plan. Projects on paid plans are- prioritized.- </p>- <div>- <Button asChild type="default" icon={<Mail />}>+ </a>+ </ButtonGroupItem>+ <ButtonGroupItem size="tiny" icon={<Mail strokeWidth={1.5} size={14} />}><Link href={supportUrl}>Contact Support</Link>- </Button>- </div>+ </ButtonGroupItem>+ </ButtonGroup></div><Popover.Separator /><div className="mb-4 space-y-2">diff --git a/packages/ui/index.tsx b/packages/ui/index.tsxindex dabb4e30d6d..5970d2bf230 100644--- a/packages/ui/index.tsx+++ b/packages/ui/index.tsx@@ -177,6 +177,8 @@ export { Input as Input_Shadcn_ } from './src/components/shadcn/ui/input'export { Button as Button_Shadcn_ } from './src/components/shadcn/ui/button'+export { ButtonGroup, ButtonGroupItem } from './src/components/shadcn/ui/button-group'+export {Breadcrumb as Breadcrumb_Shadcn_,BreadcrumbItem as BreadcrumbItem_Shadcn_,diff --git a/packages/ui/src/components/shadcn/ui/button-group.tsx b/packages/ui/src/components/shadcn/ui/button-group.tsxnew file mode 100644index 00000000000..5be74cb993a--- /dev/null+++ b/packages/ui/src/components/shadcn/ui/button-group.tsx@@ -0,0 +1,56 @@+'use client'++import * as React from 'react'+import { cn } from '../../../lib/utils/cn'+import { Button, ButtonProps } from '../../Button/Button'++interface ButtonGroupProps extends React.HTMLAttributes<HTMLDivElement> {+ children: React.ReactNode+}++interface ButtonGroupItemProps extends Omit<ButtonProps, 'variant'> {+ children: React.ReactNode+ icon?: React.ReactNode+ asChild?: boolean+}++const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(+ ({ className, children, ...props }, ref) => {+ return (+ <div+ ref={ref}+ className={cn(+ 'flex flex-col items-stretch border border-control rounded-md overflow-hidden',+ className+ )}+ {...props}+ >+ {children}+ </div>+ )+ }+)+ButtonGroup.displayName = 'ButtonGroup'++const ButtonGroupItem = React.forwardRef<HTMLButtonElement, ButtonGroupItemProps>(+ ({ className, children, icon, asChild, ...props }, ref) => {+ return (+ <Button+ ref={ref}+ type="text"+ icon={icon}+ asChild={asChild}+ className={cn(+ 'h-auto py-2 rounded-none justify-start border-0 border-b border-border last:border-b-0',+ className+ )}+ {...props}+ >+ {children}+ </Button>+ )+ }+)+ButtonGroupItem.displayName = 'ButtonGroupItem'++export { ButtonGroup, ButtonGroupItem, type ButtonGroupProps, type ButtonGroupItemProps }