1
0

refactor: modernize code, improve performance, and clean up various components.

This commit is contained in:
2026-03-01 21:05:35 +01:00
parent 15f9647f8a
commit a6c7df0a71
37 changed files with 240 additions and 627 deletions

View File

@@ -1,6 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Toak.Core;
using Toak.Serialization;
using Toak.Core.Interfaces;
@@ -9,23 +7,19 @@ namespace Toak.Configuration;
public class ConfigManager : IConfigProvider
{
private readonly string ConfigDir = Constants.Paths.ConfigDir;
private readonly string ConfigPath = Constants.Paths.ConfigFile;
public ConfigManager()
{
}
private readonly string _configDir = Constants.Paths.ConfigDir;
private readonly string _configPath = Constants.Paths.ConfigFile;
public ToakConfig LoadConfig()
{
if (!File.Exists(ConfigPath))
if (!File.Exists(_configPath))
{
return new ToakConfig();
}
try
{
var json = File.ReadAllText(ConfigPath);
var json = File.ReadAllText(_configPath);
return JsonSerializer.Deserialize(json, AppJsonSerializerContext.Default.ToakConfig) ?? new ToakConfig();
}
catch (Exception)
@@ -36,12 +30,12 @@ public class ConfigManager : IConfigProvider
public void SaveConfig(ToakConfig config)
{
if (!Directory.Exists(ConfigDir))
if (!Directory.Exists(_configDir))
{
Directory.CreateDirectory(ConfigDir);
Directory.CreateDirectory(_configDir);
}
var json = JsonSerializer.Serialize(config, AppJsonSerializerContext.Default.ToakConfig);
File.WriteAllText(ConfigPath, json);
File.WriteAllText(_configPath, json);
}
}

View File

@@ -12,10 +12,10 @@ public class ToakConfig
public int MinRecordingDuration { get; set; } = 500;
public string WhisperLanguage { get; set; } = string.Empty;
public string LlmModel { get; set; } = Toak.Core.Constants.Defaults.LlmModel;
public string LlmModel { get; set; } = Core.Constants.Defaults.LlmModel;
public string ReasoningEffort { get; set; } = "none"; // none or low
public string WhisperModel { get; set; } = Toak.Core.Constants.Defaults.WhisperModel;
public string WhisperModel { get; set; } = Core.Constants.Defaults.WhisperModel;
public string StartSoundPath { get; set; } = "Assets/Audio/beep.wav";
public string StopSoundPath { get; set; } = "Assets/Audio/beep.wav";
public List<string> ActiveSkills { get; set; } = new List<string> { "Terminal", "Translate" };
public List<string> ActiveSkills { get; set; } = ["Terminal", "Translate"];
}