studio: add sql provenance trackingot ai assistant + reports

This commit is contained in:
Charis Lam
2026-05-05 13:10:15 -04:00
parent 4f28e5ccb4
commit 4563932ce2
4 changed files with 12 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import { acceptUntrustedSql } from '@supabase/pg-meta'
import { useQuery } from '@tanstack/react-query'
import { useParams } from 'common'
import { X } from 'lucide-react'
@@ -104,7 +105,10 @@ export const ReportBlock = ({
return executeSql({
projectRef,
connectionString,
sql,
// acceptUntrustedSql is usually not allowed in an auto-run position,
// but in this case we are explicitly allowing it because adding a block
// to a report is an explicit user action.
sql: acceptUntrustedSql(sql),
})
},
enabled: !isLoadingContent && contentError == null,

View File

@@ -1,3 +1,4 @@
import { acceptUntrustedSql, type UntrustedSqlFragment } from '@supabase/pg-meta'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
import { useParams } from 'common'
@@ -22,7 +23,7 @@ interface DisplayBlockRendererProps {
messageId: string
toolCallId: string
initialArgs: {
sql: string
sql: UntrustedSqlFragment
label?: string
isWriteQuery?: boolean
view?: 'table' | 'chart'
@@ -163,7 +164,7 @@ export const DisplayBlockRenderer = ({
setIsWriteQuery(true)
}
executeSql(
{ projectRef: ref, connectionString, sql: sqlQuery },
{ projectRef: ref, connectionString, sql: acceptUntrustedSql(sqlQuery) },
{
onSuccess: (data) => {
setRows(Array.isArray(data.result) ? data.result : undefined)

View File

@@ -1,3 +1,4 @@
import { untrustedSql } from '@supabase/pg-meta'
import { z, type SafeParseReturnType } from 'zod'
// Splits markdown into alternating [plain, code, plain, code, ...] segments.
@@ -81,7 +82,7 @@ const executeSqlChartResultSchema = z
const chartArgs = chartConfig ?? config
return {
sql: sql ?? '',
sql: untrustedSql(sql ?? ''),
label,
isWriteQuery,
view: chartArgs?.view,

View File

@@ -1,3 +1,4 @@
import { untrustedSql } from '@supabase/pg-meta'
import dynamic from 'next/dynamic'
import Link from 'next/link'
import {
@@ -265,7 +266,7 @@ export const MarkdownPre = ({
messageId={id}
toolCallId={toolCallId}
initialArgs={{
sql: cleanContent,
sql: untrustedSql(cleanContent),
label: title,
isWriteQuery: false,
view: isChart ? 'chart' : 'table',