1
0

feat: Introduce ITranscriptionOrchestrator and related interfaces, refactoring DaemonService and other components to use dependency injection.

This commit is contained in:
2026-02-28 15:36:03 +01:00
parent ac0ac2397b
commit 0577640da9
18 changed files with 356 additions and 175 deletions

View File

@@ -1,10 +1,19 @@
using System.Diagnostics;
using Toak.Core.Interfaces;
namespace Toak.IO;
public static class ClipboardManager
public class ClipboardManager : IClipboardManager
{
public static void Copy(string text)
private readonly INotifications _notifications;
public ClipboardManager(INotifications notifications)
{
_notifications = notifications;
}
public void Copy(string text)
{
if (string.IsNullOrWhiteSpace(text)) return;
try
@@ -47,7 +56,7 @@ public static class ClipboardManager
catch (Exception ex)
{
Console.WriteLine($"[ClipboardManager] Error copying text: {ex.Message}");
Notifications.Notify("Clipboard Error", "Could not copy text to clipboard.");
_notifications.Notify("Clipboard Error", "Could not copy text to clipboard.");
}
}
}

View File

@@ -1,12 +1,14 @@
using System.Diagnostics;
using Toak.Core.Interfaces;
namespace Toak.IO;
public static class Notifications
public class Notifications : INotifications
{
private static bool _notifySendAvailable = true;
private bool _notifySendAvailable = true;
public static void Notify(string summary, string body = "")
public void Notify(string summary, string body = "")
{
if (!_notifySendAvailable) return;
@@ -32,9 +34,9 @@ public static class Notifications
}
}
private static bool _paplayAvailable = true;
private bool _paplayAvailable = true;
public static void PlaySound(string soundPath)
public void PlaySound(string soundPath)
{
if (!_paplayAvailable || string.IsNullOrWhiteSpace(soundPath)) return;
try

View File

@@ -2,14 +2,23 @@ using System.Diagnostics;
using Toak.Core;
using Toak.Core.Interfaces;
namespace Toak.IO;
public static class TextInjector
public class TextInjector : ITextInjector
{
public static void Inject(string text, string backend)
private readonly INotifications _notifications;
public TextInjector(INotifications notifications)
{
_notifications = notifications;
}
public Task InjectTextAsync(string text, string backend = "xdotool")
{
Logger.LogDebug($"Injecting text: '{text}' with {backend}");
if (string.IsNullOrWhiteSpace(text)) return;
if (string.IsNullOrWhiteSpace(text)) return Task.CompletedTask;
try
{
@@ -42,11 +51,12 @@ public static class TextInjector
catch (Exception ex)
{
Console.WriteLine($"[TextInjector] Error injecting text: {ex.Message}");
Notifications.Notify("Injection Error", "Could not type text into window.");
_notifications.Notify("Injection Error", "Could not type text into window.");
}
return Task.CompletedTask;
}
public static async Task<string> InjectStreamAsync(IAsyncEnumerable<string> tokenStream, string backend)
public async Task<string> InjectStreamAsync(IAsyncEnumerable<string> tokenStream, string backend)
{
string fullText = string.Empty;
try
@@ -97,7 +107,7 @@ public static class TextInjector
catch (Exception ex)
{
Console.WriteLine($"[TextInjector] Error injecting text stream: {ex.Message}");
Notifications.Notify("Injection Error", "Could not type text stream into window.");
_notifications.Notify("Injection Error", "Could not type text stream into window.");
}
return fullText;
}