Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix save bug when adding a model (#6600)

Shahmir Varqhade257e2624ef
diff --git a/frontend/src/components/app-config/ai-config.tsx b/frontend/src/components/app-config/ai-config.tsx
index 296967c8b6..e9bc68f3c0 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<AiConfigProps> = ({
))}
</Tree>
</div>
- <AddModelForm form={form} customModels={customModels} />
+ <AddModelForm
+ form={form}
+ customModels={customModels}
+ onSubmit={onSubmit}
+ />
</SettingGroup>
);
};
@@ -1176,7 +1180,8 @@ export const AiModelDisplayConfig: React.FC<AiConfigProps> = ({
export const AddModelForm: React.FC<{
form: UseFormReturn<UserConfig>;
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<ProviderId | "custom" | null>(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 b32d3fbf36..d8a0c593f8 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,