Skip to content

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

fix(cmdk): strip additional markdown code from generated sql

Greg Richardson3d4bf75a9373
diff --git a/packages/ui/src/components/Command/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL.tsx
index e63f8cf8a96..02856cd3963 100644
--- a/packages/ui/src/components/Command/GenerateSQL.tsx
+++ b/packages/ui/src/components/Command/GenerateSQL.tsx
@@ -111,7 +111,7 @@ const SQLOutputActions = ({ answer }: { answer: string }) => {
return (
<div className="flex items-center justify-end space-x-2 mr-12">
- <CopyToClipboard text={answer?.replace(/`/g, '')}>
+ <CopyToClipboard text={answer?.replace(/```.*/g, '').trim()}>
<Button
type="default"
icon={
diff --git a/studio/components/interfaces/App/CommandMenuWrapper.tsx b/studio/components/interfaces/App/CommandMenuWrapper.tsx
index e4038a72b49..07359411b5f 100644
--- a/studio/components/interfaces/App/CommandMenuWrapper.tsx
+++ b/studio/components/interfaces/App/CommandMenuWrapper.tsx
@@ -28,7 +28,7 @@ const CommandMenuWrapper = ({ children }: PropsWithChildren<{}>) => {
const onSaveGeneratedSQL = async (answer: string, resolve: any) => {
// remove backticks from returned answer
- answer = answer.replace(/`/g, '')
+ answer = answer.replace(/```.*/g, '').trim()
const formattedOutput = `
-- Note: This query was generated via Supabase AI, please do verify the correctness of the