Skip to content

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

chore(studio): refine Explorer sidebar, onboarding, and notebooks (#50555)

Saxon Fletcher252f69e4517e
diff --git a/apps/studio/components/interfaces/Account/Preferences/ExplorerHomePreference.tsx b/apps/studio/components/interfaces/Account/Preferences/ExplorerHomePreference.tsx
deleted file mode 100644
index 4b3c46bc3cc..00000000000
--- a/apps/studio/components/interfaces/Account/Preferences/ExplorerHomePreference.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { RadioGroupCard, RadioGroupCardItem } from 'ui'
-
-import { ExplorerHomePreview } from './ExplorerHomePreview'
-import { explorerHomeSchema, type ExplorerHome } from './useExplorerPreferences'
-
-interface ExplorerHomePreferenceProps {
- value: ExplorerHome
- onValueChange: (value: ExplorerHome) => void
- disabled?: boolean
-}
-
-export const ExplorerHomePreference = ({
- value,
- onValueChange,
- disabled,
-}: ExplorerHomePreferenceProps) => (
- <RadioGroupCard
- aria-label="Choose how Explorer opens"
- value={value}
- onValueChange={(value) => {
- const result = explorerHomeSchema.safeParse(value)
- if (result.success) onValueChange(result.data)
- }}
- disabled={disabled}
- className="grid-cols-1 gap-3 sm:grid-cols-2"
- >
- <RadioGroupCardItem
- value="home"
- className="w-full p-4"
- label={
- <span className="flex flex-col gap-1">
- <span className="text-sm text-foreground">Start page</span>
- <span className="text-sm leading-relaxed text-foreground-light">
- Choose a query, chat, or notebook to get started.
- </span>
- </span>
- }
- >
- <ExplorerHomePreview home="home" />
- </RadioGroupCardItem>
- <RadioGroupCardItem
- value="query"
- className="w-full p-4"
- label={
- <span className="flex flex-col gap-1">
- <span className="text-sm text-foreground">SQL query</span>
- <span className="text-sm leading-relaxed text-foreground-light">
- Open a new query tab, ready to write SQL.
- </span>
- </span>
- }
- >
- <ExplorerHomePreview home="query" />
- </RadioGroupCardItem>
- </RadioGroupCard>
-)
diff --git a/apps/studio/components/interfaces/Account/Preferences/ExplorerHomePreview.tsx b/apps/studio/components/interfaces/Account/Preferences/ExplorerHomePreview.tsx
deleted file mode 100644
index c0407221b93..00000000000
--- a/apps/studio/components/interfaces/Account/Preferences/ExplorerHomePreview.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import type { ExplorerHome } from './useExplorerPreferences'
-
-export const ExplorerHomePreview = ({ home }: { home: ExplorerHome }) => (
- <svg
- viewBox="0 0 240 128"
- fill="none"
- aria-hidden="true"
- className="mb-2 w-full rounded border border-default bg-surface-100 stroke-border"
- >
- <path d="M0 0h48v128H0z" className="fill-muted stroke-none" />
- <path d="M48 0v128" />
- <g className="fill-foreground-muted/40 stroke-none">
- <rect x="8" y="15" width="30" height="4" rx="1" />
- <rect x="8" y="32" width="26" height="3" rx="1" />
- <rect x="8" y="44" width="20" height="3" rx="1" />
- <rect x="8" y="56" width="24" height="3" rx="1" />
- </g>
-
- {home === 'home' ? (
- <>
- <rect x="88" y="48" width="112" height="22" rx="3" />
- <rect x="88" y="78" width="52" height="17" rx="2" />
- <rect x="148" y="78" width="52" height="17" rx="2" />
- <g className="fill-foreground-muted/40 stroke-none">
- <rect x="112" y="35" width="64" height="4" rx="1" />
- <rect x="96" y="57" width="58" height="3" rx="1" />
- <rect x="96" y="85" width="32" height="3" rx="1" />
- <rect x="156" y="85" width="32" height="3" rx="1" />
- </g>
- </>
- ) : (
- <>
- <path d="M48 65h192" />
- <g className="fill-foreground-muted/40 stroke-none">
- <rect x="62" y="18" width="30" height="3" rx="1" />
- <rect x="98" y="18" width="18" height="3" rx="1" />
- <rect x="70" y="28" width="52" height="3" rx="1" />
- <rect x="62" y="38" width="22" height="3" rx="1" />
- <rect x="90" y="38" width="40" height="3" rx="1" />
- </g>
- <rect x="58" y="77" width="172" height="12" className="fill-muted stroke-none" />
- <rect x="58" y="77" width="172" height="36" rx="2" />
- <path d="M58 89h172M58 101h172M105 77v36M168 77v36" />
- </>
- )}
- </svg>
-)
diff --git a/apps/studio/components/interfaces/Explorer/AddCellDropdown.tsx b/apps/studio/components/interfaces/Explorer/AddCellDropdown.tsx
index f63f2b83a5d..90cdff05034 100644
--- a/apps/studio/components/interfaces/Explorer/AddCellDropdown.tsx
+++ b/apps/studio/components/interfaces/Explorer/AddCellDropdown.tsx
@@ -35,11 +35,11 @@ export const AddCellDropdown = ({ cellId }: AddCellDropdownProps) => {
<DropdownMenuContent align="start" className="w-40">
<DropdownMenuItem className="gap-x-2" onClick={() => onSelectAddCell('query')}>
<SquareCode size={14} />
- <span>Add query cell</span>
+ <span>Add query</span>
</DropdownMenuItem>
<DropdownMenuItem className="gap-x-2" onClick={() => onSelectAddCell('markdown')}>
<FileText size={14} />
- <span>Add markdown cell</span>
+ <span>Add markdown</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx
index c1b24419ba2..7e8b92fb198 100644
--- a/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx
+++ b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx
@@ -477,8 +477,8 @@ export const ExplorerNotebookTab = () => {
contentClassName="[&>h3]:text-sm [&>p]:text-xs"
>
<div className="flex items-center gap-x-2">
- <Button onClick={() => onSelectAddCell('query')}>Add query cell</Button>
- <Button onClick={() => onSelectAddCell('markdown')}>Add markdown cell</Button>
+ <Button onClick={() => onSelectAddCell('query')}>Add query</Button>
+ <Button onClick={() => onSelectAddCell('markdown')}>Add markdown</Button>
</div>
</EmptyStatePresentational>
)}
@@ -513,17 +513,19 @@ export const ExplorerNotebookTab = () => {
<div className="flex items-center justify-center gap-x-2 mt-4">
<ButtonTooltip
variant="outline"
+ size="small"
icon={<SquareCode />}
- className="w-7"
+ className="w-[34px]"
onClick={() => onSelectAddCell('query')}
- tooltip={{ content: { side: 'bottom', text: 'Add query cell' } }}
+ tooltip={{ content: { side: 'bottom', text: 'Add query' } }}
/>
<ButtonTooltip
variant="outline"
+ size="small"
icon={<FileText />}
- className="w-7"
+ className="w-[34px]"
onClick={() => onSelectAddCell('markdown')}
- tooltip={{ content: { side: 'bottom', text: 'Add markdown cell' } }}
+ tooltip={{ content: { side: 'bottom', text: 'Add markdown' } }}
/>
</div>
</>
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerOnboarding.tsx b/apps/studio/components/interfaces/Explorer/ExplorerOnboarding.tsx
index ed370257255..ec3ac3c42e1 100644
--- a/apps/studio/components/interfaces/Explorer/ExplorerOnboarding.tsx
+++ b/apps/studio/components/interfaces/Explorer/ExplorerOnboarding.tsx
@@ -1,33 +1,121 @@
-import { Button } from 'ui'
+import { ArrowRight } from 'lucide-react'
+import { useState, type ComponentType } from 'react'
+import { Badge, Button, cn } from 'ui'
-import { ExplorerOnboardingLearnMore } from './ExplorerOnboardingLearnMore'
-import { ExplorerHomePreference } from '@/components/interfaces/Account/Preferences/ExplorerHomePreference'
+import {
+ ChatWireframe,
+ NotebooksWireframe,
+ RunSqlWireframe,
+ WelcomeWireframe,
+} from './ExplorerOnboardingWireframes'
import { useExplorerPreferences } from '@/components/interfaces/Account/Preferences/useExplorerPreferences'
+const ONBOARDING_STEPS: Array<{
+ Wireframe: ComponentType
+ title: string
+ description: string
+ isPreview?: boolean
+}> = [
+ {
+ Wireframe: WelcomeWireframe,
+ title: 'Welcome to Explorer',
+ description:
+ 'Interact with your database and logs in one place. Run SQL, save your work to notebooks, and chat with Assistant.',
+ isPreview: true,
+ },
+ {
+ Wireframe: RunSqlWireframe,
+ title: 'Run SQL',
+ description:
+ 'Run any SQL on your database, just like in the SQL Editor. You can also query your logs and chart the results.',
+ },
+ {
+ Wireframe: NotebooksWireframe,
+ title: 'Notebooks',
+ description:
+ 'Snippets have evolved into notebooks. Combine multiple queries with markdown notes for you, your team, or Assistant to run later.',
+ },
+ {
+ Wireframe: ChatWireframe,
+ title: 'Chat with your project',
+ description:
+ 'Ask Assistant to write queries, explain results, or build notebooks for you. Your organization’s AI settings control what it can access.',
+ },
+]
+
export const ExplorerOnboarding = () => {
- const { home, setHome, completeOnboarding, isReady } = useExplorerPreferences()
+ const { completeOnboarding, isReady } = useExplorerPreferences()
+ const [stepIndex, setStepIndex] = useState(0)
+
+ const step = ONBOARDING_STEPS[stepIndex]
+ const isFirstStep = stepIndex === 0
+ const isLastStep = stepIndex === ONBOARDING_STEPS.length - 1
+ const { Wireframe } = step
return (
<div className="flex h-full min-h-0 flex-col items-center overflow-y-auto bg-surface-100 px-6">
<div className="my-auto w-full max-w-xl shrink-0 space-y-8 py-12">
- <div className="space-y-3">
- <h1 className="heading-section">Welcome to Explorer</h1>
- <p className="text-sm leading-relaxed text-foreground-light">
- Interact with your database and logs in one place. Run SQL, chat with Assistant, or
- combine queries and notes in notebooks.
- </p>
+ <div aria-live="polite" className="space-y-6">
+ <Wireframe />
+ <div className="min-h-24 space-y-2">
+ <div className="flex items-center gap-2">
+ <h1 className="heading-section">{step.title}</h1>
+ {step.isPreview && <Badge variant="default">Preview</Badge>}
+ </div>
+ <p className="text-base leading-relaxed text-foreground-light">{step.description}</p>
+ </div>
</div>
- <div className="space-y-3">
- <h2 className="text-sm font-medium">Choose how Explorer opens</h2>
- <ExplorerHomePreference value={home} onValueChange={setHome} disabled={!isReady} />
- </div>
+ <div className="flex items-center justify-between gap-4">
+ <div className="flex items-center gap-1.5">
+ <span className="sr-only">
+ Step {stepIndex + 1} of {ONBOARDING_STEPS.length}
+ </span>
+ {ONBOARDING_STEPS.map(({ title }, index) => (
+ <span
+ key={title}
+ aria-hidden="true"
+ className={cn(
+ 'h-1.5 rounded-full transition-all',
+ index === stepIndex ? 'w-4 bg-foreground' : 'w-1.5 bg-border-stronger'
+ )}
+ />
+ ))}
+ </div>
- <ExplorerOnboardingLearnMore />
-
- <Button variant="primary" onClick={completeOnboarding} disabled={!isReady}>
- Open Explorer
- </Button>
+ <div className="flex items-center gap-2">
+ {!isLastStep && (
+ <Button type="button" variant="text" onClick={completeOnboarding} disabled={!isReady}>
+ Skip
+ </Button>
+ )}
+ {!isFirstStep && (
+ <Button type="button" variant="default" onClick={() => setStepIndex(stepIndex - 1)}>
+ Back
+ </Button>
+ )}
+ {isLastStep ? (
+ <Button
+ type="button"
+ variant="primary"
+ iconRight={<ArrowRight />}
+ onClick={completeOnboarding}
+ disabled={!isReady}
+ >
+ Continue to Explorer
+ </Button>
+ ) : (
+ <Button
+ type="button"
+ variant="primary"
+ iconRight={<ArrowRight />}
+ onClick={() => setStepIndex(stepIndex + 1)}
+ >
+ Next
+ </Button>
+ )}
+ </div>
+ </div>
</div>
</div>
)
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerOnboardingLearnMore.tsx b/apps/studio/components/interfaces/Explorer/ExplorerOnboardingLearnMore.tsx
deleted file mode 100644
index dd1b616b616..00000000000
--- a/apps/studio/components/interfaces/Explorer/ExplorerOnboardingLearnMore.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Card, CardContent } from 'ui'
-import { CollapsibleCardSection } from 'ui-patterns/CollapsibleCardSection'
-
-export const ExplorerOnboardingLearnMore = () => (
- <Card>
- <CardContent>
- <CollapsibleCardSection title="Learn more">
- <dl className="space-y-5 pt-2 text-sm">
- <div className="space-y-1">
- <dt className="font-medium">Where did my snippets go?</dt>
- <dd className="leading-relaxed text-foreground-light">
- Notebooks are intended to replace snippets over time. Your saved snippets are still
- accessible by switching back to the SQL Editor.
- </dd>
- </div>
- <div className="space-y-1">
- <dt className="font-medium">Do notebooks replace custom reports?</dt>
- <dd className="leading-relaxed text-foreground-light">
- Notebooks are intended to replace custom reports over time. Your custom reports are
- still accessible under Observability.
- </dd>
- </div>
- <div className="space-y-1">
- <dt className="font-medium">Who can see my notebooks?</dt>
- <dd className="leading-relaxed text-foreground-light">
- Notebooks are shared with everyone on your team by default.
- </dd>
- </div>
- <div className="space-y-1">
- <dt className="font-medium">Can AI see my data?</dt>
- <dd className="leading-relaxed text-foreground-light">
- Your organization’s AI settings control whether Assistant can access schema, logs, and
- query results.
- </dd>
- </div>
- </dl>
- </CollapsibleCardSection>
- </CardContent>
- </Card>
-)
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerOnboardingWireframes.tsx b/apps/studio/components/interfaces/Explorer/ExplorerOnboardingWireframes.tsx
new file mode 100644
index 00000000000..08bfa0b4339
--- /dev/null
+++ b/apps/studio/components/interfaces/Explorer/ExplorerOnboardingWireframes.tsx
@@ -0,0 +1,347 @@
+import {
+ ArrowUp,
+ ChevronLeft,
+ ChevronRight,
+ Home,
+ MessageSquare,
+ NotebookText,
+ Play,
+ Plus,
+ SquareCode,
+ type LucideIcon,
+} from 'lucide-react'
+import type { ReactNode } from 'react'
+import { cn } from 'ui'
+
+type Section = 'home' | 'query' | 'notebook' | 'chat'
+
+const Line = ({ className }: { className?: string }) => (
+ <div className={cn('h-1 shrink-0 rounded-[2px] bg-border-stronger', className)} />
+)
+
+const Icon = ({ icon: IconComponent, className }: { icon: LucideIcon; className?: string }) => (
+ <IconComponent size={10} strokeWidth={1.5} className={cn('shrink-0', className)} />
+)
+
+const SidebarRow = ({
+ icon,
+ isActive = false,
+ trailing,
+ lineClassName = 'w-10',
+}: {
+ icon: LucideIcon
+ isActive?: boolean
+ trailing?: ReactNode
+ lineClassName?: string
+}) => (
+ <div
+ className={cn(
+ 'flex h-5 items-center gap-1.5 rounded-sm px-1.5',
+ isActive ? 'bg-surface-300 text-foreground' : 'text-foreground-muted'
+ )}
+ >
+ <Icon icon={icon} />
+ <Line className={cn(lineClassName, isActive && 'bg-foreground-muted')} />
+ <div className="ml-auto flex items-center gap-1">{trailing}</div>
+ </div>
+)
+
+const Count = () => <div className="h-1.5 w-1.5 rounded-full bg-border-stronger" />
+
+const SidebarHome = ({ section }: { section: Section }) => (
+ <>
+ <div className="space-y-px">
+ <SidebarRow
+ icon={SquareCode}
+ isActive={section === 'query'}
+ trailing={<Icon icon={Plus} />}
+ lineClassName="w-9"
+ />
+ <SidebarRow
+ icon={NotebookText}
+ trailing={
+ <>
+ <Count />
+ <Icon icon={ChevronRight} />
+ </>
+ }
+ lineClassName="w-12"
+ />
+ <SidebarRow
+ icon={MessageSquare}
+ isActive={section === 'chat'}
+ trailing={
+ <>
+ <Count />
+ <Icon icon={ChevronRight} />
+ </>
+ }
+ lineClassName="w-8"
+ />
+ </div>
+ <div className="space-y-px">
+ <Line className="mx-1.5 mb-2 w-14 bg-foreground-muted/50" />
+ <SidebarRow icon={NotebookText} lineClassName="w-14" />
+ <SidebarRow icon={MessageSquare} isActive={section === 'chat'} lineClassName="w-12" />
+ <SidebarRow icon={NotebookText} lineClassName="w-10" />
+ <SidebarRow icon={MessageSquare} lineClassName="w-14" />
+ </div>
+ </>
+)
+
+const SidebarNotebooks = () => (
+ <>
+ <div className="flex h-5 items-center rounded-sm border bg-surface-200 px-1.5">
+ <Line className="w-12" />
+ </div>
+ <div className="space-y-px">
+ <SidebarRow icon={NotebookText} isActive lineClassName="w-14" />
+ <SidebarRow icon={NotebookText} lineClassName="w-10" />
+ <SidebarRow icon={NotebookText} lineClassName="w-16" />
+ <SidebarRow icon={NotebookText} lineClassName="w-12" />
+ <SidebarRow icon={NotebookText} lineClassName="w-9" />
+ </div>
+ </>
+)
+
+const Sidebar = ({ section }: { section: Section }) => (
+ <div className="flex w-[24%] shrink-0 flex-col border-r">
+ <div className="flex h-7 shrink-0 items-center gap-1 border-b px-2.5 text-foreground-muted">
+ {section === 'notebook' && <Icon icon={ChevronLeft} />}
+ <Line className={cn('bg-foreground-muted', section === 'notebook' ? 'w-12' : 'w-10')} />
+ <div className="ml-auto flex h-3.5 w-3.5 items-center justify-center rounded-sm border">
+ <Icon icon={Plus} className="size-2" />
+ </div>
+ </div>
+ <div className="flex flex-col gap-3 p-1.5">
+ {section === 'notebook' ? <SidebarNotebooks /> : <SidebarHome section={section} />}
+ </div>
+ </div>
+)
+
+const TAB_ICONS: Record<Exclude<Section, 'home'>, LucideIcon> = {
+ query: SquareCode,
+ notebook: NotebookText,
+ chat: MessageSquare,
+}
+
+const Tab = ({ icon, isActive = false }: { icon: LucideIcon; isActive?: boolean }) => (
+ <div
+ className={cn(
+ 'flex h-full items-center gap-1.5 border-r px-2.5',
+ isActive ? 'bg-surface-200 text-foreground' : 'text-foreground-muted'
+ )}
+ >
+ <Icon icon={icon} />
+ <Line className={cn('w-8', isActive && 'bg-foreground-muted')} />
+ </div>
+)
+
+const TabBar = ({ section }: { section: Section }) => (
+ <div className="flex h-7 shrink-0 items-stretch border-b">
+ <div
+ className={cn(
+ 'flex items-center border-r px-2.5',
+ section === 'home' ? 'bg-surface-200 text-foreground' : 'text-foreground-muted'
+ )}
+ >
+ <Icon icon={Home} />
+ </div>
+ {section !== 'home' && <Tab icon={TAB_ICONS[section]} isActive />}
+ <Tab icon={section === 'notebook' ? SquareCode : NotebookText} />
+ <div className="flex items-center px-2 text-foreground-muted">
+ <Icon icon={Plus} />
+ </div>
+ </div>
+)
+
+const ExplorerFrame = ({ section, children }: { section: Section; children: ReactNode }) => (
+ <div
+ aria-hidden="true"
+ className="flex aspect-video w-full overflow-hidden rounded-md border bg-muted shadow-sm"
+ >
+ <Sidebar section={section} />
+ <div className="flex min-w-0 flex-1 flex-col">
+ <TabBar section={section} />
+ <div className="relative min-h-0 flex-1 overflow-hidden">{children}</div>
+ </div>
+ </div>
+)
+
+const SqlLines = ({ rows = 3 }: { rows?: number }) => {
+ const widths = [
+ ['w-6', 'w-14'],
+ ['w-5', 'w-10'],
+ ['w-6', 'w-16'],
+ ['w-4', 'w-8'],
+ ]
+
+ return (
+ <div className="space-y-1.5">
+ {widths.slice(0, rows).map(([keyword, rest], index) => (
+ <div key={index} className="flex items-center gap-1.5">
+ <span className="w-2 text-right font-mono text-[6px] leading-none text-foreground-muted">
+ {index + 1}
+ </span>
+ <Line className={cn(keyword, 'bg-foreground-muted')} />
+ <Line className={rest} />
+ </div>
+ ))}
+ </div>
+ )
+}
+
+const ResultsGrid = ({ rows = 3, className }: { rows?: number; className?: string }) => (
+ <div className={cn('divide-y overflow-hidden rounded-sm border', className)}>
+ {Array.from({ length: rows + 1 }).map((_, row) => (
+ <div key={row} className="grid grid-cols-4 gap-2 px-2 py-1.5">
+ {Array.from({ length: 4 }).map((_, col) => (
+ <Line key={col} className={cn(row === 0 ? 'w-3/4 bg-foreground-muted' : 'w-1/2')} />
+ ))}
+ </div>
+ ))}
+ </div>
+)
+
+const BarChart = ({ className }: { className?: string }) => (
+ <div className={cn('flex items-end gap-1 rounded-sm border p-2', className)}>
+ {[35, 55, 45, 70, 60, 85, 75, 95].map((height, index) => (
+ <div
+ key={index}
+ className="flex-1 rounded-t-[1px] bg-border-stronger"
+ style={{ height: `${height}%` }}
+ />
+ ))}
+ </div>
+)
+
+const RunButton = () => (
+ <div className="flex h-4 items-center gap-1 rounded-sm border bg-surface-300 px-1.5 text-foreground-muted">
+ <Icon icon={Play} className="size-2 fill-current" />
+ <div className="h-0.5 w-4 rounded-[2px] bg-foreground-muted" />
+ </div>
+)
+
+const HomeContent = () => (
+ <div className="flex h-full flex-col items-center justify-center gap-3 px-8">
+ <Line className="w-2/3 bg-foreground-muted" />
+ <div className="w-full space-y-3 rounded-md border bg-surface-200 p-2">
+ <Line className="w-1/2" />
+ <div className="flex justify-end">
+ <div className="flex h-3.5 w-3.5 items-center justify-center rounded-full bg-foreground-muted text-background">
+ <Icon icon={ArrowUp} className="size-2" />
+ </div>
+ </div>
+ </div>
+ <div className="grid w-full grid-cols-2 gap-2">
+ {[SquareCode, NotebookText].map((icon, index) => (
+ <div key={index} className="flex items-center gap-1.5 rounded-md border bg-surface-200 p-2">
+ <div className="flex h-4 w-4 items-center justify-center rounded-sm border bg-surface-300 text-foreground-muted">
+ <Icon icon={icon} className="size-2" />
+ </div>
+ <div className="space-y-1">
+ <Line className="w-10 bg-foreground-muted" />
+ <Line className="w-14" />
+ </div>
+ </div>
+ ))}
+ </div>
+ <div className="w-full space-y-1.5">
+ <Line className="w-12" />
+ <div className="grid grid-cols-3 gap-2">
+ {Array.from({ length: 3 }).map((_, index) => (
+ <div key={index} className="h-6 rounded-md border bg-surface-200" />
+ ))}
+ </div>
+ </div>
+ </div>
+)
+
+const QueryContent = () => (
+ <div className="flex h-full flex-col">
+ <div className="flex h-6 shrink-0 items-center justify-between border-b px-2">
+ <Line className="w-10" />
+ <RunButton />
+ </div>
+ <div className="flex-1 p-2">
+ <SqlLines rows={4} />
+ </div>
+ <ResultsGrid rows={5} className="h-1/2 shrink-0 rounded-none border-x-0 border-b-0" />
+ </div>
+)
+
+const MarkdownCell = ({ lines }: { lines: string[] }) => (
+ <div className="space-y-1.5 px-1">
+ <Line className="w-1/4 bg-foreground-muted" />
+ {lines.map((width, index) => (
+ <Line key={index} className={width} />
+ ))}
+ </div>
+)
+
+const NotebookContent = () => (
+ <div className="h-full overflow-hidden px-6 pb-3 pt-6">
+ <div className="space-y-2.5">
+ <MarkdownCell lines={['w-5/6', 'w-2/3']} />
+ <BarChart className="h-16" />
+ <div className="flex items-center gap-1.5 text-foreground-muted">
+ <div className="h-px flex-1 bg-border" />
+ <Icon icon={Plus} />
+ <div className="h-px flex-1 bg-border" />
+ </div>
+ <MarkdownCell lines={['w-3/4']} />
+ <BarChart className="h-16" />
+ </div>
+ </div>
+)
+
+const ChatContent = () => (
+ <div className="flex h-full flex-col px-6 py-3">
+ <div className="flex flex-1 flex-col gap-2.5 overflow-hidden">
+ <div className="ml-auto w-1/2 space-y-1.5 rounded-md border bg-surface-300 p-2">
+ <Line className="w-full" />
+ <Line className="w-2/3" />
+ </div>
+ <div className="w-5/6 space-y-2">
+ <div className="space-y-1.5">
+ <Line className="w-full" />
+ <Line className="w-4/5" />
+ </div>
+ <BarChart className="h-16" />
+ <Line className="w-2/3" />
+ </div>
+ </div>
+ <div className="flex shrink-0 items-center justify-between rounded-md border bg-surface-200 py-1.5 pl-2 pr-1.5">
+ <span className="text-[8px] leading-none text-foreground-muted">
+ Ask a follow up question...
+ </span>
+ <div className="flex h-3.5 w-3.5 items-center justify-center rounded-full bg-foreground-muted text-background">
+ <Icon icon={ArrowUp} className="size-2" />
+ </div>
+ </div>
+ </div>
+)
+
+export const WelcomeWireframe = () => (
+ <ExplorerFrame section="home">
+ <HomeContent />
+ </ExplorerFrame>
+)
+
+export const RunSqlWireframe = () => (
+ <ExplorerFrame section="query">
+ <QueryContent />
+ </ExplorerFrame>
+)
+
+export const NotebooksWireframe = () => (
+ <ExplorerFrame section="notebook">
+ <NotebookContent />
+ </ExplorerFrame>
+)
+
+export const ChatWireframe = () => (
+ <ExplorerFrame section="chat">
+ <ChatContent />
+ </ExplorerFrame>
+)
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerQueryTab.tsx b/apps/studio/components/interfaces/Explorer/ExplorerQueryTab.tsx
index fd187c0c57e..f855c9d7d7c 100644
--- a/apps/studio/components/interfaces/Explorer/ExplorerQueryTab.tsx
+++ b/apps/studio/components/interfaces/Explorer/ExplorerQueryTab.tsx
@@ -166,7 +166,10 @@ export const ExplorerQueryTab = () => {
}}
toolbarActions={
<>
- <SaveQueryDropdown query={{ title: draft.name, sql: draft.uncheckedSql }} />
+ <SaveQueryDropdown
+ query={{ title: draft.name, sql: draft.uncheckedSql }}
+ source={toQuerySourceBinding(draft)}
+ />
<DropdownMenu>
<DropdownMenuTrigger asChild>
<ExplorerToolbarAction icon={<MoreVertical size={16} strokeWidth={2} />} />
diff --git a/apps/studio/components/interfaces/Explorer/QueryCell/index.tsx b/apps/studio/components/interfaces/Explorer/QueryCell/index.tsx
index 6588f486c3d..a152e3a9262 100644
--- a/apps/studio/components/interfaces/Explorer/QueryCell/index.tsx
+++ b/apps/studio/components/interfaces/Explorer/QueryCell/index.tsx
@@ -110,7 +110,7 @@ export const QueryCell = forwardRef<QueryEditorHandle, QueryCellProps>(function
return (
<SortableSection
id={cell._id}
- sectionWidth="72rem"
+ sectionWidth="48rem"
actions={<AddCellDropdown cellId={cell._id} />}
gripDropdownContent={<MoveCellDropdownContent cellId={cell._id} />}
gripClassName="mt-2 sm:opacity-0 group-hover:opacity-100 has-[[data-state=open]]:opacity-100 transition"
diff --git a/apps/studio/components/interfaces/Explorer/SaveQueryDropdown.tsx b/apps/studio/components/interfaces/Explorer/SaveQueryDropdown.tsx
index 3c04204dc93..22395f2a943 100644
--- a/apps/studio/components/interfaces/Explorer/SaveQueryDropdown.tsx
+++ b/apps/studio/components/interfaces/Explorer/SaveQueryDropdown.tsx
@@ -22,18 +22,22 @@ import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { ExplorerToolbarAction } from './ExplorerToolbar'
import { useCreateNotebook } from './hooks'
-import { createQueryCellSkeleton } from './utils'
+import { createLogCellSkeleton, createQueryCellSkeleton } from './utils'
import { getNotebook } from '@/data/content/notebooks/notebook-query'
import { useNotebooksInfiniteQuery } from '@/data/content/notebooks/notebooks-infinite-query'
+import { type QuerySourceBinding } from '@/data/query-sources/query-source-registry'
import { useNotebooksStateSnapshot } from '@/state/notebooks/notebooks-state'
interface SaveQueryDropdownProps {
query: { title: string; sql: string }
+ /** Saves as a log cell when the query targets logs. Defaults to a database cell. */
+ source?: QuerySourceBinding
}
export const SaveQueryDropdown = ({
children,
query,
+ source,
}: PropsWithChildren<SaveQueryDropdownProps>) => {
const router = useRouter()
const { ref } = useParams()
@@ -53,9 +57,14 @@ export const SaveQueryDropdown = ({
return items
}, [notebooksData?.pages])
+ const createCell = () =>
+ source?._tag === 'logs'
+ ? createLogCellSkeleton({ ...query, time_range: source.time_range })
+ : createQueryCellSkeleton(query)
+
const onAddToNewNotebook = () => {
createNotebook({
- cells: [createQueryCellSkeleton(query)],
+ cells: [createCell()],
})
}
@@ -69,7 +78,7 @@ export const SaveQueryDropdown = ({
notebooksSnap.insertCellAfter({
id: notebookId,
- cell: createQueryCellSkeleton(query),
+ cell: createCell(),
})
notebooksSnap.requestScrollToBottom(notebookId)
diff --git a/apps/studio/components/interfaces/Explorer/__tests__/ExplorerHomeTab.test.tsx b/apps/studio/components/interfaces/Explorer/__tests__/ExplorerHomeTab.test.tsx
index 5bf942fbdb1..77ae31debef 100644
--- a/apps/studio/components/interfaces/Explorer/__tests__/ExplorerHomeTab.test.tsx
+++ b/apps/studio/components/interfaces/Explorer/__tests__/ExplorerHomeTab.test.tsx
@@ -54,12 +54,23 @@ beforeEach(() => {
afterEach(() => localStorage.clear())
describe('Explorer home onboarding', () => {
- it('lets the user complete onboarding with the start page and does not show it on return', async () => {
+ it('steps through onboarding, completes it with the start page, and does not show it on return', async () => {
const user = userEvent.setup()
const first = renderHome()
expect(await screen.findByRole('heading', { name: 'Welcome to Explorer' })).toBeVisible()
- expect(screen.getByRole('radio', { name: /^Start page/ })).toBeChecked()
- await user.click(screen.getByRole('button', { name: 'Open Explorer' }))
+ expect(screen.getByText('Step 1 of 4')).toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: 'Back' })).not.toBeInTheDocument()
+
+ for (const name of ['Run SQL', 'Notebooks', 'Chat with your project']) {
+ await user.click(screen.getByRole('button', { name: 'Next' }))
+ expect(screen.getByRole('heading', { name })).toBeVisible()
+ }
+ expect(screen.getByText('Step 4 of 4')).toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: 'Next' })).not.toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: 'Skip' })).not.toBeInTheDocument()
+ expect(screen.queryByRole('radio')).not.toBeInTheDocument()
+
+ await user.click(screen.getByRole('button', { name: 'Continue to Explorer' }))
expect(await screen.findByLabelText('Start page chat')).toBeInTheDocument()
first.unmount()
@@ -69,26 +80,23 @@ describe('Explorer home onboarding', () => {
expect(createQuery).not.toHaveBeenCalled()
})
- it('supports keyboard selection and waits for completion before opening a query', async () => {
+ it('goes back to the previous step', async () => {
const user = userEvent.setup()
renderHome()
- const startPage = await screen.findByRole('radio', { name: /^Start page/ })
- await user.click(startPage)
- // Radix defers moving focus; keep the key down until that focus event selects the radio.
- await user.keyboard('{ArrowRight>}')
- await waitFor(() => expect(screen.getByRole('radio', { name: /^SQL query/ })).toBeChecked())
- await user.keyboard('{/ArrowRight}')
- expect(createQuery).not.toHaveBeenCalled()
- await user.click(screen.getByRole('button', { name: 'Open Explorer' }))
- await waitFor(() => expect(createQuery).toHaveBeenCalledExactlyOnceWith({ replace: true }))
+ await screen.findByRole('heading', { name: 'Welcome to Explorer' })
+ await user.click(screen.getByRole('button', { name: 'Next' }))
+ await user.click(screen.getByRole('button', { name: 'Back' }))
+ expect(screen.getByRole('heading', { name: 'Welcome to Explorer' })).toBeVisible()
})
- it('shows onboarding for an unfinished query preference', async () => {
+ it('opens a query when onboarding is skipped and the saved preference is a query', async () => {
+ const user = userEvent.setup()
seedPreferences('query', false)
renderHome()
expect(await screen.findByRole('heading', { name: 'Welcome to Explorer' })).toBeVisible()
- expect(screen.getByRole('radio', { name: /^SQL query/ })).toBeChecked()
expect(createQuery).not.toHaveBeenCalled()
+ await user.click(screen.getByRole('button', { name: 'Skip' }))
+ await waitFor(() => expect(createQuery).toHaveBeenCalledExactlyOnceWith({ replace: true }))
})
it('opens one query for a returning user, even under Strict Mode', async () => {
@@ -115,16 +123,4 @@ describe('Explorer home onboarding', () => {
await waitFor(() => expect(createQuery).toHaveBeenCalledExactlyOnceWith({ replace: true }))
}
)
-
- it('keeps Learn more collapsed initially and supports expanding and collapsing with the keyboard', async () => {
- const user = userEvent.setup()
- renderHome()
- const trigger = await screen.findByRole('button', { name: 'Learn more' })
- expect(trigger).toHaveAttribute('aria-expanded', 'false')
- expect(screen.queryByText('Where did my snippets go?')).not.toBeInTheDocument()
- await user.click(trigger)
- expect(screen.getByText('Where did my snippets go?')).toBeVisible()
- await user.keyboard('{Enter}')
- expect(trigger).toHaveAttribute('aria-expanded', 'false')
- })
})
diff --git a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
index 4b969b9f64b..ba8b4789867 100644
--- a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
+++ b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
@@ -1,6 +1,6 @@
import { useParams } from 'common'
import { motion } from 'framer-motion'
-import { ChevronRight } from 'lucide-react'
+import { ChevronRight, Plus, SquareCode } from 'lucide-react'
import Link from 'next/link'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
@@ -12,7 +12,7 @@ import {
rowClassName,
} from './ExplorerLayout.constants'
import { formatRelativeTimeShort, getRecentlyUpdatedItems } from './ExplorerNavHome.utils'
-import { useCreateChat } from '@/components/interfaces/Explorer/hooks'
+import { useCreateChat, useCreateQuery } from '@/components/interfaces/Explorer/hooks'
import { useContentCountQuery } from '@/data/content/content-count-query'
import { useNotebooksInfiniteQuery } from '@/data/content/notebooks/notebooks-infinite-query'
import { useAiAssistantChatList } from '@/state/ai-assistant-state'
@@ -24,6 +24,7 @@ export const ExplorerNavHome = ({
}) => {
const { ref } = useParams()
const { openChat } = useCreateChat()
+ const { createQuery } = useCreateQuery()
const { data: notebooksData } = useNotebooksInfiniteQuery({ projectRef: ref, limit: 100 })
const notebooks = notebooksData?.pages.flatMap((page) => page.content) ?? []
@@ -50,6 +51,16 @@ export const ExplorerNavHome = ({
className="absolute inset-0 flex flex-col gap-4 overflow-y-auto p-3"
>
<nav className="flex flex-col gap-px">
+ <button
+ type="button"
+ tabIndex={0}
+ className={rowClassName(false)}
+ onClick={() => createQuery()}
+ >
+ <SquareCode size={14} className="shrink-0" />
+ <span className="flex-1 text-left">Run SQL</span>
+ <Plus size={14} className="shrink-0 text-foreground-muted" />
+ </button>
{EXPLORER_SECTIONS.map(({ type, label, icon: Icon }) => {
return (
<button
diff --git a/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx b/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx
index 44e847305ce..1cb22012512 100644
--- a/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx
@@ -12,7 +12,9 @@ import {
} from './AssistantQueryCell.utils'
import { Confirm } from './Confirm'
import { type ConfirmFooterApprovalState } from './Confirm.utils'
+import { useIsExplorerEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { QueryEditor } from '@/components/interfaces/Explorer/QueryEditor'
+import { SaveQueryDropdown } from '@/components/interfaces/Explorer/SaveQueryDropdown'
import { type QueryDisplay, type QueryResult } from '@/components/interfaces/Explorer/types'
import {
type QuerySourceBinding,
@@ -74,6 +76,7 @@ export const AssistantQueryCell = ({
const track = useTrack()
const roleImpersonationState = useLocalRoleImpersonationState()
const aiAssistantState = useAiAssistantState()
+ const isExplorerEnabled = useIsExplorerEnabled()
const fallbackTitle =
initialTitle?.trim() ||
@@ -185,6 +188,11 @@ export const AssistantQueryCell = ({
onDisplayChange={handleDisplayChange}
onRun={handleRun}
onDebug={aiAssistantState.setInitialInput}
+ toolbarActions={
+ isExplorerEnabled && !isStreaming ? (
+ <SaveQueryDropdown query={{ title, sql: query.uncheckedSql }} source={query} />
+ ) : undefined
+ }
/>
</Confirm>
)
diff --git a/apps/studio/components/ui/AIAssistantPanel/Message.Parts.tsx b/apps/studio/components/ui/AIAssistantPanel/Message.Parts.tsx
index d54b2a1b23e..8c3d255bab6 100644
--- a/apps/studio/components/ui/AIAssistantPanel/Message.Parts.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/Message.Parts.tsx
@@ -235,12 +235,7 @@ function MessagePartNotebookProposal({
const { addToolApprovalResponse } = useMessageActionsContext()
if (state === 'input-streaming') {
- return (
- <div className="my-4 mx-4 rounded-lg border bg-surface-75 heading-meta h-9 px-3 text-foreground-light flex items-center gap-2">
- <Loader2 className="w-4 h-4 animate-spin" />
- {NOTEBOOK_DRAFTING_LABEL[mode]}
- </div>
- )
+ return <ToolDisplayExecuteSqlLoading label={NOTEBOOK_DRAFTING_LABEL[mode]} />
}
const { confirmState, onApprove, onDeny, denyWithReason } = getManualToolApprovalHandlers({
@@ -324,6 +319,7 @@ const isWideMessagePart = (part: NonNullable<VercelMessage['parts']>[number]) =>
part.type === 'tool-query_logs' ||
part.type === 'tool-create_notebook' ||
part.type === 'tool-update_notebook' ||
+ part.type === 'tool-delete_notebook' ||
part.type === 'tool-run_notebook' ||
(part.type === 'dynamic-tool' && part.toolName === 'query_logs') ||
// Unlabelled code fences resolve to SQL in MessageMarkdown, too.
diff --git a/apps/studio/components/ui/AIAssistantPanel/NotebookProposalRenderer.tsx b/apps/studio/components/ui/AIAssistantPanel/NotebookProposalRenderer.tsx
index f91758dea8e..354197b2ca9 100644
--- a/apps/studio/components/ui/AIAssistantPanel/NotebookProposalRenderer.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/NotebookProposalRenderer.tsx
@@ -175,7 +175,7 @@ function UpdateNotebookTerminalSummary({
: 'Skipped notebook update'
return (
- <div className="flex items-center justify-between gap-2 my-2 mx-4 px-3 py-1.5 text-sm border rounded-md bg-surface-75">
+ <div className="flex items-center justify-between gap-2 my-2 px-3 py-1.5 text-sm border rounded-md bg-surface-75">
<span className="text-foreground-light truncate">{label}</span>
{state === 'output-available' && parsedOutput.success && ref && (
<Button asChild size="tiny">
@@ -458,7 +458,7 @@ function UpdateNotebookProposal({
if (isLoading) {
return (
- <div className="my-4 mx-4 rounded-lg border bg-surface-75 heading-meta h-9 px-3 text-foreground-light flex items-center gap-2">
+ <div className="my-4 rounded-lg border bg-surface-75 heading-meta h-9 px-3 text-foreground-light flex items-center gap-2">
<Loader2 className="w-4 h-4 animate-spin" />
Loading notebook...
</div>
@@ -572,7 +572,7 @@ function DeleteNotebookProposal({
if (isLoading) {
return (
- <div className="my-4 mx-4 rounded-lg border bg-surface-75 heading-meta h-9 px-3 text-foreground-light flex items-center gap-2">
+ <div className="my-4 rounded-lg border bg-surface-75 heading-meta h-9 px-3 text-foreground-light flex items-center gap-2">
<Loader2 className="w-4 h-4 animate-spin" />
Loading notebook...
</div>