Skip to content

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

chore: update alerts

Jonathan Summers-Muira5809c9f2334
diff --git a/packages/ui/src/components/Command/AiCommand.tsx b/packages/ui/src/components/Command/AiCommand.tsx
index 85b6371f6d2..0d60868872a 100644
--- a/packages/ui/src/components/Command/AiCommand.tsx
+++ b/packages/ui/src/components/Command/AiCommand.tsx
@@ -21,6 +21,7 @@ import { AiIcon, AiIconChat } from './Command.icons'
import { CommandGroup, CommandItem } from './Command.utils'
import { useCommandMenu } from './CommandMenuProvider'
+import { AiWarning } from './Command.alerts'
import { cn } from './../../utils/cn'
@@ -337,18 +338,6 @@ export function queryAi(messages: Message[], timeout = 0) {
})
}
-export const AiWarning = ({ className }: { className?: string }) => (
- <Alert
- variant="warning"
- title="Experimental"
- className={className}
- icon={<IconAlertTriangle strokeWidth={1.5} size={18} />}
- >
- Supabase AI is experimental and may produce incorrect answers. Always verify the output before
- executing.
- </Alert>
-)
-
const AiCommand = () => {
const { isLoading, setIsLoading, search, setSearch, MarkdownHandler } = useCommandMenu()
@@ -467,7 +456,7 @@ const AiCommand = () => {
<div className="[overflow-anchor:auto] h-px w-full"></div>
</div>
<div className="absolute bottom-0 w-full bg-scale-200 py-3">
- {messages.length > 0 && !hasError && <AiWarning className="mb-4 mx-4" />}
+ {messages.length > 0 && !hasError && <AiWarning className="mb-3 mx-3" />}
<Input
className="bg-scale-100 rounded mx-3"
autoFocus
diff --git a/packages/ui/src/components/Command/Command.alerts.tsx b/packages/ui/src/components/Command/Command.alerts.tsx
new file mode 100644
index 00000000000..0a83875ae39
--- /dev/null
+++ b/packages/ui/src/components/Command/Command.alerts.tsx
@@ -0,0 +1,35 @@
+import { Alert } from 'ui'
+import { Microscope } from 'lucide-react'
+
+export const AiWarning = ({ className }: { className?: string }) => (
+ <Alert
+ variant="info"
+ title="Supabase AI is experimental and may produce incorrect answers."
+ className={className}
+ icon={<Microscope strokeWidth={1.5} size={18} className="text-scale-900" />}
+ >
+ <p>Always verify the output before executing.</p>
+ </Alert>
+)
+
+export const IncludeSchemaAlert = () => (
+ <Alert
+ variant={'warning'}
+ title="Project metadata (tables, columns, and data types) is being shared with OpenAI"
+ withIcon
+ className="mx-4"
+ >
+ Start a new conversation to change this configuration
+ </Alert>
+)
+
+export const ExcludeSchemaAlert = () => (
+ <Alert
+ variant={'info'}
+ title="Project metadata (tables, columns, and data types) is not being shared with OpenAI"
+ withIcon
+ className="mx-4"
+ >
+ Start a new conversation to change this configuration
+ </Alert>
+)
diff --git a/packages/ui/src/components/Command/CommandMenuShortcuts.tsx b/packages/ui/src/components/Command/CommandMenuShortcuts.tsx
index 08ff299d7fe..873c70b93d4 100644
--- a/packages/ui/src/components/Command/CommandMenuShortcuts.tsx
+++ b/packages/ui/src/components/Command/CommandMenuShortcuts.tsx
@@ -1,41 +1,43 @@
-import React from 'react'
import { IconArrowLeft } from '../Icon/icons/IconArrowLeft'
+import { Badge } from 'ui'
+import { COMMAND_ROUTES } from './Command.constants'
import { CommandShortcut } from './Command.utils'
import { useCommandMenu } from './CommandMenuProvider'
-import { COMMAND_ROUTES } from './Command.constants'
export default function CommandMenuShortcuts() {
const { setPages, pages, currentPage } = useCommandMenu()
return (
- <div className="flex w-full gap-2 px-4 pt-4 justify-items-start flex-row items-center">
- <CommandShortcut onClick={() => setPages([])}>
- <div className="flex items-center gap-2">
- <IconArrowLeft width={15} height={15} />
- </div>
- </CommandShortcut>
-
- {pages.map((page, index) => (
- <CommandShortcut
- type={page === currentPage ? 'breadcrumb' : 'default'}
- key={page}
- onClick={() => {
- if (index === pages.length - 1) {
- return
- }
- setPages(pages.slice(0, index - 1))
- }}
- >
- {page}
+ <div className="flex w-full gap-2 px-4 pt-4 justify-items-start flex-row items-center justify-between">
+ <div className="flex gap-2 flex-row items-center">
+ <CommandShortcut onClick={() => setPages([])}>
+ <div className="flex items-center gap-2">
+ <IconArrowLeft width={15} height={15} />
+ </div>
</CommandShortcut>
- ))}
- {currentPage && isExperimental(currentPage) && (
- <span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-opacity-10 bg-brand-200 text-brand-1100 border border-brand-700">
- Experimental
- </span>
- )}
+ {pages.map((page, index) => (
+ <CommandShortcut
+ type={page === currentPage ? 'breadcrumb' : 'default'}
+ key={page}
+ onClick={() => {
+ if (index === pages.length - 1) {
+ return
+ }
+ setPages(pages.slice(0, index - 1))
+ }}
+ >
+ {page}
+ </CommandShortcut>
+ ))}
+
+ {currentPage && isExperimental(currentPage) && (
+ <Badge dot color="scale">
+ Experimental
+ </Badge>
+ )}
+ </div>
</div>
)
}
diff --git a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
index d6d4df33c39..9039f484607 100644
--- a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
+++ b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
@@ -12,9 +12,6 @@ import {
MessageRole,
MessageStatus,
useAiChat,
- AiWarning,
- IconAlertCircle,
- Alert,
Tabs,
} from 'ui'
@@ -25,6 +22,7 @@ import { useCommandMenu } from '../CommandMenuProvider'
import { SAMPLE_QUERIES } from '../Command.constants'
import SQLOutputActions from './SQLOutputActions'
import { generatePrompt } from './GenerateSQL.utils'
+import { ExcludeSchemaAlert, IncludeSchemaAlert, AiWarning } from '../Command.alerts'
const GenerateSQL = () => {
// [Joshen] Temp hack to ensure that generatePrompt receives updated value
@@ -88,8 +86,8 @@ const GenerateSQL = () => {
<div onClick={(e) => e.stopPropagation()}>
<div
className={cn(
- 'relative py-4 max-h-[550px] overflow-auto',
- allowSendingSchemaMetadata ? 'mb-[265px]' : 'mb-[155px]'
+ 'relative py-4 max-h-[420px] overflow-auto',
+ allowSendingSchemaMetadata ? 'mb-[155px]' : 'mb-[64px]'
)}
>
{messages.map((message, i) => {
@@ -149,13 +147,20 @@ const GenerateSQL = () => {
</div>
) : (
<div className="space-y-2 flex-grow max-w-[93%]">
- <CodeBlock
- hideCopy
- language="sql"
- className="relative prose dark:prose-dark bg-scale-300 max-w-none"
- >
- {answer}
- </CodeBlock>
+ <div className="-space-y-px">
+ <CodeBlock
+ hideCopy
+ language="sql"
+ className="
+ relative prose dark:prose-dark bg-scale-300 max-w-none !mb-0
+ !rounded-b-none
+
+ "
+ >
+ {answer}
+ </CodeBlock>
+ <AiWarning className="!rounded-t-none border-scale-400" />
+ </div>
{message.status === MessageStatus.Complete && (
<SQLOutputActions answer={answer} messages={messages.slice(0, i + 1)} />
)}
@@ -234,7 +239,7 @@ const GenerateSQL = () => {
</div>
<div className="absolute bottom-0 w-full bg-scale-200 pt-4">
- {messages.length > 0 && !hasError && <AiWarning className="mb-4 mx-4" />}
+ {/* {messages.length > 0 && !hasError && <AiWarning className="mb-4 mx-4" />} */}
{allowSendingSchemaMetadata && (
<div className="mb-4">
{messages.length === 0 ? (
@@ -260,32 +265,10 @@ const GenerateSQL = () => {
}
/>
</div>
+ ) : includeSchemaMetadata ? (
+ <IncludeSchemaAlert />
) : (
- <Alert
- variant={includeSchemaMetadata ? 'info' : 'warning'}
- title="Project metadata"
- icon={
- includeSchemaMetadata ? (
- <IconAlertCircle strokeWidth={1.5} size={18} />
- ) : (
- <IconAlertTriangle strokeWidth={1.5} size={18} />
- )
- }
- className="mx-4"
- >
- <div className="flex flex-col gap-2">
- <p>
- This project's metadata (tables, columns, and data types){' '}
- <span className="text-scale-1200">
- {includeSchemaMetadata ? 'will be' : 'will not be'} sent as context
- </span>{' '}
- in this conversation
- </p>
- <p className="text-scale-1000">
- Start a new conversation to change this configuration
- </p>
- </div>
- </Alert>
+ <ExcludeSchemaAlert />
)}
</div>
)}
diff --git a/packages/ui/src/components/Dropdown/Dropdown.tsx b/packages/ui/src/components/Dropdown/Dropdown.tsx
index 3d1b320b907..760197c5919 100644
--- a/packages/ui/src/components/Dropdown/Dropdown.tsx
+++ b/packages/ui/src/components/Dropdown/Dropdown.tsx
@@ -98,7 +98,10 @@ export function Item({ icon, className, ...props }: ItemProps) {
let __styles = styleHandler('dropdown')
return (
- <RadixDropdown.Item className={cn(__styles.item, className)} {...props}>
+ <RadixDropdown.Item
+ className={cn(__styles.item, className, props.disabled && __styles.disabled)}
+ {...props}
+ >
{icon && icon}
<span>{props.children}</span>
</RadixDropdown.Item>
diff --git a/packages/ui/src/lib/theme/defaultTheme.ts b/packages/ui/src/lib/theme/defaultTheme.ts
index fb9ad36e32e..a794f13bca8 100644
--- a/packages/ui/src/lib/theme/defaultTheme.ts
+++ b/packages/ui/src/lib/theme/defaultTheme.ts
@@ -256,7 +256,7 @@ export default {
alert: {
base: `
- relative rounded border py-4 px-6
+ relative rounded-md border py-4 px-6
flex space-x-4 items-start
`,
header: 'block text-sm font-normal mb-1',
@@ -275,10 +275,10 @@ export default {
description: `text-amber-1100`,
},
info: {
- base: `bg-blue-200 dark:bg-blue-100 border-blue-700`,
- icon: `text-blue-900`,
- header: `text-blue-1200`,
- description: `text-blue-1100`,
+ base: `bg-scale-200 dark:bg-scale-100 border-scale-300`,
+ icon: `text-scale-900`,
+ header: `text-scale-1200`,
+ description: `text-scale-1100`,
},
success: {
base: `bg-brand-300 dark:bg-brand-100 border-brand-700`,
@@ -1247,6 +1247,7 @@ export default {
border-none
focus:outline-none
`,
+ disabled: `opacity-50 cursor-default`,
label: `
text-scale-900
px-4 flex items-center space-x-2 py-1.5