feat(ui): add RunNowRequestedEvent and GetAgentsAsync to WorkerClient

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mika Kuns
2026-04-14 16:20:39 +02:00
parent a6fe91d106
commit 026df8d8f6

View File

@@ -42,6 +42,7 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
public event Action<string, string>? TaskMessageEvent; public event Action<string, string>? TaskMessageEvent;
public event Action<string>? TaskUpdatedEvent; public event Action<string>? TaskUpdatedEvent;
public event Action<string>? WorktreeUpdatedEvent; public event Action<string>? WorktreeUpdatedEvent;
public event Action<string>? RunNowRequestedEvent;
public WorkerClient(string signalRUrl) public WorkerClient(string signalRUrl)
{ {
@@ -162,6 +163,7 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
public async Task RunNowAsync(string taskId) public async Task RunNowAsync(string taskId)
{ {
RunNowRequestedEvent?.Invoke(taskId);
await _hub.InvokeAsync("RunNow", taskId); await _hub.InvokeAsync("RunNow", taskId);
} }
@@ -175,6 +177,24 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
await _hub.InvokeAsync("WakeQueue"); await _hub.InvokeAsync("WakeQueue");
} }
public async Task<List<AgentInfo>> GetAgentsAsync()
{
try
{
var agents = await _hub.InvokeAsync<List<AgentInfo>>("GetAgents");
return agents ?? [];
}
catch
{
return [];
}
}
public async Task RefreshAgentsAsync()
{
await _hub.InvokeAsync("RefreshAgents");
}
private async Task SeedActiveTasksAsync() private async Task SeedActiveTasksAsync()
{ {
try try
@@ -200,7 +220,7 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
await _hub.DisposeAsync(); await _hub.DisposeAsync();
} }
// DTO for deserializing the GetActive response // DTOs for deserializing hub responses
private sealed class ActiveTaskDto private sealed class ActiveTaskDto
{ {
public string Slot { get; set; } = ""; public string Slot { get; set; } = "";
@@ -208,3 +228,5 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
public DateTime StartedAt { get; set; } public DateTime StartedAt { get; set; }
} }
} }
public record AgentInfo(string Name, string Description, string Path);