Skip to content

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

refine assistant page (#30776)

Saxon Fletcher24630bfb85f0
diff --git a/apps/www/components/AIDemo/Panel.tsx b/apps/www/components/AIDemo/Panel.tsx
index ac6bb818caa..b1f87ad216b 100644
--- a/apps/www/components/AIDemo/Panel.tsx
+++ b/apps/www/components/AIDemo/Panel.tsx
@@ -129,18 +129,6 @@ export const AIDemoPanel = ({ incomingMessages = [] }: { incomingMessages?: Demo
<div className="z-30 border-b border-b-muted flex items-center gap-x-3 px-5 h-[46px]">
<AiIconAnimation loading={false} allowHoverEffect />
<div className="text-sm flex-1">Assistant</div>
- <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
- <Button
- type="default"
- onClick={() => {
- setMessages([])
- setIsComplete(true)
- setPendingMessages([])
- }}
- >
- Reset
- </Button>
- </motion.div>
</div>
{/* Messages */}
diff --git a/apps/www/components/AIDemo/SqlSnippet.tsx b/apps/www/components/AIDemo/SqlSnippet.tsx
index 345ad2e2173..c25c9b6f852 100644
--- a/apps/www/components/AIDemo/SqlSnippet.tsx
+++ b/apps/www/components/AIDemo/SqlSnippet.tsx
@@ -90,7 +90,7 @@ export const SqlSnippet = ({
const ResultsDisplay = () => {
if (resultType === 'chart') {
return (
- <div className="p-5 border-t border-t-muted">
+ <div className="px-0 py-5 border-t border-t-muted">
<ChartContainer config={{}} className="aspect-auto h-[250px] w-full">
<BarChart
data={results}
@@ -121,14 +121,10 @@ export const SqlSnippet = ({
return (
<>
- <div
- className={cn(
- showResults ? 'h-auto max-h-64 overflow-auto border-t border-t-muted' : 'h-0'
- )}
- >
+ <div className={cn(showResults ? 'h-auto max-h-64 overflow-auto border-t' : 'h-0')}>
<table className="w-full m-0 p-0">
<thead>
- <tr className="bg-surface-100">
+ <tr className="bg-surface-100 border-b">
{results?.length > 0 &&
Object.keys(results[0]).map((key) => (
<th key={key} className="p-2 px-5 text-left text-xs font-mono">
diff --git a/apps/www/pages/assistant.tsx b/apps/www/pages/assistant.tsx
index 341964aefd5..9730ba19c55 100644
--- a/apps/www/pages/assistant.tsx
+++ b/apps/www/pages/assistant.tsx
@@ -108,6 +108,67 @@ LIMIT 12;`}
},
],
},
+ {
+ label: 'Latest Products',
+ messages: [
+ {
+ id: '23',
+ role: 'user' as const,
+ content: 'Show me our latest products',
+ createdAt: new Date(),
+ },
+ {
+ id: '24',
+ role: 'assistant' as const,
+ content: 'Here are the 5 most recently added products:',
+ createdAt: new Date(),
+ render: (
+ <SqlSnippet
+ id="latest-products"
+ title="Latest Products"
+ sql={`SELECT
+product_id,
+name,
+price,
+category,
+created_at,
+stock_level
+FROM products
+ORDER BY created_at DESC
+LIMIT 5;`}
+ mockData={{
+ rows: [
+ {
+ product_id: 'PROD-001',
+ name: 'Wireless Earbuds Pro',
+ price: 199.99,
+ category: 'Electronics',
+ created_at: '2024-01-15T16:30:00Z',
+ stock_level: 45,
+ },
+ {
+ product_id: 'PROD-002',
+ name: 'Smart Home Hub',
+ price: 299.99,
+ category: 'Smart Home',
+ created_at: '2024-01-15T15:45:00Z',
+ stock_level: 32,
+ },
+ {
+ product_id: 'PROD-003',
+ name: 'Fitness Tracker Elite',
+ price: 149.99,
+ category: 'Wearables',
+ created_at: '2024-01-15T14:20:00Z',
+ stock_level: 78,
+ },
+ ],
+ }}
+ />
+ ),
+ },
+ ],
+ },
{
label: 'Create Function',
messages: [
@@ -424,55 +485,7 @@ ORDER BY last_login DESC;`}
},
],
},
- {
- label: 'Storage Usage',
- messages: [
- {
- id: '9',
- role: 'user' as const,
- content: 'What is our current storage usage?',
- createdAt: new Date(),
- },
- {
- id: '10',
- role: 'assistant' as const,
- content: 'Here is the storage usage by table:',
- createdAt: new Date(),
- render: (
- <SqlSnippet
- id="storage-usage"
- title="Database Storage Usage"
- sql={`SELECT
-schemaname,
-tablename,
-pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) as total_size
-FROM pg_tables
-WHERE schemaname = 'public'
-ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;`}
- mockData={{
- rows: [
- {
- schemaname: 'public',
- tablename: 'users',
- total_size: '1.2 GB',
- },
- {
- schemaname: 'public',
- tablename: 'orders',
- total_size: '856 MB',
- },
- {
- schemaname: 'public',
- tablename: 'products',
- total_size: '234 MB',
- },
- ],
- }}
- />
- ),
- },
- ],
- },
+
{
label: 'Daily Page Views',
messages: [
@@ -562,54 +575,6 @@ ORDER BY error_count DESC;`}
},
],
},
- {
- label: 'Database Performance',
- messages: [
- {
- id: '1',
- role: 'user' as const,
- content: 'Show me database performance metrics',
- createdAt: new Date(),
- },
- {
- id: '16',
- role: 'assistant' as const,
- content: 'Here are the current database performance metrics:',
- createdAt: new Date(),
- render: (
- <SqlSnippet
- id="db-performance"
- title="Database Performance"
- sql={`SELECT
-datname,
-numbackends,
-xact_commit,
-xact_rollback,
-blks_read,
-blks_hit,
-tup_returned,
-tup_fetched
-FROM pg_stat_database
-WHERE datname = current_database();`}
- mockData={{
- rows: [
- {
- datname: 'production_db',
- numbackends: 50,
- xact_commit: 1500000,
- xact_rollback: 1200,
- blks_read: 25000,
- blks_hit: 980000,
- tup_returned: 15000000,
- tup_fetched: 2500000,
- },
- ],
- }}
- />
- ),
- },
- ],
- },
{
label: 'API Usage Trends',
messages: [