From 5211e17b61d3ebee9d22b25da3d7fdd6104c1982 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 18 Sep 2026 15:55:45 +0200 Subject: [PATCH] Ask before a change re-indexes local data sources --- .../Dialogs/EmbeddingProviderDialog.razor.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/MindWork AI Studio/Dialogs/EmbeddingProviderDialog.razor.cs b/app/MindWork AI Studio/Dialogs/EmbeddingProviderDialog.razor.cs index d9be51f1..03479185 100644 --- a/app/MindWork AI Studio/Dialogs/EmbeddingProviderDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/EmbeddingProviderDialog.razor.cs @@ -116,6 +116,12 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId [Inject] private ILogger Logger { get; init; } = null!; + [Inject] + private IDialogService DialogService { get; init; } = null!; + + [Inject] + private DataSourceEmbeddingService DataSourceEmbeddingService { get; init; } = null!; + private static readonly Dictionary SPELLCHECK_ATTRIBUTES = new(); /// @@ -293,7 +299,22 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId // When the data is not valid, we don't store it: if (!this.dataIsValid) return; - + + // + // Ask before anything is written. Storing a tokenizer deletes the previous one before it + // copies, and the API key goes into the OS keyring right after, so asking any later would + // leave those changes behind even when the user says no. Saying no also keeps this dialog + // open, which is the point: the value which would have cost the index can be corrected + // right away. + // + // Enterprise-managed providers are left out. Every field which reaches the embedding + // signature is locked for them, and their data sources are not queued for indexing either. + // + if (this.IsEditing && !this.IsEnterpriseConfiguration && !await DataSourceReindexWarning.ConfirmEmbeddingProviderChangeAsync( + this.DialogService, this.SettingsManager, this.DataSourceEmbeddingService, + this.SettingsManager.GetEmbeddingProviderById(this.DataId), this.CreateEmbeddingProviderSettings())) + return; + var response = await this.StoreOrDeleteTokenizerAsync(); if (!response.Success) {