diff --git a/frontend/src/components/app-config/ai-config.tsx b/frontend/src/components/app-config/ai-config.tsx index 296967c8b64..e9bc68f3c0b 100644 --- a/frontend/src/components/app-config/ai-config.tsx +++ b/frontend/src/components/app-config/ai-config.tsx @@ -1168,7 +1168,11 @@ export const AiModelDisplayConfig: React.FC = ({ ))} - + ); }; @@ -1176,7 +1180,8 @@ export const AiModelDisplayConfig: React.FC = ({ export const AddModelForm: React.FC<{ form: UseFormReturn; customModels: QualifiedModelId[]; -}> = ({ form, customModels }) => { + onSubmit: (values: UserConfig) => void; +}> = ({ form, customModels, onSubmit }) => { const [isFormOpen, setIsFormOpen] = useState(false); const [modelAdded, setModelAdded] = useState(false); const [provider, setProvider] = useState(null); @@ -1209,6 +1214,7 @@ export const AddModelForm: React.FC<{ ); form.setValue("ai.models.custom_models", [newModel.id, ...customModels]); + onSubmit(form.getValues()); resetForm(); // Show model added message for 2 seconds diff --git a/frontend/src/core/codemirror/language/languages/sql/sql.ts b/frontend/src/core/codemirror/language/languages/sql/sql.ts index b32d3fbf369..d8a0c593f8d 100644 --- a/frontend/src/core/codemirror/language/languages/sql/sql.ts +++ b/frontend/src/core/codemirror/language/languages/sql/sql.ts @@ -666,14 +666,13 @@ function sqlValidationExtension(): Extension { let lastValidationRequest: string | null = null; return EditorView.updateListener.of((update) => { - // Only run validation if the document has changed - if (!update.docChanged) { + // Only run validation if the document has changed and editor is focused + if (!update.docChanged || !update.view.hasFocus) { return; } - // Only run validation if the SQL mode is set to validate const sqlMode = getSQLMode(); - if (sqlMode !== "validate") { + if (sqlMode === "default") { return; } @@ -710,7 +709,6 @@ function sqlValidationExtension(): Extension { try { const dialect = connectionNameToParserDialect(connectionName); - const sqlMode = getSQLMode(); const result = await validateSQL( sqlContent, connectionName,