Skip to content

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

Add confirmation modal when running notebook if notebook contains query cells that aren't read only (#49376)

Joshen Lim4dc973048d98
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx
index d772a94a77e..1a05d963027 100644
--- a/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx
+++ b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.tsx
@@ -33,6 +33,7 @@ import { toast } from 'sonner'
import {
AiIconAnimation,
Button,
+ Checkbox,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
@@ -41,7 +42,9 @@ import {
} from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { EmptyStatePresentational } from 'ui-patterns/EmptyStatePresentational'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+import { findMutatingQueryCells } from './ExplorerNotebookTab.utils'
import {
ExplorerToolbar,
ExplorerToolbarAction,
@@ -64,7 +67,11 @@ import {
import { useUpsertNotebookMutation } from '@/data/content/notebooks/notebook-upsert-mutation'
import { acceptUntrustedLogsSql } from '@/data/logs/safe-analytics-sql'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
-import { useCurrentNotebook, useNotebooksStateSnapshot } from '@/state/notebooks/notebooks-state'
+import {
+ getNotebooksStateSnapshot,
+ useCurrentNotebook,
+ useNotebooksStateSnapshot,
+} from '@/state/notebooks/notebooks-state'
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
export const ExplorerNotebookTab = () => {
@@ -86,6 +93,10 @@ export const ExplorerNotebookTab = () => {
const [isRunningNotebook, setIsRunningNotebook] = useState(false)
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)
+ const [pendingMutationCells, setPendingMutationCells] = useState<
+ { id: string; title: string }[] | null
+ >(null)
+ const [skipMutatingCells, setSkipMutatingCells] = useState(false)
const queryCellRefs = useRef(new Map<string, QueryEditorHandle>())
const { mutate: updateNotebook, isPending: isUpdating } = useUpsertNotebookMutation({
@@ -117,17 +128,53 @@ export const ExplorerNotebookTab = () => {
}
}
- const handleRunNotebook = async () => {
+ const runNotebook = async ({
+ cellIdsToRun,
+ force = false,
+ }: {
+ cellIdsToRun: string[]
+ force?: boolean
+ }) => {
setIsRunningNotebook(true)
try {
await Promise.allSettled(
- queryCellIds.map((cellId) => queryCellRefs.current.get(cellId)?.run())
+ cellIdsToRun.map((cellId) => queryCellRefs.current.get(cellId)?.run(force))
)
} finally {
setIsRunningNotebook(false)
}
}
+ const getFreshCells = () => {
+ const freshNotebook = id ? getNotebooksStateSnapshot().notebooks[id] : undefined
+ if (!freshNotebook || freshNotebook.projectRef !== ref) return cells
+ return freshNotebook.notebook.content?.cells ?? []
+ }
+
+ const handleRunNotebook = () => {
+ const freshCells = getFreshCells()
+ const mutatingCells = findMutatingQueryCells({
+ cells: freshCells,
+ getLiveSql: (cellId) => queryCellRefs.current.get(cellId)?.getSql(),
+ })
+ if (mutatingCells.length === 0) {
+ runNotebook({ cellIdsToRun: freshCells.filter(isQueryCell).map((cell) => cell._id) })
+ } else {
+ setSkipMutatingCells(false)
+ setPendingMutationCells(mutatingCells)
+ }
+ }
+
+ const handleConfirmRunNotebook = () => {
+ const mutatingCellIds = new Set((pendingMutationCells ?? []).map((cell) => cell.id))
+ const cellIdsToRun = skipMutatingCells
+ ? queryCellIds.filter((id) => !mutatingCellIds.has(id))
+ : queryCellIds
+
+ setPendingMutationCells(null)
+ runNotebook({ cellIdsToRun, force: true })
+ }
+
const handleSaveNotebook = () => {
const notebookId = currentNotebook?.notebook.id
if (!ref || !notebookId || !name || !content) return
@@ -344,6 +391,42 @@ export const ExplorerNotebookTab = () => {
This action cannot be undone. Are you sure you want to delete '{name}'?
</p>
</ConfirmationModal>
+
+ <ConfirmationModal
+ size="small"
+ visible={pendingMutationCells !== null}
+ title="Confirm to run notebook"
+ confirmLabel={skipMutatingCells ? 'Run read-only cells' : 'Run all cells'}
+ variant="warning"
+ onCancel={() => setPendingMutationCells(null)}
+ onConfirm={handleConfirmRunNotebook}
+ >
+ <p className="text-sm">
+ This notebook has {pendingMutationCells?.length ?? 0}{' '}
+ {pendingMutationCells?.length === 1 ? 'query' : 'queries'} that{' '}
+ {pendingMutationCells?.length === 1 ? 'modifies' : 'modify'} data or schema and cannot be
+ undone once run:
+ </p>
+ <ul className="text-sm list-disc pl-4 mt-2">
+ {pendingMutationCells?.map((cell) => (
+ <li key={cell.id}>{cell.title}</li>
+ ))}
+ </ul>
+ <FormItemLayout
+ isReactForm={false}
+ layout="flex"
+ id="skipMutatingCells"
+ label="Skip these queries"
+ description="Run only the read-only cells in this notebook"
+ className="mt-4 [&>div:first-child>button]:translate-y-0.5"
+ >
+ <Checkbox
+ id="skipMutatingCells"
+ checked={skipMutatingCells}
+ onCheckedChange={(value) => setSkipMutatingCells(!!value)}
+ />
+ </FormItemLayout>
+ </ConfirmationModal>
</div>
)
}
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.utils.test.ts b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.utils.test.ts
new file mode 100644
index 00000000000..ee346c23e76
--- /dev/null
+++ b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.utils.test.ts
@@ -0,0 +1,127 @@
+import { untrustedSql } from '@supabase/pg-meta'
+import { describe, expect, it } from 'vitest'
+
+import { findMutatingQueryCells, isMutatingSql } from './ExplorerNotebookTab.utils'
+import { type Cell } from '@/data/content/notebooks/notebook-schema'
+import { untrustedLogSql } from '@/data/logs/safe-analytics-sql'
+
+describe('isMutatingSql', () => {
+ it('returns false for a read-only query', () => {
+ expect(isMutatingSql('select * from auth.users')).toBe(false)
+ })
+
+ it.each([
+ 'insert',
+ 'update',
+ 'delete',
+ 'create',
+ 'alter',
+ 'drop',
+ 'truncate',
+ 'grant',
+ 'revoke',
+ 'merge',
+ ])('returns true when the SQL starts with %s', (keyword) => {
+ expect(isMutatingSql(`${keyword} something`)).toBe(true)
+ })
+
+ it('is case-insensitive', () => {
+ expect(isMutatingSql('DELETE FROM auth.users')).toBe(true)
+ })
+
+ it('returns true when a mutating statement follows a read-only one', () => {
+ expect(isMutatingSql('select 1; delete from auth.users')).toBe(true)
+ })
+
+ it('ignores mutating keywords inside comments', () => {
+ expect(isMutatingSql('-- delete this table later\nselect 1')).toBe(false)
+ expect(isMutatingSql('/* create table foo */\nselect 1')).toBe(false)
+ })
+})
+
+describe('findMutatingQueryCells', () => {
+ const readOnlyDatabaseCell: Cell = {
+ _tag: 'database_cell',
+ _id: 'cell-1',
+ title: 'Signups',
+ view: 'table',
+ unchecked_sql: untrustedSql('select * from auth.users'),
+ row_limit: 50,
+ }
+
+ const mutatingDatabaseCell: Cell = {
+ _tag: 'database_cell',
+ _id: 'cell-2',
+ title: 'Cleanup',
+ view: 'table',
+ unchecked_sql: untrustedSql('delete from auth.users where id = 1'),
+ row_limit: 50,
+ }
+
+ const mutatingLogCell: Cell = {
+ _tag: 'log_cell',
+ _id: 'cell-3',
+ title: 'Edge logs',
+ view: 'table',
+ unchecked_sql: untrustedLogSql('insert into edge_logs values (1)'),
+ time_range: { _tag: 'relative_time_range', unit: 'hour', amount: 1 },
+ }
+
+ const markdownCell: Cell = {
+ _tag: 'markdown_cell',
+ _id: 'cell-4',
+ text: 'insert some notes here',
+ }
+
+ it('returns an empty array when there are no mutating database cells', () => {
+ expect(findMutatingQueryCells({ cells: [readOnlyDatabaseCell, markdownCell] })).toEqual([])
+ })
+
+ it('flags mutating database cells with their id and title', () => {
+ expect(findMutatingQueryCells({ cells: [readOnlyDatabaseCell, mutatingDatabaseCell] })).toEqual(
+ [{ id: 'cell-2', title: 'Cleanup' }]
+ )
+ })
+
+ it('excludes log cells even when their SQL looks mutating', () => {
+ expect(findMutatingQueryCells({ cells: [mutatingDatabaseCell, mutatingLogCell] })).toEqual([
+ { id: 'cell-2', title: 'Cleanup' },
+ ])
+ })
+
+ it('falls back to "Untitled query" when a mutating cell has no title', () => {
+ const untitledCell: Cell = { ...mutatingDatabaseCell, title: undefined }
+ expect(findMutatingQueryCells({ cells: [untitledCell] })).toEqual([
+ { id: 'cell-2', title: 'Untitled query' },
+ ])
+ })
+
+ it('flags a cell whose live SQL mutates even though the stored SQL is read-only', () => {
+ const getLiveSql = (cellId: string) =>
+ cellId === 'cell-1' ? 'delete from auth.users' : undefined
+
+ expect(
+ findMutatingQueryCells({ cells: [readOnlyDatabaseCell, mutatingDatabaseCell], getLiveSql })
+ ).toEqual([
+ { id: 'cell-1', title: 'Signups' },
+ { id: 'cell-2', title: 'Cleanup' },
+ ])
+ })
+
+ it('flags a cell whose stored SQL mutates even when its live SQL looks read-only', () => {
+ const getLiveSql = (cellId: string) =>
+ cellId === 'cell-2' ? 'select * from auth.users' : undefined
+
+ expect(
+ findMutatingQueryCells({ cells: [readOnlyDatabaseCell, mutatingDatabaseCell], getLiveSql })
+ ).toEqual([{ id: 'cell-2', title: 'Cleanup' }])
+ })
+
+ it('falls back to the stored SQL when the live getter has nothing for a cell', () => {
+ const getLiveSql = () => undefined
+
+ expect(
+ findMutatingQueryCells({ cells: [readOnlyDatabaseCell, mutatingDatabaseCell], getLiveSql })
+ ).toEqual([{ id: 'cell-2', title: 'Cleanup' }])
+ })
+})
diff --git a/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.utils.ts b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.utils.ts
new file mode 100644
index 00000000000..db101184810
--- /dev/null
+++ b/apps/studio/components/interfaces/Explorer/ExplorerNotebookTab.utils.ts
@@ -0,0 +1,41 @@
+import { type Snapshot } from 'valtio'
+
+import { type Cell, type DatabaseCell } from '@/data/content/notebooks/notebook-schema'
+import { removeCommentsFromSql } from '@/lib/helpers'
+
+const MUTATING_STATEMENT_REGEX =
+ /^\s*(insert|update|delete|create|alter|drop|truncate|grant|revoke|merge)\b/i
+
+/**
+ * Whether `sql` contains any statement that writes to data or schema, as opposed to a
+ * read-only query. Checked per `;`-delimited statement so a mutating statement anywhere
+ * in a multi-statement cell is caught, not just when it leads.
+ */
+export function isMutatingSql(sql: string): boolean {
+ const cleanedSql = removeCommentsFromSql(sql)
+ return cleanedSql.split(';').some((statement) => MUTATING_STATEMENT_REGEX.test(statement))
+}
+
+/**
+ * The database cells whose SQL mutates data or schema, for flagging before a notebook-wide run.
+ */
+export function findMutatingQueryCells({
+ cells,
+ getLiveSql,
+}: {
+ cells: readonly Snapshot<Cell>[]
+ /**
+ * Lets a caller also check each cell's live editor buffer as well. The store
+ * only updates on a Monaco blur commit, which fires asynchronously, so a scan
+ * against the store alone can miss SQL typed just before the run click.
+ * */
+ getLiveSql?: (cellId: string) => string | undefined
+}): { id: string; title: string }[] {
+ return cells
+ .filter((cell): cell is Snapshot<DatabaseCell> => cell._tag === 'database_cell')
+ .filter((cell) => {
+ const liveSql = getLiveSql?.(cell._id)
+ return isMutatingSql(cell.unchecked_sql) || (liveSql !== undefined && isMutatingSql(liveSql))
+ })
+ .map((cell) => ({ id: cell._id, title: cell.title ?? 'Untitled query' }))
+}
diff --git a/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx b/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx
index ba4730da723..71639aca904 100644
--- a/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx
+++ b/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx
@@ -104,7 +104,14 @@ export type ExplorerQueryModel =
} & LogsSourceParameters)
export type QueryEditorHandle = {
- run: () => Promise<void>
+ /**
+ * `force` skips this query's own blocking-issue check (destructive op, unwhered
+ * update/delete, missing RLS, …) — for a caller that already gathered its own consent
+ * for this run, e.g. the notebook-wide mutation confirmation.
+ */
+ run: (force?: boolean) => Promise<void>
+ /** The editor's live text buffer, ahead of any blur-triggered commit to the store. */
+ getSql: () => string
}
type QueryEditorProps = {
@@ -345,7 +352,10 @@ export const QueryEditor = forwardRef<QueryEditorHandle, QueryEditorProps>(funct
const Shell = variant === 'viewport' ? ExplorerQueryViewport : ExplorerQuery
- useImperativeHandle(ref, () => ({ run: () => handleRunQuery() }))
+ useImperativeHandle(ref, () => ({
+ run: (force = false) => handleRunQuery({ shouldForce: force }),
+ getSql: () => sqlRef.current,
+ }))
useEffect(() => {
if (!promptState?.isOpen) return
diff --git a/apps/studio/components/interfaces/Explorer/__tests__/ExplorerNotebookTab.test.tsx b/apps/studio/components/interfaces/Explorer/__tests__/ExplorerNotebookTab.test.tsx
index 8cde3bb5944..cad2ac83fad 100644
--- a/apps/studio/components/interfaces/Explorer/__tests__/ExplorerNotebookTab.test.tsx
+++ b/apps/studio/components/interfaces/Explorer/__tests__/ExplorerNotebookTab.test.tsx
@@ -1,11 +1,13 @@
-import { screen, waitFor } from '@testing-library/react'
+import { fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { LOCAL_STORAGE_KEYS, safeLocalStorage } from 'common'
import { HttpResponse } from 'msw'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { ExplorerNotebookTab } from '../ExplorerNotebookTab'
+import { setCellSql } from '../QueryCell/QueryCell.utils'
import { createMarkdownCellSkeleton, createQueryCellSkeleton } from '../utils'
+import { isQueryCell } from '@/data/content/notebooks/notebook-schema'
import { untrustedLogSql } from '@/data/logs/safe-analytics-sql'
import { notebooksState } from '@/state/notebooks/notebooks-state'
import type { Notebook } from '@/state/notebooks/types'
@@ -30,8 +32,18 @@ vi.mock('common', async (importOriginal) => {
})
vi.mock('@/components/ui/CodeEditor/CodeEditor', () => ({
- CodeEditor: ({ value }: { value: string }) => (
- <textarea aria-label="SQL editor" value={value} readOnly />
+ CodeEditor: ({
+ value,
+ onInputChange,
+ }: {
+ value: string
+ onInputChange?: (value: string | undefined) => void
+ }) => (
+ <textarea
+ aria-label="SQL editor"
+ value={value}
+ onChange={(e) => onInputChange?.(e.target.value)}
+ />
),
}))
@@ -76,6 +88,33 @@ const renderNotebookTab = () =>
</TabsStateContext.Provider>
)
+// `useAddDefinitions` fires its own background keywords/functions/schemas/table-columns
+// fetches, and `QueryEditor` fires a background database-event-triggers fetch (for the
+// run-time RLS/event-trigger warning check), against this same generic pg-meta query
+// endpoint (differentiated by the `key` search param) as soon as a database cell's editor
+// mounts — those are expected and unrelated to an actual cell run.
+const BACKGROUND_QUERY_KEYS = ['keywords', 'database-functions', 'schemas', 'table-columns']
+const isBackgroundQueryKey = (key: string) =>
+ BACKGROUND_QUERY_KEYS.includes(key) || key.endsWith('database-event-triggers')
+
+/** Mocks the database query endpoint and returns the SQL text of every non-background request. */
+const mockDatabaseQueryRequests = () => {
+ const queries: string[] = []
+ addAPIMock({
+ method: 'post',
+ path: '/platform/pg-meta/:ref/query',
+ response: async ({ request }) => {
+ const key = new URL(request.url).searchParams.get('key')
+ if (!key || !isBackgroundQueryKey(key)) {
+ const body = (await request.clone().json()) as { query?: string }
+ queries.push(body.query ?? '')
+ }
+ return HttpResponse.json([{ result: 1 }])
+ },
+ })
+ return queries
+}
+
beforeEach(() => {
setupSqlEditorMocks()
testContext.flags.otelLegacyLogs = true
@@ -125,25 +164,7 @@ describe('ExplorerNotebookTab', () => {
})
it('runs every database and log cell, and skips markdown cells, on "Run notebook"', async () => {
- // `useAddDefinitions` fires its own background keywords/functions/schemas/table-columns
- // fetches against this same generic pg-meta query endpoint (differentiated by the `key`
- // search param) as soon as a database cell's editor mounts, and `QueryEditor` runs an
- // event-trigger lookup for `analyzeQueryIssues` — both are expected and unrelated to the
- // actual cell run.
- const INTELLISENSE_KEYS = ['keywords', 'database-functions', 'schemas', 'table-columns']
- const dbRequests: Request[] = []
- addAPIMock({
- method: 'post',
- path: '/platform/pg-meta/:ref/query',
- response: async ({ request }) => {
- const key = new URL(request.url).searchParams.get('key')
- const { query } = (await request.clone().json()) as { query?: string }
- const isIntellisenseRequest = !!key && INTELLISENSE_KEYS.includes(key)
- const isEventTriggerRequest = !!query?.includes('pg_event_trigger')
- if (!isIntellisenseRequest && !isEventTriggerRequest) dbRequests.push(request)
- return HttpResponse.json([{ result: 1 }])
- },
- })
+ const dbRequests = mockDatabaseQueryRequests()
const logRequests: Request[] = []
addAPIMock({
@@ -166,6 +187,129 @@ describe('ExplorerNotebookTab', () => {
await waitFor(() => expect(runNotebookButton).toBeEnabled())
})
+ describe('mutation confirmation on "Run notebook"', () => {
+ const readOnlyCell = createQueryCellSkeleton({ title: 'Read-only query', sql: 'select 1' })
+ const mutatingCell = createQueryCellSkeleton({
+ title: 'Mutating query',
+ sql: 'delete from foo',
+ })
+
+ beforeEach(() => {
+ seedNotebook([readOnlyCell, mutatingCell])
+ })
+
+ it('opens a confirmation modal instead of running immediately when a cell mutates data', async () => {
+ const queries = mockDatabaseQueryRequests()
+
+ renderNotebookTab()
+
+ await userEvent.click(await screen.findByRole('button', { name: 'Run notebook' }))
+
+ const dialog = await screen.findByRole('dialog', { name: 'Confirm to run notebook' })
+ expect(within(dialog).getByText('Mutating query')).toBeInTheDocument()
+ expect(queries).toHaveLength(0)
+ })
+
+ it('runs no cells when the confirmation is cancelled', async () => {
+ const queries = mockDatabaseQueryRequests()
+
+ renderNotebookTab()
+
+ await userEvent.click(await screen.findByRole('button', { name: 'Run notebook' }))
+ await screen.findByRole('dialog', { name: 'Confirm to run notebook' })
+
+ await userEvent.click(screen.getByRole('button', { name: 'Cancel' }))
+
+ await waitFor(() =>
+ expect(
+ screen.queryByRole('dialog', { name: 'Confirm to run notebook' })
+ ).not.toBeInTheDocument()
+ )
+ expect(queries).toHaveLength(0)
+ })
+
+ it('runs every cell, including the mutating one, when confirmed with "Run all cells"', async () => {
+ const queries = mockDatabaseQueryRequests()
+
+ renderNotebookTab()
+
+ await userEvent.click(await screen.findByRole('button', { name: 'Run notebook' }))
+ await screen.findByRole('dialog', { name: 'Confirm to run notebook' })
+
+ await userEvent.click(screen.getByRole('button', { name: 'Run all cells' }))
+
+ await waitFor(() => expect(queries).toHaveLength(2))
+ expect(queries.some((query) => query.includes('select 1'))).toBe(true)
+ expect(queries.some((query) => query.includes('delete from foo'))).toBe(true)
+ })
+
+ it('picks up a SQL commit that lands after this render but before the click handler runs', async () => {
+ seedNotebook([readOnlyCell])
+ const queries = mockDatabaseQueryRequests()
+
+ renderNotebookTab()
+
+ const runNotebookButton = await screen.findByRole('button', { name: 'Run notebook' })
+ await waitFor(() => expect(runNotebookButton).toBeEnabled())
+
+ // Simulates the store commit a Monaco blur performs synchronously right before the
+ // click (see QueryCell's onSqlCommit), without letting the resulting re-render reach
+ // this component first — the exact race "type mutating SQL, then immediately click
+ // Run notebook" hits in the browser.
+ notebooksState.updateCell({
+ id: NOTEBOOK_ID,
+ cellId: readOnlyCell._id,
+ updater: (cell) => (isQueryCell(cell) ? setCellSql(cell, 'delete from foo') : cell),
+ })
+ fireEvent.click(runNotebookButton)
+
+ const dialog = await screen.findByRole('dialog', { name: 'Confirm to run notebook' })
+ expect(within(dialog).getByText('Read-only query')).toBeInTheDocument()
+ expect(queries).toHaveLength(0)
+ })
+
+ it('picks up SQL typed into the live editor buffer that has not yet been committed to the store', async () => {
+ seedNotebook([readOnlyCell], 'new')
+ const queries = mockDatabaseQueryRequests()
+
+ renderNotebookTab()
+
+ const sqlEditor = await screen.findByRole('textbox', { name: 'SQL editor' })
+ fireEvent.change(sqlEditor, { target: { value: 'delete from foo' } })
+
+ // No blur fired, so the store still has the original read-only SQL — the check must
+ // read the live buffer directly, not `notebooksState`, to catch this.
+ expect(
+ notebooksState.notebooks[NOTEBOOK_ID]?.notebook.content?.cells.find(
+ (cell) => cell._id === readOnlyCell._id
+ )
+ ).toMatchObject({ unchecked_sql: 'select 1' })
+
+ const runNotebookButton = screen.getByRole('button', { name: 'Run notebook' })
+ await userEvent.click(runNotebookButton)
+
+ const dialog = await screen.findByRole('dialog', { name: 'Confirm to run notebook' })
+ expect(within(dialog).getByText('Read-only query')).toBeInTheDocument()
+ expect(queries).toHaveLength(0)
+ })
+
+ it('runs only the read-only cells when "Skip these queries" is checked', async () => {
+ const queries = mockDatabaseQueryRequests()
+
+ renderNotebookTab()
+
+ await userEvent.click(await screen.findByRole('button', { name: 'Run notebook' }))
+ await screen.findByRole('dialog', { name: 'Confirm to run notebook' })
+
+ await userEvent.click(screen.getByRole('checkbox', { name: 'Skip these queries' }))
+ await userEvent.click(screen.getByRole('button', { name: 'Run read-only cells' }))
+
+ await waitFor(() => expect(queries).toHaveLength(1))
+ expect(queries[0]).toContain('select 1')
+ expect(queries.some((query) => query.includes('delete from foo'))).toBe(false)
+ })
+ })
+
it('disables "Run notebook" when the notebook has no database or log cells', async () => {
seedNotebook([createMarkdownCellSkeleton()])
diff --git a/apps/studio/components/ui/SortableSection.tsx b/apps/studio/components/ui/SortableSection.tsx
index 53e44256795..fa66764ab6d 100644
--- a/apps/studio/components/ui/SortableSection.tsx
+++ b/apps/studio/components/ui/SortableSection.tsx
@@ -50,7 +50,7 @@ export const SortableSection = ({
<div
ref={setNodeRef}
style={style}
- className="group relative will-change-transform flex items-start gap-x-4"
+ className="group relative will-change-transform flex items-start gap-x-4 min-w-0"
>
<div className={cn('flex items-center', gripClassName)}>
{actions}
@@ -87,7 +87,7 @@ export const SortableSection = ({
{gripDropdownContent}
</DropdownMenu>
</div>
- <div className={cn('w-full', isDragging && 'opacity-70')}>{children}</div>
+ <div className={cn('w-full min-w-0', isDragging && 'opacity-70')}>{children}</div>
</div>
)
}