Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add AI assistant callout on support form (#35106)

Jonathan Summers-Muir71c48710f967
diff --git a/apps/studio/components/interfaces/Support/AIAssistantOption.tsx b/apps/studio/components/interfaces/Support/AIAssistantOption.tsx
new file mode 100644
index 00000000000..7a20fa9eb44
--- /dev/null
+++ b/apps/studio/components/interfaces/Support/AIAssistantOption.tsx
@@ -0,0 +1,97 @@
+import { Button } from 'ui'
+import { MessageSquare, Send, X } from 'lucide-react'
+import { motion, AnimatePresence } from 'framer-motion'
+import { useState, useEffect } from 'react'
+import Link from 'next/link'
+import { useProjectsQuery } from 'data/projects/projects-query'
+
+interface AIAssistantOptionProps {
+ projectRef: string
+ organizationSlug: string
+}
+
+export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantOptionProps) => {
+ const [isVisible, setIsVisible] = useState(false)
+ const { data: projects } = useProjectsQuery()
+
+ useEffect(() => {
+ const timer = setTimeout(() => setIsVisible(true), 800)
+ return () => clearTimeout(timer)
+ }, [])
+
+ if (!organizationSlug || organizationSlug === 'no-org') {
+ return null
+ }
+
+ const getProjectRef = () => {
+ if (projectRef !== 'no-project') {
+ return projectRef
+ }
+ // If no specific project selected, use first project from the org
+ const orgProjects = projects?.filter((p) => p.organization_slug === organizationSlug)
+ return orgProjects?.[0]?.ref || '_'
+ }
+
+ const aiLink = `/project/${getProjectRef()}?aiAssistantPanelOpen=true`
+
+ return (
+ <AnimatePresence initial={false}>
+ {isVisible && (
+ <motion.div
+ initial={{ height: 0, opacity: 0 }}
+ animate={{ height: 'auto', opacity: 1 }}
+ exit={{ 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>
+ <p className="text-sm text-foreground">Try the AI Assistant</p>
+ <p className="text-sm text-foreground-lighter">
+ Ask the AI assistant to help you with your support issue
+ </p>
+ </div>
+ <div>
+ <Link href={aiLink}>
+ <Button size="tiny" type="default">
+ Ask AI assistant
+ </Button>
+ </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" />
+ </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>
+ </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>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ )
+}
diff --git a/apps/studio/components/interfaces/Support/SupportFormV2.tsx b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
index b13c1502d56..d1adafc13dd 100644
--- a/apps/studio/components/interfaces/Support/SupportFormV2.tsx
+++ b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
@@ -58,13 +58,18 @@ const INCLUDE_DISCUSSIONS = ['Problem', 'Database_unresponsive']
const CONTAINER_CLASSES = 'px-6'
interface SupportFormV2Props {
+ onProjectSelected: (value: string) => void
+ onOrganizationSelected: (value: string) => void
setSentCategory: (value: string) => void
- setSelectedProject: (value: string) => void
}
// [Joshen] Just naming it as V2 for now for PR review purposes so its easier to view
// This is a rewrite of the old SupportForm to use the new form components
-export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFormV2Props) => {
+export const SupportFormV2 = ({
+ onProjectSelected: setSelectedProject,
+ onOrganizationSelected: setSelectedOrganization,
+ setSentCategory,
+}: SupportFormV2Props) => {
const { profile } = useProfile()
const {
projectRef: ref,
@@ -295,6 +300,18 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
if (urlMessage) form.setValue('message', urlMessage)
}, [urlMessage])
+ // Sync organization selection with parent state
+ // Initialized as 'no-org' in parent if no org is selected
+ useEffect(() => {
+ setSelectedOrganization(organizationSlug)
+ }, [organizationSlug, setSelectedOrganization])
+
+ // Sync project selection with parent state
+ // Initialized as 'no-project' in parent if no project is selected
+ useEffect(() => {
+ setSelectedProject(projectRef)
+ }, [projectRef, setSelectedProject])
+
return (
<Form_Shadcn_ {...form}>
<form
diff --git a/apps/studio/pages/support/new.tsx b/apps/studio/pages/support/new.tsx
index 2975c2436f3..5f3a76beffb 100644
--- a/apps/studio/pages/support/new.tsx
+++ b/apps/studio/pages/support/new.tsx
@@ -16,10 +16,14 @@ import { BASE_PATH } from 'lib/constants'
import { toast } from 'sonner'
import { NextPageWithLayout } from 'types'
import { Button, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
+import { AIAssistantOption } from 'components/interfaces/Support/AIAssistantOption'
const SupportPage: NextPageWithLayout = () => {
const [sentCategory, setSentCategory] = useState<string>()
+ // For AIAssistantOption projectRef prop
const [selectedProject, setSelectedProject] = useState<string>('no-project')
+ // For AIAssistantOption organizationSlug prop
+ const [selectedOrganization, setSelectedOrganization] = useState<string>('no-org')
const { data, isLoading } = usePlatformStatusQuery()
const isHealthy = data?.isHealthy
@@ -34,6 +38,7 @@ const SupportPage: NextPageWithLayout = () => {
<SVG src={`${BASE_PATH}/img/supabase-logo.svg`} className="h-4 w-4" />
<h1 className="m-0 text-lg">Supabase support</h1>
</div>
+
<div className="flex items-center gap-x-3">
<Button asChild type="default" icon={<Wrench />}>
<Link
@@ -74,7 +79,7 @@ const SupportPage: NextPageWithLayout = () => {
</Tooltip>
</div>
</div>
-
+ <AIAssistantOption projectRef={selectedProject} organizationSlug={selectedOrganization} />
<div
className={[
'min-w-full w-full space-y-12 rounded border bg-panel-body-light shadow-md',
@@ -90,8 +95,9 @@ const SupportPage: NextPageWithLayout = () => {
/>
) : (
<SupportFormV2
+ onProjectSelected={setSelectedProject}
+ onOrganizationSelected={setSelectedOrganization}
setSentCategory={setSentCategory}
- setSelectedProject={setSelectedProject}
/>
)}
</div>