feat(ui): add RunNowRequestedEvent and GetAgentsAsync to WorkerClient
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,7 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
|
||||
public event Action<string, string>? TaskMessageEvent;
|
||||
public event Action<string>? TaskUpdatedEvent;
|
||||
public event Action<string>? WorktreeUpdatedEvent;
|
||||
public event Action<string>? RunNowRequestedEvent;
|
||||
|
||||
public WorkerClient(string signalRUrl)
|
||||
{
|
||||
@@ -162,6 +163,7 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
|
||||
|
||||
public async Task RunNowAsync(string taskId)
|
||||
{
|
||||
RunNowRequestedEvent?.Invoke(taskId);
|
||||
await _hub.InvokeAsync("RunNow", taskId);
|
||||
}
|
||||
|
||||
@@ -175,6 +177,24 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
|
||||
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()
|
||||
{
|
||||
try
|
||||
@@ -200,7 +220,7 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
|
||||
await _hub.DisposeAsync();
|
||||
}
|
||||
|
||||
// DTO for deserializing the GetActive response
|
||||
// DTOs for deserializing hub responses
|
||||
private sealed class ActiveTaskDto
|
||||
{
|
||||
public string Slot { get; set; } = "";
|
||||
@@ -208,3 +228,5 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable
|
||||
public DateTime StartedAt { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public record AgentInfo(string Name, string Description, string Path);
|
||||
|
||||
Reference in New Issue
Block a user