Skip to content

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

consider js comments in assistant props (#33669)

Saxon Fletcher4bc9596dbd84
diff --git a/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx b/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx
index d7a38e9c464..019eab1197a 100644
--- a/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx
@@ -151,7 +151,7 @@ export const MarkdownPre = ({ children }: { children: any }) => {
const language = children[0].props.className?.replace('language-', '') || 'sql'
const rawContent = children[0].props.children[0]
- const propsMatch = rawContent.match(/--\s*props:\s*(\{[^}]+\})/)
+ const propsMatch = rawContent.match(/(?:--|\/\/)\s*props:\s*(\{[^}]+\})/)
const snippetProps: AssistantSnippetProps = useMemo(
() => (propsMatch ? JSON.parse(propsMatch[1]) : {}),
@@ -164,7 +164,7 @@ export const MarkdownPre = ({ children }: { children: any }) => {
const runQuery = snippetProps.runQuery === 'true'
// Strip props from the content for both SQL and edge functions
- const cleanContent = rawContent.replace(/--\s*props:\s*\{[^}]+\}/, '').trim()
+ const cleanContent = rawContent.replace(/(?:--|\/\/)\s*props:\s*\{[^}]+\}/, '').trim()
const isDraggableToReports =
supportSQLBlocks && canCreateSQLSnippet && router.pathname.endsWith('/reports/[id]')