Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d02d6b5
Add enterprise config support via env vars & Windows registry
SommerEngineering May 31, 2025
ea3271b
Fixed the Unix implementation
SommerEngineering May 31, 2025
1fb04a7
Refactor enterprise config functions to return String instead of Option
SommerEngineering May 31, 2025
86f5255
Fixed config plugins action column
SommerEngineering Jun 1, 2025
f4b2038
Added delete endpoint for enterprise config ID
SommerEngineering Jun 1, 2025
ed006f3
Added SettingsLocker service and implementation
SommerEngineering Jun 1, 2025
03bf288
Refactor TemporaryChatService for cleaner logging and improvements
SommerEngineering Jun 1, 2025
944f4a8
Add method to remove enterprise config ID
SommerEngineering Jun 1, 2025
72ea91d
Add EnterpriseEnvironmentService and plugin management
SommerEngineering Jun 1, 2025
3f97264
Disable update frequency when locked via SettingsLocker
SommerEngineering Jun 1, 2025
f1fcae3
Inject SettingsLocker into SettingsPanelBase
SommerEngineering Jun 1, 2025
ab84cf1
Add enterprise configuration handling in SettingsPanelProviders
SommerEngineering Jun 1, 2025
9404e83
Manage IsEnterpriseConfiguration for manual providers
SommerEngineering Jun 1, 2025
c320d05
Add enterprise environment details to About page
SommerEngineering Jun 1, 2025
fa48dd8
Added example config plugin
SommerEngineering Jun 1, 2025
a44eaa4
Update IsPluginEnabled to include configuration plugins
SommerEngineering Jun 1, 2025
28484da
Added config plugin class
SommerEngineering Jun 1, 2025
d51093b
Remove enterprise environment configuration logging
SommerEngineering Jun 1, 2025
e1478d9
Mark configuration plugins as partially implemented
SommerEngineering Jun 1, 2025
7903f13
Add enterprise config plugin support in Provider
SommerEngineering Jun 1, 2025
85fcb4a
Refactor hot reload system to improve event handling & monitor delete…
SommerEngineering Jun 1, 2025
f1d0549
Log warning on plugin load cancellation due to timeout
SommerEngineering Jun 1, 2025
e573b4d
Remove unavailable enterprise configuration plugins and reset related…
SommerEngineering Jun 1, 2025
0077875
Add support for configuration plugins in PluginFactory
SommerEngineering Jun 1, 2025
83d7ab6
Refactored startup code of the plugin factory & handle config plugins…
SommerEngineering Jun 1, 2025
a8d96c9
Add EnterpriseEnvironment record struct to manage configuration state
SommerEngineering Jun 1, 2025
98aaea4
Updated I18M
SommerEngineering Jun 1, 2025
441cc0f
Updated changelog
SommerEngineering Jun 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added SettingsLocker service and implementation
  • Loading branch information
SommerEngineering committed Jun 1, 2025
commit ed006f3a4b12ef0f690cd66f6e210791f3364f66
1 change: 1 addition & 0 deletions app/MindWork AI Studio/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static async Task Main()
builder.Services.AddSingleton<SettingsManager>();
builder.Services.AddSingleton<ThreadSafeRandom>();
builder.Services.AddSingleton<DataSourceService>();
builder.Services.AddSingleton<SettingsLocker>();
builder.Services.AddTransient<HTMLParser>();
builder.Services.AddTransient<AgentDataSourceSelection>();
builder.Services.AddTransient<AgentRetrievalContextValidation>();
Expand Down
78 changes: 78 additions & 0 deletions app/MindWork AI Studio/Settings/SettingsLocker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System.Linq.Expressions;

namespace AIStudio.Settings;

public sealed class SettingsLocker
{
private static readonly ILogger<SettingsLocker> LOGGER = Program.LOGGER_FACTORY.CreateLogger<SettingsLocker>();
private readonly Dictionary<string, Dictionary<string, Guid>> lockedProperties = new();

public void Register<T>(Expression<Func<T, object>> propertyExpression, Guid configurationPluginId)
{
var memberExpression = GetMemberExpression(propertyExpression);
var className = typeof(T).Name;
var propertyName = memberExpression.Member.Name;

if (!this.lockedProperties.ContainsKey(className))
this.lockedProperties[className] = [];

this.lockedProperties[className].TryAdd(propertyName, configurationPluginId);
}

public void Remove<T>(Expression<Func<T, object>> propertyExpression)
{
var memberExpression = GetMemberExpression(propertyExpression);
var className = typeof(T).Name;
var propertyName = memberExpression.Member.Name;

if (this.lockedProperties.TryGetValue(className, out var props))
{
if (props.Remove(propertyName))
{
// If the property was removed, check if the class has no more locked properties:
if (props.Count == 0)
this.lockedProperties.Remove(className);
}
}
}

public Guid GetConfigurationPluginId<T>(Expression<Func<T, object>> propertyExpression)
{
var memberExpression = GetMemberExpression(propertyExpression);
var className = typeof(T).Name;
var propertyName = memberExpression.Member.Name;

if (this.lockedProperties.TryGetValue(className, out var props) && props.TryGetValue(propertyName, out var configurationPluginId))
return configurationPluginId;

// No configuration plugin ID found for this property:
return Guid.Empty;
}

public bool IsLocked<T>(Expression<Func<T, object>> propertyExpression)
{
var memberExpression = GetMemberExpression(propertyExpression);
var className = typeof(T).Name;
var propertyName = memberExpression.Member.Name;

return this.lockedProperties.TryGetValue(className, out var props) && props.ContainsKey(propertyName);
}

private static MemberExpression GetMemberExpression<T>(Expression<Func<T, object>> expression)
{
switch (expression.Body)
{
// Case for value types, which are wrapped in UnaryExpression:
case UnaryExpression { NodeType: ExpressionType.Convert } unaryExpression:
return (MemberExpression)unaryExpression.Operand;

// Case for reference types, which are directly MemberExpressions:
case MemberExpression memberExpression:
return memberExpression;

default:
LOGGER.LogError($"Expression '{expression}' is not a valid property expression.");
throw new ArgumentException($"Expression '{expression}' is not a valid property expression.", nameof(expression));
}
}
}
1 change: 1 addition & 0 deletions app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public static partial class PluginFactory
{
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PluginFactory));
private static readonly SettingsManager SETTINGS_MANAGER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
private static readonly SettingsLocker SETTINGS_LOCKER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsLocker>();

private static bool IS_INITIALIZED;
private static string DATA_DIR = string.Empty;
Expand Down