Skip to content

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

Assistant refinements (#30685)

Saxon Fletcheraea64c9a07e8
diff --git a/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
index acfd0705ee7..601fd07558a 100644
--- a/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
@@ -114,7 +114,11 @@ const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<ProjectLayout
useEffect(() => {
const handler = (e: KeyboardEvent) => {
- if (e.metaKey && e.code === 'KeyI') setAiAssistantPanel({ open: !open })
+ if (e.metaKey && e.code === 'KeyI') {
+ setAiAssistantPanel({ open: !open })
+ e.preventDefault()
+ e.stopPropagation()
+ }
}
if (isAssistantV2Enabled) window.addEventListener('keydown', handler)
return () => window.removeEventListener('keydown', handler)
diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx
index 050323869e2..81f71e9bd35 100644
--- a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx
@@ -1,5 +1,5 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { motion } from 'framer-motion'
+import { AnimatePresence, motion } from 'framer-motion'
import { last } from 'lodash'
import { FileText } from 'lucide-react'
import { memo, useEffect, useMemo, useRef, useState } from 'react'
@@ -7,6 +7,7 @@ import { toast } from 'sonner'
import type { Message as MessageType } from 'ai/react'
import { useChat } from 'ai/react'
+import { useParams, useSearchParamsShallow } from 'common/hooks'
import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'
import { Markdown } from 'components/interfaces/Markdown'
import OptInToOpenAIToggle from 'components/interfaces/Organization/GeneralSettings/OptInToOpenAIToggle'
@@ -25,7 +26,9 @@ import { useFlag } from 'hooks/ui/useFlag'
import { BASE_PATH, IS_PLATFORM, OPT_IN_TAGS } from 'lib/constants'
import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
import uuidv4 from 'lib/uuid'
+import { useRouter } from 'next/router'
import { useAppStateSnapshot } from 'state/app-state'
+import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
import {
AiIconAnimation,
Button,
@@ -40,10 +43,6 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import AIOnboarding from './AIOnboarding'
import CollapsibleCodeBlock from './CollapsibleCodeBlock'
import { Message } from './Message'
-import { useParams } from 'common/hooks'
-import { useSearchParamsShallow } from 'common/hooks'
-import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
-import { useRouter } from 'next/router'
const MemoizedMessage = memo(
({ message, isLoading }: { message: MessageType; isLoading: boolean }) => {
@@ -235,14 +234,18 @@ export const AIAssistant = ({
// Add useEffect to set up scroll listener
useEffect(() => {
- const container = scrollContainerRef.current
- if (container) {
- container.addEventListener('scroll', handleScroll)
- // Initial check
- handleScroll()
- }
+ // Use a small delay to ensure container is mounted and has content
+ const timeoutId = setTimeout(() => {
+ const container = scrollContainerRef.current
+ if (container) {
+ container.addEventListener('scroll', handleScroll)
+ handleScroll()
+ }
+ }, 100)
return () => {
+ clearTimeout(timeoutId)
+ const container = scrollContainerRef.current
if (container) {
container.removeEventListener('scroll', handleScroll)
}
@@ -507,12 +510,18 @@ export const AIAssistant = ({
</div>
)}
</div>
-
- {showFade && (
- <div className="pointer-events-none z-10 -mt-24">
- <div className="h-24 w-full bg-gradient-to-t from-background muted to-transparent" />
- </div>
- )}
+ <AnimatePresence>
+ {showFade && (
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ className="pointer-events-none z-10 -mt-24"
+ >
+ <div className="h-24 w-full bg-gradient-to-t from-background muted to-transparent" />
+ </motion.div>
+ )}
+ </AnimatePresence>
<div className="p-5 pt-0 z-20 relative">
{sqlSnippets && sqlSnippets.length > 0 && (
@@ -565,7 +574,7 @@ export const AIAssistant = ({
? 'Reply to the assistant...'
: (sqlSnippets ?? [])?.length > 0
? 'Ask a question or make a change...'
- : 'How can we help you today?'
+ : 'Chat to Postgres...'
}
value={value}
onValueChange={(e) => setValue(e.target.value)}
diff --git a/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx b/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx
index 5f505e24f9b..0d330085b60 100644
--- a/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/AIOnboarding.tsx
@@ -1,6 +1,13 @@
import { motion } from 'framer-motion'
+import { FileText, MessageCircleMore, WandSparkles } from 'lucide-react'
+
+import DotGrid from 'components/ui/DotGrid'
import { Button } from 'ui'
-import { WandSparkles, FileText, MessageCircle, MessageCircleMore } from 'lucide-react'
+import {
+ InnerSideMenuCollapsible,
+ InnerSideMenuCollapsibleContent,
+ InnerSideMenuCollapsibleTrigger,
+} from 'ui-patterns/InnerSideMenu'
interface AIOnboardingProps {
setMessages: (messages: any[]) => void
@@ -13,233 +20,226 @@ export default function AIOnboarding({ setMessages, onSendMessage }: AIOnboardin
}
return (
- <div className="w-full px-8 py-content flex flex-col flex-1 h-full">
- <div className="shrink-0 h-64 mb-5 w-auto overflow-hidden -mx-8 -mt-8 relative">
- <motion.div
- initial={{ height: '800%', bottom: 0 }}
- animate={{ height: '100%', bottom: 0, transition: { duration: 8 } }}
- className="absolute bottom-0 left-0 right-0 z-20 bg-gradient-to-b from-transparent to-background"
- />
- <div className="h-full w-full relative">
- <motion.div
- initial={{ x: 350, rotate: -45 }}
- animate={{
- x: 400,
- rotate: -45,
- transition: { duration: 5, ease: 'easeInOut' },
- }}
- className="absolute -inset-full bg-gradient-to-b from-black/[0.05] dark:from-white/[0.08] to-transparent "
- />
- <motion.div
- initial={{ x: 380, rotate: -45 }}
- animate={{
- x: 500,
- rotate: -45,
- transition: { duration: 5, ease: 'easeInOut' },
- }}
- className="absolute -inset-full bg-gradient-to-b from-black/[0.05] dark:from-white/[0.08] to-transparent "
- />
- <motion.div
- initial={{ x: 410, rotate: -45 }}
- animate={{
- x: 600,
- rotate: -45,
- transition: { duration: 5, ease: 'easeInOut' },
- }}
- className="absolute -inset-full bg-gradient-to-b from-black/[0.05] dark:from-white/[0.08] to-transparent "
- />
- </div>
+ <div className="w-full p-8 flex flex-col grow shrink-0 justify-end overflow-auto">
+ <div className="min-h-48 grow shrink-0">
+ <DotGrid rows={10} columns={10} count={33} />
</div>
- <motion.div
- initial={{ x: -10, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- transition={{ delay: 0 }}
- >
- <p className="text-base mb-8">How can I help you today?</p>
- </motion.div>
- <motion.div className="space-y-6 pb-16">
- <motion.section
+ <div className="shrink-0">
+ <motion.div
initial={{ x: -10, opacity: 0 }}
animate={{ x: 0, opacity: 1 }}
transition={{ delay: 0 }}
>
- <h3 className="text-foreground-light font-mono text-sm uppercase mb-3">Tables</h3>
- <div className="-mx-3">
- <Button
- size="small"
- icon={<WandSparkles strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant(
- "Create a table of countries and a table of cities. The cities table should have a country column that's a foreign key to the countries table."
- )
- }
- >
- Create a new table
- </Button>
+ <p className="text-base mb-2">How can I assist you?</p>
+ <p className="text-sm text-foreground-lighter mb-4">
+ I can help you build and manage your database by writing SQL or supabase-js, set up
+ policies, functions or triggers, and query your data - ask me anything.
+ </p>
+ </motion.div>
+ <motion.div>
+ <motion.div
+ initial={{ x: -10, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ transition={{ delay: 0 }}
+ >
+ <InnerSideMenuCollapsible className="border-b border-muted py-3">
+ <InnerSideMenuCollapsibleTrigger className="px-0" title="Tables" />
+ <InnerSideMenuCollapsibleContent>
+ <div className="mt-3 mb-1 space-y-1">
+ <Button
+ size="small"
+ icon={<WandSparkles strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(
+ "Create a table of countries and a table of cities. The cities table should have a country column that's a foreign key to the countries table."
+ )
+ }
+ >
+ Create a new table
+ </Button>
- <Button
- size="small"
- icon={<FileText strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant(
- 'Give me a list of new users from the auth.users table who signed up in the past week'
- )
- }
- >
- Query your data
- </Button>
+ <Button
+ size="small"
+ icon={<FileText strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(
+ 'Give me a list of new users from the auth.users table who signed up in the past week'
+ )
+ }
+ >
+ Query your data
+ </Button>
- <Button
- size="small"
- icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant(
- 'Give me a chart showing the number of new sign ups in the auth.users table per day over the last week'
- )
- }
- >
- Chart your data
- </Button>
- </div>
- </motion.section>
+ <Button
+ size="small"
+ icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(
+ 'Give me a chart showing the number of new sign ups in the auth.users table per day over the last week'
+ )
+ }
+ >
+ Chart your data
+ </Button>
+ </div>
+ </InnerSideMenuCollapsibleContent>
+ </InnerSideMenuCollapsible>
+ </motion.div>
- <motion.section
- initial={{ x: -10, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- transition={{ delay: 0.1 }}
- >
- <h3 className="text-foreground-light font-mono text-sm uppercase mb-3">RLS Policies</h3>
- <div className="-mx-3">
- <Button
- size="small"
- icon={<WandSparkles strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant(
- 'Suggest some database RLS policies I can add to my public schema'
- )
- }
- >
- Suggest RLS policies
- </Button>
+ <motion.div
+ initial={{ x: -10, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ transition={{ delay: 0.1 }}
+ >
+ <InnerSideMenuCollapsible className="border-b border-muted py-3">
+ <InnerSideMenuCollapsibleTrigger className="px-0" title="RLS Policies" />
+ <InnerSideMenuCollapsibleContent>
+ <div className="mt-3 mb-1 space-y-1">
+ <Button
+ size="small"
+ icon={<WandSparkles strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(
+ 'Suggest some database RLS policies I can add to my public schema'
+ )
+ }
+ >
+ Suggest RLS policies
+ </Button>
- <Button
- size="small"
- icon={<FileText strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant('Generate some examples of database RLS policies')
- }
- >
- Examples of RLS policies
- </Button>
+ <Button
+ size="small"
+ icon={<FileText strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant('Generate some examples of database RLS policies')
+ }
+ >
+ Examples of RLS policies
+ </Button>
- <Button
- size="small"
- icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() => sendMessageToAssistant(`What are database RLS policies`)}
- >
- What are RLS policies?
- </Button>
- </div>
- </motion.section>
+ <Button
+ size="small"
+ icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() => sendMessageToAssistant(`What are database RLS policies`)}
+ >
+ What are RLS policies?
+ </Button>
+ </div>
+ </InnerSideMenuCollapsibleContent>
+ </InnerSideMenuCollapsible>
+ </motion.div>
- <motion.section
- initial={{ x: -10, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- transition={{ delay: 0.2 }}
- >
- <h3 className="text-foreground-light font-mono text-sm uppercase mb-3">Functions</h3>
- <div className="-mx-3">
- <Button
- size="small"
- icon={<WandSparkles strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant(
- 'Suggest some database functions I can add to my public schema'
- )
- }
- >
- Suggest database functions
- </Button>
+ <motion.div
+ initial={{ x: -10, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ transition={{ delay: 0.2 }}
+ >
+ <InnerSideMenuCollapsible className="border-b border-muted py-3">
+ <InnerSideMenuCollapsibleTrigger className="px-0" title="Functions" />
+ <InnerSideMenuCollapsibleContent>
+ <div className="mt-3 mb-1 space-y-1">
+ <Button
+ size="small"
+ icon={<WandSparkles strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(
+ 'Suggest some database functions I can add to my public schema'
+ )
+ }
+ >
+ Suggest database functions
+ </Button>
- <Button
- size="small"
- icon={<FileText strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() => sendMessageToAssistant('Generate some examples of database functions')}
- >
- Examples of database functions
- </Button>
+ <Button
+ size="small"
+ icon={<FileText strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant('Generate some examples of database functions')
+ }
+ >
+ Examples of database functions
+ </Button>
- <Button
- size="small"
- icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() => sendMessageToAssistant('What are database functions')}
- >
- What are database functions?
- </Button>
- </div>
- </motion.section>
+ <Button
+ size="small"
+ icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() => sendMessageToAssistant('What are database functions')}
+ >
+ What are database functions?
+ </Button>
+ </div>
+ </InnerSideMenuCollapsibleContent>
+ </InnerSideMenuCollapsible>
+ </motion.div>
- <motion.section
- initial={{ x: -10, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- transition={{ delay: 0.3 }}
- >
- <h3 className="text-foreground-light font-mono text-sm uppercase mb-3">Triggers</h3>
- <div className="-mx-3">
- <Button
- size="small"
- icon={<WandSparkles strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() =>
- sendMessageToAssistant(
- 'Suggest some database triggers I can add to my public schema'
- )
- }
- >
- Suggest database Triggers
- </Button>
+ <motion.div
+ initial={{ x: -10, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ transition={{ delay: 0.3 }}
+ >
+ <InnerSideMenuCollapsible className="py-3">
+ <InnerSideMenuCollapsibleTrigger className="px-0" title="Triggers" />
+ <InnerSideMenuCollapsibleContent>
+ <div className="mt-3 mb-1 space-y-1">
+ <Button
+ size="small"
+ icon={<WandSparkles strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(
+ 'Suggest some database triggers I can add to my public schema'
+ )
+ }
+ >
+ Suggest database Triggers
+ </Button>
- <Button
- size="small"
- icon={<FileText strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() => sendMessageToAssistant(`Generate some examples of database triggers`)}
- >
- Examples of database triggers
- </Button>
+ <Button
+ size="small"
+ icon={<FileText strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() =>
+ sendMessageToAssistant(`Generate some examples of database triggers`)
+ }
+ >
+ Examples of database triggers
+ </Button>
- <Button
- size="small"
- icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
- type="text"
- className="w-full justify-start py-1 h-auto"
- onClick={() => sendMessageToAssistant('What are database triggers')}
- >
- What are database triggers?
- </Button>
- </div>
- </motion.section>
- </motion.div>
+ <Button
+ size="small"
+ icon={<MessageCircleMore strokeWidth={1.5} size={16} />}
+ type="text"
+ className="w-full justify-start py-1 h-auto"
+ onClick={() => sendMessageToAssistant('What are database triggers')}
+ >
+ What are database triggers?
+ </Button>
+ </div>
+ </InnerSideMenuCollapsibleContent>
+ </InnerSideMenuCollapsible>
+ </motion.div>
+ </motion.div>
+ </div>
</div>
)
}
diff --git a/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx b/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx
index de91f7eab30..5cbde110e8b 100644
--- a/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx
@@ -1,4 +1,4 @@
-import { Code, DatabaseIcon, Edit, Play } from 'lucide-react'
+import { Code, Edit, Play } from 'lucide-react'
import { useRouter } from 'next/router'
import { useCallback, useEffect, useState } from 'react'
import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'
@@ -21,6 +21,7 @@ import {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
+ SQL_ICON,
cn,
} from 'ui'
import { Admonition } from 'ui-patterns'
@@ -211,7 +212,17 @@ export const SqlCard = ({
</Admonition>
) : (
<>
- <DatabaseIcon size={16} strokeWidth={1.5} />
+ <SQL_ICON
+ className={cn(
+ 'transition-colors',
+ 'fill-foreground-muted',
+ 'group-aria-selected:fill-foreground',
+ 'w-5 h-5 shrink-0',
+ '-ml-0.5'
+ )}
+ size={16}
+ strokeWidth={1.5}
+ />
<h3 className="text-sm font-medium flex-1">{title}</h3>
{!readOnly && (
@@ -313,11 +324,12 @@ export const SqlCard = ({
{showCode && (
<CodeBlock
hideLineNumbers
+ wrapLines={false}
value={sql}
language="sql"
className={cn(
'max-h-96 max-w-none block !bg-transparent !py-3 !px-3.5 prose dark:prose-dark border-0 border-t text-foreground !rounded-none w-full',
- '[&>code]:m-0 [&>code>span]:flex [&>code>span]:flex-wrap [&>code]:block [&>code>span]:text-foreground'
+ '[&>code]:m-0 [&>code>span]:text-foreground'
)}
/>
)}
diff --git a/apps/studio/components/ui/DotGrid.tsx b/apps/studio/components/ui/DotGrid.tsx
new file mode 100644
index 00000000000..906206b9e41
--- /dev/null
+++ b/apps/studio/components/ui/DotGrid.tsx
@@ -0,0 +1,73 @@
+import { motion } from 'framer-motion'
+
+interface DotGridProps {
+ rows: number
+ columns: number
+ count: number
+}
+
+const DotGrid = ({ rows, columns, count }: DotGridProps) => {
+ const container = {
+ hidden: { opacity: 1 },
+ visible: {
+ opacity: 1,
+ transition: {
+ staggerChildren: 0.05,
+ delayChildren: 0.05,
+ },
+ },
+ }
+
+ const item = {
+ hidden: { opacity: 0 },
+ visible: { opacity: 0.5 },
+ }
+
+ const highlightedVariants = {
+ visible: {
+ opacity: [1, 0.5, 1],
+ transition: {
+ repeat: Infinity,
+ duration: 0.5,
+ repeatDelay: 1.5,
+ ease: 'easeInOut',
+ },
+ },
+ }
+
+ return (
+ <div
+ className="relative w-full h-full"
+ style={{
+ maskImage: 'linear-gradient(to bottom, black, transparent)',
+ WebkitMaskImage: 'linear-gradient(to bottom, black, transparent)',
+ }}
+ >
+ <motion.div
+ className="grid w-full h-full justify-between items-space-between items-start"
+ style={{
+ gridTemplateColumns: `repeat(${columns}, 1px)`,
+ gridTemplateRows: `repeat(${rows}, 1fr)`,
+ rowGap: 'auto',
+ }}
+ variants={container}
+ initial="hidden"
+ animate="visible"
+ aria-label={`Grid of ${rows * columns} dots, ${count} highlighted`}
+ >
+ {Array.from({ length: rows * columns }).map((_, index) => {
+ const isHighlighted = index < count
+ return (
+ <motion.div
+ key={index}
+ variants={isHighlighted ? highlightedVariants : item}
+ className={`w-[1px] h-[1px] rounded-full bg-foreground`}
+ />
+ )
+ })}
+ </motion.div>
+ </div>
+ )
+}
+
+export default DotGrid
diff --git a/apps/studio/pages/api/ai/sql/generate-v3.ts b/apps/studio/pages/api/ai/sql/generate-v3.ts
index 343cde4a462..917c3d07bf5 100644
--- a/apps/studio/pages/api/ai/sql/generate-v3.ts
+++ b/apps/studio/pages/api/ai/sql/generate-v3.ts
@@ -77,6 +77,7 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {
- Output as markdown
- Always include code snippets if available
- If a code snippet is SQL, the first line of the snippet should always be -- props: {"title": "Query title", "isChart": "true", "xAxis": "columnName", "yAxis": "columnName"}
+ - Only set chart to true if the query makes sense as a chart
- Explain what the snippet does in a sentence or two before showing it
- Use vector(384) data type for any embedding/vector related query
- When debugging, retrieve sql schema details to ensure sql is correct
@@ -106,7 +107,7 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {
Please make sure that all queries are valid Postgres SQL queries
# You convert sql to supabase-js client code
- Use the convertSqlToSupabaseJs tool to convert select sql to supabase-js client code. If conversion isn't supported, build a postgres function instead and suggest using supabase-js to call it via "const { data, error } = await supabase.rpc('echo', { say: '👋'})"
+ Use the convertSqlToSupabaseJs tool to convert select sql to supabase-js client code. Only provide js code snippets if explicitly asked. If conversion isn't supported, build a postgres function instead and suggest using supabase-js to call it via "const { data, error } = await supabase.rpc('echo', { say: '👋'})"
Follow these instructions:
- First look at the list of provided schemas and if needed, get more information about a schema. You will almost always need to retrieve information about the public schema before answering a question. If the question is about users, also retrieve the auth schema.
diff --git a/packages/ui/src/components/CodeBlock/CodeBlock.tsx b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
index 0aeaedc2410..2013320d5ba 100644
--- a/packages/ui/src/components/CodeBlock/CodeBlock.tsx
+++ b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
@@ -52,6 +52,7 @@ export interface CodeBlockProps {
children?: string
renderer?: SyntaxHighlighterProps['renderer']
focusable?: boolean
+ wrapLines?: boolean
}
/**
@@ -84,6 +85,7 @@ export const CodeBlock = ({
children,
hideCopy = false,
hideLineNumbers = false,
+ wrapLines = true,
renderer,
focusable = true,
}: CodeBlockProps) => {
@@ -150,7 +152,7 @@ export const CodeBlock = ({
{/* @ts-ignore */}
<SyntaxHighlighter
language={lang}
- wrapLines={true}
+ wrapLines={wrapLines}
// @ts-ignore
style={monokaiTheme}
className={cn(
diff --git a/packages/ui/src/components/TreeView/TreeView.tsx b/packages/ui/src/components/TreeView/TreeView.tsx
index 53e463971e6..8673e308b13 100644
--- a/packages/ui/src/components/TreeView/TreeView.tsx
+++ b/packages/ui/src/components/TreeView/TreeView.tsx
@@ -237,4 +237,4 @@ const TreeViewFolderIcon = forwardRef<SVGSVGElement, LucideSVGProps & { isOpen?:
}
)
-export { TreeView, TreeViewFolderIcon, TreeViewItem, flattenTree }
+export { TreeView, TreeViewFolderIcon, TreeViewItem, flattenTree, SQL_ICON }