refactor(config): consolidate permission modes into PermissionModeRegistry
Also fixes WorkerHub.UpdateAppSettings falling back to "bypassPermissions" when AppSettingsEntity and the runtime default are "auto". The fallback now matches the entity default.
This commit is contained in:
11
src/ClaudeDo.Data/Models/PermissionModeRegistry.cs
Normal file
11
src/ClaudeDo.Data/Models/PermissionModeRegistry.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace ClaudeDo.Data.Models;
|
||||||
|
|
||||||
|
public static class PermissionModeRegistry
|
||||||
|
{
|
||||||
|
public static readonly IReadOnlyList<string> Modes = new[]
|
||||||
|
{
|
||||||
|
"auto", "bypassPermissions", "acceptEdits", "plan", "default",
|
||||||
|
};
|
||||||
|
|
||||||
|
public const string DefaultMode = "auto";
|
||||||
|
}
|
||||||
@@ -8,11 +8,10 @@ public sealed partial class GeneralSettingsTabViewModel : ViewModelBase
|
|||||||
[ObservableProperty] private string _defaultClaudeInstructions = "";
|
[ObservableProperty] private string _defaultClaudeInstructions = "";
|
||||||
[ObservableProperty] private string _defaultModel = ModelRegistry.DefaultAlias;
|
[ObservableProperty] private string _defaultModel = ModelRegistry.DefaultAlias;
|
||||||
[ObservableProperty] private int _defaultMaxTurns = 100;
|
[ObservableProperty] private int _defaultMaxTurns = 100;
|
||||||
[ObservableProperty] private string _defaultPermissionMode = "auto";
|
[ObservableProperty] private string _defaultPermissionMode = PermissionModeRegistry.DefaultMode;
|
||||||
|
|
||||||
public IReadOnlyList<string> Models { get; } = ModelRegistry.Aliases;
|
public IReadOnlyList<string> Models { get; } = ModelRegistry.Aliases;
|
||||||
public IReadOnlyList<string> PermissionModes { get; } = new[]
|
public IReadOnlyList<string> PermissionModes { get; } = PermissionModeRegistry.Modes;
|
||||||
{ "auto", "bypassPermissions", "acceptEdits", "plan", "default" };
|
|
||||||
|
|
||||||
public string? Validate()
|
public string? Validate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
|
|||||||
DefaultClaudeInstructions = dto.DefaultClaudeInstructions ?? "",
|
DefaultClaudeInstructions = dto.DefaultClaudeInstructions ?? "",
|
||||||
DefaultModel = dto.DefaultModel ?? ModelRegistry.DefaultAlias,
|
DefaultModel = dto.DefaultModel ?? ModelRegistry.DefaultAlias,
|
||||||
DefaultMaxTurns = dto.DefaultMaxTurns,
|
DefaultMaxTurns = dto.DefaultMaxTurns,
|
||||||
DefaultPermissionMode = dto.DefaultPermissionMode ?? "bypassPermissions",
|
DefaultPermissionMode = dto.DefaultPermissionMode ?? PermissionModeRegistry.DefaultMode,
|
||||||
WorktreeStrategy = dto.WorktreeStrategy ?? "sibling",
|
WorktreeStrategy = dto.WorktreeStrategy ?? "sibling",
|
||||||
CentralWorktreeRoot = dto.CentralWorktreeRoot,
|
CentralWorktreeRoot = dto.CentralWorktreeRoot,
|
||||||
WorktreeAutoCleanupEnabled = dto.WorktreeAutoCleanupEnabled,
|
WorktreeAutoCleanupEnabled = dto.WorktreeAutoCleanupEnabled,
|
||||||
|
|||||||
Reference in New Issue
Block a user