Skip to content

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

Chore/sql editor ai self host (#19649)

Joshen Lim453c76996389
diff --git a/apps/studio/components/interfaces/Billing/Subscription/Subscription.utils.ts b/apps/studio/components/interfaces/Billing/Subscription/Subscription.utils.ts
index 85171c1734d..0011e6dc0d1 100644
--- a/apps/studio/components/interfaces/Billing/Subscription/Subscription.utils.ts
+++ b/apps/studio/components/interfaces/Billing/Subscription/Subscription.utils.ts
@@ -1,3 +1,4 @@
+import { IS_PLATFORM } from 'lib/constants'
import { OrgSubscription } from 'data/subscriptions/org-subscription-query'
import { ProjectSelectedAddon } from 'data/subscriptions/project-addons-query'
@@ -10,6 +11,8 @@ export const getAddons = (selectedAddons: ProjectSelectedAddon[]) => {
}
export const subscriptionHasHipaaAddon = (subscription: OrgSubscription | undefined): boolean => {
+ if (IS_PLATFORM) return false
+
return (
subscription !== undefined &&
subscription.addons.some((addon) => addon.supabase_prod_id === 'addon_security_hipaa')
diff --git a/apps/studio/components/interfaces/Home/NewProjectPanel/NewProjectPanel.tsx b/apps/studio/components/interfaces/Home/NewProjectPanel/NewProjectPanel.tsx
index 4a88a217d31..122e549468a 100644
--- a/apps/studio/components/interfaces/Home/NewProjectPanel/NewProjectPanel.tsx
+++ b/apps/studio/components/interfaces/Home/NewProjectPanel/NewProjectPanel.tsx
@@ -4,14 +4,13 @@ import SVG from 'react-inlinesvg'
import { Button, IconActivity, IconArchive, IconCode, IconExternalLink, IconKey } from 'ui'
import Panel from 'components/ui/Panel'
-import { useFlag, useIsFeatureEnabled } from 'hooks'
+import { useIsFeatureEnabled } from 'hooks'
import APIKeys from './APIKeys'
import GetStartedHero from './GetStartedHero'
const NewProjectPanel = () => {
const router = useRouter()
const { ref } = router.query
- const supabaseAIEnabled = useFlag('sqlEditorSupabaseAI')
const {
projectAuthAll: authEnabled,
@@ -74,15 +73,7 @@ const NewProjectPanel = () => {
/>
}
>
- <Link
- href={
- supabaseAIEnabled
- ? `/project/${ref}/sql/new`
- : `/project/${ref}/sql/templates`
- }
- >
- SQL editor
- </Link>
+ <Link href={`/project/${ref}/sql/new`}>SQL editor</Link>
</Button>
<Button asChild type="default" icon={<IconExternalLink size={14} />}>
<Link
diff --git a/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx b/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx
index 5c2496d76e1..84728b0100d 100644
--- a/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx
@@ -22,7 +22,6 @@ const RenameQueryModal = ({ snippet, visible, onCancel, onComplete }: RenameQuer
const { ref } = useParams()
const organization = useSelectedOrganization()
const snap = useSqlEditorStateSnapshot()
- const supabaseAIEnabled = useFlag('sqlEditorSupabaseAI')
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })
// Customers on HIPAA plans should not have access to Supabase AI
@@ -89,7 +88,7 @@ const RenameQueryModal = ({ snippet, visible, onCancel, onComplete }: RenameQuer
onChange={(e) => setNameInput(e.target.value)}
/>
<div className="flex w-full justify-end mt-2">
- {supabaseAIEnabled && !hasHipaaAddon && isAiButtonVisible && (
+ {!hasHipaaAddon && isAiButtonVisible && (
<Button
type="default"
onClick={async () => {
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index 536d1d1aaf2..a0c8860ec9e 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -119,7 +119,6 @@ const SQLEditor = () => {
const [hasSelection, setHasSelection] = useState<boolean>(false)
const inputRef = useRef<HTMLInputElement>(null)
const readReplicasEnabled = useFlag('readReplicas')
- const supabaseAIEnabled = useFlag('sqlEditorSupabaseAI')
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })
const { data: databases, isSuccess: isSuccessReadReplicas } = useReadReplicasQuery({
@@ -315,7 +314,7 @@ const SQLEditor = () => {
return
}
- if (supabaseAIEnabled && !hasHipaaAddon && snippet?.snippet.name === untitledSnippetTitle) {
+ if (!hasHipaaAddon && snippet?.snippet.name === untitledSnippetTitle) {
// Intentionally don't await title gen (lazy)
setAiTitle(id, sql)
}
@@ -344,17 +343,7 @@ const SQLEditor = () => {
})
}
},
- [
- isDiffOpen,
- id,
- isExecuting,
- project,
- supabaseAIEnabled,
- hasHipaaAddon,
- execute,
- getImpersonatedRole,
- setAiTitle,
- ]
+ [isDiffOpen, id, isExecuting, project, hasHipaaAddon, execute, getImpersonatedRole, setAiTitle]
)
const handleNewQuery = useCallback(
@@ -567,7 +556,7 @@ const SQLEditor = () => {
}}
/>
<div className="flex h-full flex-col relative">
- {isAiOpen && supabaseAIEnabled && !hasHipaaAddon && (
+ {isAiOpen && !hasHipaaAddon && (
<AISchemaSuggestionPopover
onClickSettings={() => {
appSnap.setShowAiSettingsModal(true)
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx
index 5c522908f38..fa1d301b47e 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx
@@ -49,7 +49,6 @@ const UtilityTabResults = ({ id, isExecuting }: UtilityTabResultsProps) => {
const snippet = snap.snippets[id]
const result = snap.results[id]?.[0]
const isUtilityPanelCollapsed = (snippet?.splitSizes?.[1] ?? 0) === 0
- const supabaseAIEnabled = useFlag('sqlEditorSupabaseAI')
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })
@@ -114,7 +113,7 @@ const UtilityTabResults = ({ id, isExecuting }: UtilityTabResultsProps) => {
)}
</div>
)}
- {supabaseAIEnabled && !hasHipaaAddon && (
+ {!hasHipaaAddon && (
<Button
icon={
<div className="scale-75">
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
index 1094980def8..f1f60ddbf14 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
@@ -51,7 +51,6 @@ const NavigationBar = () => {
const { project } = useProjectContext()
const navLayoutV2 = useFlag('navigationLayoutV2')
- const supabaseAIEnabled = useFlag('sqlEditorSupabaseAI')
const showFeaturePreviews = useFlag('featurePreviews')
const isNewAPIDocsEnabled = useIsAPIDocsSidePanelEnabled()
@@ -69,7 +68,7 @@ const NavigationBar = () => {
const realtimeFlagEnabled = useFlag('realtimeDashboard')
const activeRoute = router.pathname.split('/')[3]
- const toolRoutes = generateToolRoutes(projectRef, project, supabaseAIEnabled)
+ const toolRoutes = generateToolRoutes(projectRef, project)
const productRoutes = generateProductRoutes(projectRef, project, {
auth: authEnabled,
edgeFunctions: edgeFunctionsEnabled,
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
index d06acaae64c..4d5504d8404 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
@@ -6,11 +6,7 @@ import { Route } from 'components/ui/ui.types'
import { BASE_PATH, IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import { ProjectBase } from 'types'
-export const generateToolRoutes = (
- ref?: string,
- project?: ProjectBase,
- supabaseAIEnabled?: boolean
-): Route[] => {
+export const generateToolRoutes = (ref?: string, project?: ProjectBase): Route[] => {
const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
const buildingUrl = `/project/${ref}/building`
@@ -39,12 +35,7 @@ export const generateToolRoutes = (
),
link: !IS_PLATFORM
? `/project/${ref}/sql/1`
- : ref &&
- (isProjectBuilding
- ? buildingUrl
- : supabaseAIEnabled
- ? `/project/${ref}/sql/new`
- : `/project/${ref}/sql/templates`),
+ : ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/sql/new`),
},
]
}