Skip to content

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

refactor(cmdk): ai disclaimer & messaging to use Alert component

Greg Richardson3502f04527d4
diff --git a/packages/ui/src/components/Command/AiCommand.tsx b/packages/ui/src/components/Command/AiCommand.tsx
index 503f3167e58..e51b65c913d 100644
--- a/packages/ui/src/components/Command/AiCommand.tsx
+++ b/packages/ui/src/components/Command/AiCommand.tsx
@@ -15,7 +15,7 @@ import {
import { SSE } from 'sse.js'
-import { Button, IconAlertTriangle, IconCornerDownLeft, IconUser, Input } from 'ui'
+import { Alert, Button, IconAlertTriangle, IconCornerDownLeft, IconUser, Input } from 'ui'
import { AiIcon, AiIconChat } from './Command.icons'
import { CommandGroup, CommandItem } from './Command.utils'
@@ -336,15 +336,16 @@ export function queryAi(messages: Message[], timeout = 0) {
})
}
-export const AiWarning = () => (
- <div className="mx-4 p-6 flex flex-row items-center gap-2 border rounded-lg text-left text-xs text-scale-1100 border-scale-500 bg-white dark:bg-scale-300">
- <div className="flex flex-row items-center gap-2 text-xs text-amber-900">
- <IconAlertTriangle strokeWidth={1.5} size={18} />
- <strong>Warning</strong>
- </div>{' '}
+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.
- </div>
+ </Alert>
)
const AiCommand = () => {
@@ -375,7 +376,7 @@ const AiCommand = () => {
return (
<div onClick={(e) => e.stopPropagation()}>
- <div className={cn('relative mb-[140px] py-4 max-h-[720px] overflow-auto')}>
+ <div className={cn('relative mb-[145px] py-4 max-h-[720px] overflow-auto')}>
{messages.map((message, index) => {
switch (message.role) {
case MessageRole.User:
@@ -465,11 +466,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 && (
- <div className="mb-4">
- <AiWarning />
- </div>
- )}
+ {messages.length > 0 && !hasError && <AiWarning className="mb-4 mx-4" />}
<Input
className="bg-scale-100 rounded mx-3"
autoFocus
diff --git a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
index ebf4244f9c1..ce9cf4b26ad 100644
--- a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
+++ b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx
@@ -12,6 +12,8 @@ import {
MessageStatus,
useAiChat,
AiWarning,
+ IconAlertCircle,
+ Alert,
} from 'ui'
import { cn } from '../../../utils/cn'
@@ -85,7 +87,7 @@ const GenerateSQL = () => {
<div
className={cn(
'relative py-4 max-h-[550px] overflow-auto',
- allowSendingSchemaMetadata ? 'mb-[255px]' : 'mb-[150px]'
+ allowSendingSchemaMetadata ? 'mb-[265px]' : 'mb-[155px]'
)}
>
{messages.map((message, i) => {
@@ -238,11 +240,7 @@ const GenerateSQL = () => {
</div>
<div className="absolute bottom-0 w-full bg-scale-200 pt-4">
- {messages.length > 0 && !hasError && (
- <div className="mb-4">
- <AiWarning />
- </div>
- )}
+ {messages.length > 0 && !hasError && <AiWarning className="mb-4 mx-4" />}
{allowSendingSchemaMetadata && (
<div className="mb-4">
{messages.length === 0 ? (
@@ -269,18 +267,31 @@ const GenerateSQL = () => {
/>
</div>
) : (
- <div className="mx-4 p-6 flex flex-col items-start gap-2 mt-4 border rounded-lg text-left text-xs text-scale-1100 border-scale-500 bg-white dark:bg-scale-300">
- <p>
- Table names, column names and their corresponding data types{' '}
- <span className={cn(includeSchemaMetadata ? 'text-brand-900' : 'text-amber-900')}>
- {includeSchemaMetadata ? 'are' : 'are not'} included
- </span>{' '}
- in this conversation
- </p>
- <p className="text-scale-1000">
- Start a new conversation to change this configuration
- </p>
- </div>
+ <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>
)}
</div>
)}