Repository: supabase/supabase
File: apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableQuickstart/QuickstartAIWidget.tsx (TypeScript)

Code before:

  useEffect(() => {
    if (aiPrompt && tables.length > 0) {
      setLastGeneratedPrompt(aiPrompt)
    }
  }, [])

  const handleSelectTemplate = useCallback(
    (template: TableSuggestion) => {
      track('table_quickstart_template_clicked', {
        tableName: template.tableName,
        columnCount: template.fields.length,
        source: 'ai',
      })

      const tableField = convertTableSuggestionToTableField(template)
      onSelectTable(tableField)
      toast.success(`Applied ${template.tableName} template. You can customize the fields below.`, {
        duration: SUCCESS_MESSAGE_DURATION_MS,
      })
    },
    [onSelectTable, track]
  )

  const handleGenerateTables = useCallback(
    async (promptOverride?: string, wasQuickIdea = false) => {
      const promptToUse = promptOverride ?? aiPrompt
      if (!promptToUse.trim() || isGenerating) return

      track('table_quickstart_ai_prompt_submitted', {
        promptLength: promptToUse.length,
        wasQuickIdea,
      })

      try {
        const tables = await generateTables(promptToUse)

        track('table_quickstart_ai_generation_completed', {
          success: tables.length > 0,
          tablesGenerated: tables.length,
          promptLength: promptToUse.length,
        })

        setLastGeneratedPrompt(promptToUse)
      } catch (error) {
        track('table_quickstart_ai_generation_completed', {
          success: false,
          tablesGenerated: 0,
          promptLength: promptToUse.length,
          errorMessage: error instanceof Error ? error.message : 'Unknown error',
        })

Review comment (suggestion):
Super nitty 🙈 : generally I don't like adding boolean as raw arguments because it can make the calls to functions confusing, like `handleGenerateTable('test override', false)`. its hard to read without navigating to the definition. I would prefer something like this: 


```suggestion
    async ({ promptOverride, wasQuickIdea = false }: { promptOverride?: string, wasQuickIdea: boolean  }) => {
```

This was its a a bit more clearer to know whats happening on the function calls:

`handleGenerateTable({ promptOverride: 'test overide', wasQuickIdea: false})`

Code after:

  useEffect(() => {
    if (aiPrompt && tables.length > 0) {
      setLastGeneratedPrompt(aiPrompt)
    }
  }, [])

  const handleSelectTemplate = useCallback(
    (template: TableSuggestion) => {
      track('table_quickstart_template_clicked', {
        tableName: template.tableName,
        columnCount: template.fields.length,
        source: 'ai',
      })

      const tableField = convertTableSuggestionToTableField(template)
      onSelectTable(tableField)
      toast.success(`Applied ${template.tableName} template. You can customize the fields below.`, {
        duration: SUCCESS_MESSAGE_DURATION_MS,
      })
    },
    [onSelectTable, track]
  )

  const handleGenerateTables = useCallback(
    async ({
      promptOverride,
      wasQuickIdea = false,
    }: { promptOverride?: string; wasQuickIdea?: boolean } = {}) => {
      const promptToUse = promptOverride ?? aiPrompt
      if (!promptToUse.trim() || isGenerating) return

      track('table_quickstart_ai_prompt_submitted', {
        promptLength: promptToUse.length,
        wasQuickIdea,
      })

      try {
        const tables = await generateTables(promptToUse)

        track('table_quickstart_ai_generation_completed', {
          success: tables.length > 0,
          tablesGenerated: tables.length,
          promptLength: promptToUse.length,
        })

        setLastGeneratedPrompt(promptToUse)
      } catch (error) {
        track('table_quickstart_ai_generation_completed', {
          success: false,
          tablesGenerated: 0,