Files
Saxon Fletcher 0043e6f53b feat(studio): add Explorer onboarding and startup preference (#50493)
<img width="1454" height="920" alt="image"
src="https://github.com/user-attachments/assets/a289b618-2bd2-4957-ac49-71d4e372d2cc"
/>


## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

Yes.

## What kind of change does this PR introduce?

Feature.

## What is the current behavior?

Explorer always opens on its start page, without onboarding or a startup
preference.

## What is the new behavior?

Adds one-time onboarding with wireframe option cards and a collapsed
Learn more section. Users can start on the Explorer start page or in a
new SQL query tab, and change that choice in Account preferences →
Dashboard. Preferences persist per account in the browser.

## Additional context

How to test:
1. With Explorer enabled and fresh browser storage, open Explorer and
select either startup option. Confirm Open Explorer follows the
selection and onboarding stays dismissed after reload.
2. Change Explorer startup in Account preferences → Dashboard, then
reopen Explorer. SQL query should create one normal query tab; Start
page should restore the pinned home tab.
3. Use the keyboard to select an option and toggle Learn more. Expand it
in a short viewport and check that the page scrolls normally.

Validation: 235 tests pass, including 20 new cases; Studio typecheck and
formatting pass.

The local production build was stopped during compilation and was not
verified locally.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added an Explorer onboarding experience with startup-view selection,
guidance, and a Learn more section.
- Added Explorer settings to choose between the Start page and SQL query
views.
  - Explorer preferences now persist across sessions and accounts.
  - Explorer can open directly to a new SQL query when selected.
- The Explorer Home tab is shown based on the selected startup
preference.
- **Accessibility**
  - Reduced-motion settings now disable the Explorer loading animation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-17 15:53:18 +10:00

115 lines
3.8 KiB
TypeScript

import { zodResolver } from '@hookform/resolvers/zod'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import {
Card,
CardContent,
Form,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import * as z from 'zod'
import { DashboardToggle } from './DashboardToggle'
import { useIsInlineEditorSetting, useIsQueueOperationsSetting } from './useDashboardSettings'
import { explorerHomeSchema, useExplorerPreferences } from './useExplorerPreferences'
import { useIsExplorerEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { useTrack } from '@/lib/telemetry/track'
const DashboardSettingsSchema = z.object({
inlineEditorEnabled: z.boolean(),
queueOperationsEnabled: z.boolean(),
})
export const DashboardSettingsToggles = () => {
const isExplorerEnabled = useIsExplorerEnabled()
const { home, setHome, isReady } = useExplorerPreferences()
const { inlineEditorEnabled, setInlineEditorEnabled } = useIsInlineEditorSetting()
const { isQueueOperationsEnabled, setIsQueueOperationsEnabled } = useIsQueueOperationsSetting()
const track = useTrack()
const form = useForm<z.infer<typeof DashboardSettingsSchema>>({
resolver: zodResolver(DashboardSettingsSchema),
values: {
inlineEditorEnabled: inlineEditorEnabled ?? false,
queueOperationsEnabled: isQueueOperationsEnabled ?? false,
},
})
const handleInlineEditorToggle = (value: boolean) => {
setInlineEditorEnabled(value)
form.setValue('inlineEditorEnabled', value)
track('inline_editor_setting_clicked', { enabled: value })
toast(
`${value ? 'Editing entities will now be via the SQL Editor' : 'Editing entities will now be via a guided UI panel'}`
)
}
const handleQueueOperationsToggle = (value: boolean) => {
setIsQueueOperationsEnabled(value)
form.setValue('queueOperationsEnabled', value)
track('queue_operations_setting_clicked', { enabled: value })
toast(
`${value ? 'Table edits in the Table Editor will now be queued' : 'Table edits in the Table Editor will now be saved immediately'}`
)
}
return (
<Form {...form}>
<Card>
{isExplorerEnabled && (
<CardContent>
<FormItemLayout
isReactForm={false}
label="Explorer startup"
description="Choose how Explorer opens."
layout="flex-row-reverse"
>
<Select
value={home}
onValueChange={(value) => {
const result = explorerHomeSchema.safeParse(value)
if (result.success) setHome(result.data)
}}
disabled={!isReady}
>
<SelectTrigger aria-label="Explorer startup">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="home">Start page</SelectItem>
<SelectItem value="query">SQL query</SelectItem>
</SelectContent>
</Select>
</FormItemLayout>
</CardContent>
)}
<DashboardToggle
form={form}
name="inlineEditorEnabled"
label="Edit entities in SQL"
description="Edit policies, triggers, and functions in the SQL editor instead of the guided UI."
onToggle={handleInlineEditorToggle}
/>
<DashboardToggle
form={form}
name="queueOperationsEnabled"
label="Queue table operations"
description="Review and batch table edits in Table Editor before saving them to your database."
onToggle={handleQueueOperationsToggle}
isLast
/>
</Card>
</Form>
)
}