feat(ui): editable task status and tags from details panel
Adds a status ComboBox in the Details header (no transition guards) and a Tags section with chips + AutoCompleteBox. TaskRowViewModel.Tags becomes an ObservableCollection so chip lists stay live. TasksIsland caches AllTags for the row context menu and exposes Set/Toggle helpers. Test fakes updated for the new IWorkerClient methods. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,62 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
||||
public string TaskIdBadge => Task != null ? $"#T{Task.Id[..Math.Min(3, Task.Id.Length)].ToUpperInvariant()}" : "";
|
||||
|
||||
// Agent strip fields
|
||||
// Status editor (Details panel) — set freely; broadcast refreshes other panes.
|
||||
public System.Collections.ObjectModel.ObservableCollection<ClaudeDo.Data.Models.TaskStatus> StatusOptions { get; } = new()
|
||||
{
|
||||
ClaudeDo.Data.Models.TaskStatus.Idle,
|
||||
ClaudeDo.Data.Models.TaskStatus.Queued,
|
||||
ClaudeDo.Data.Models.TaskStatus.Running,
|
||||
ClaudeDo.Data.Models.TaskStatus.Done,
|
||||
ClaudeDo.Data.Models.TaskStatus.Failed,
|
||||
ClaudeDo.Data.Models.TaskStatus.Cancelled,
|
||||
};
|
||||
|
||||
private bool _suppressStatusSave;
|
||||
[ObservableProperty] private ClaudeDo.Data.Models.TaskStatus _selectedStatus;
|
||||
|
||||
partial void OnSelectedStatusChanged(ClaudeDo.Data.Models.TaskStatus value)
|
||||
{
|
||||
if (_suppressStatusSave || Task is null) return;
|
||||
_ = SaveStatusAsync(value);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task SaveStatusAsync(ClaudeDo.Data.Models.TaskStatus value)
|
||||
{
|
||||
if (Task is null) return;
|
||||
try { await _worker.SetTaskStatusAsync(Task.Id, value); }
|
||||
catch { /* offline */ }
|
||||
}
|
||||
|
||||
// Tag editor
|
||||
public ObservableCollection<string> Tags { get; } = new();
|
||||
public ObservableCollection<string> AvailableTags { get; } = new();
|
||||
[ObservableProperty] private string _newTagInput = "";
|
||||
|
||||
[RelayCommand]
|
||||
private async System.Threading.Tasks.Task AddTagAsync()
|
||||
{
|
||||
if (Task is null) return;
|
||||
var name = NewTagInput?.Trim().ToLowerInvariant();
|
||||
NewTagInput = "";
|
||||
if (string.IsNullOrEmpty(name)) return;
|
||||
if (Tags.Contains(name)) return;
|
||||
var next = Tags.ToList();
|
||||
next.Add(name);
|
||||
try { await _worker.SetTaskTagsAsync(Task.Id, next); }
|
||||
catch { /* offline */ }
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async System.Threading.Tasks.Task RemoveTagAsync(string? tagName)
|
||||
{
|
||||
if (Task is null || string.IsNullOrWhiteSpace(tagName)) return;
|
||||
if (!Tags.Contains(tagName)) return;
|
||||
var next = Tags.Where(t => t != tagName).ToList();
|
||||
try { await _worker.SetTaskTagsAsync(Task.Id, next); }
|
||||
catch { /* offline */ }
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(RunNowCommand))]
|
||||
private string _agentStatusLabel = "Idle";
|
||||
@@ -181,6 +237,44 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
||||
// Set by the view so DeleteTaskCommand can show an error message
|
||||
public Func<string, System.Threading.Tasks.Task>? ShowErrorAsync { get; set; }
|
||||
|
||||
private void ApplyTagsFromEntity(ClaudeDo.Data.Models.TaskEntity entity)
|
||||
{
|
||||
Tags.Clear();
|
||||
foreach (var t in entity.Tags) Tags.Add(t.Name);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task RefreshAvailableTagsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var all = await _worker.GetAllTagsAsync();
|
||||
AvailableTags.Clear();
|
||||
foreach (var t in all) AvailableTags.Add(t);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task RefreshTagsAndStatusAsync(string taskId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var ctx = await _dbFactory.CreateDbContextAsync();
|
||||
var entity = await ctx.Tasks
|
||||
.AsNoTracking()
|
||||
.Include(t => t.Tags)
|
||||
.FirstOrDefaultAsync(t => t.Id == taskId);
|
||||
if (entity is null || Task?.Id != taskId) return;
|
||||
|
||||
_suppressStatusSave = true;
|
||||
try { SelectedStatus = entity.Status; }
|
||||
finally { _suppressStatusSave = false; }
|
||||
AgentStatusLabel = entity.Status.ToString();
|
||||
ApplyTagsFromEntity(entity);
|
||||
await RefreshAvailableTagsAsync();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public DetailsIslandViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory, IWorkerClient worker, IServiceProvider services)
|
||||
{
|
||||
_dbFactory = dbFactory;
|
||||
@@ -229,6 +323,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
||||
|
||||
_worker.TaskUpdatedEvent += taskId =>
|
||||
{
|
||||
if (Task?.Id == taskId) _ = RefreshTagsAndStatusAsync(taskId);
|
||||
if (Task?.IsPlanningParent == true) _ = RefreshPlanningChildAsync(taskId);
|
||||
};
|
||||
|
||||
@@ -409,6 +504,12 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
||||
AgentStatusLabel = "Idle";
|
||||
LatestRunSessionId = null;
|
||||
ShowFailedActions = false;
|
||||
Tags.Clear();
|
||||
AvailableTags.Clear();
|
||||
NewTagInput = "";
|
||||
_suppressStatusSave = true;
|
||||
try { SelectedStatus = ClaudeDo.Data.Models.TaskStatus.Idle; }
|
||||
finally { _suppressStatusSave = false; }
|
||||
_suppressAgentSave = true;
|
||||
try
|
||||
{
|
||||
@@ -436,10 +537,11 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
||||
await using var ctx = await _dbFactory.CreateDbContextAsync(ct);
|
||||
var subtaskRepo = new SubtaskRepository(ctx);
|
||||
|
||||
// Own query with Include so WorktreePath/BranchLine are populated.
|
||||
// Own query with Include so WorktreePath/BranchLine/Tags are populated.
|
||||
var entity = await ctx.Tasks
|
||||
.AsNoTracking()
|
||||
.Include(t => t.Worktree)
|
||||
.Include(t => t.Tags)
|
||||
.FirstOrDefaultAsync(t => t.Id == row.Id, ct);
|
||||
ct.ThrowIfCancellationRequested();
|
||||
if (entity == null) return;
|
||||
@@ -455,6 +557,11 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
||||
WorktreeStateLabel = entity.Worktree?.State.ToString();
|
||||
BranchLine = entity.Worktree is { } w ? $"{w.BranchName} \u2190 main" : null;
|
||||
AgentStatusLabel = entity.Status.ToString();
|
||||
_suppressStatusSave = true;
|
||||
try { SelectedStatus = entity.Status; }
|
||||
finally { _suppressStatusSave = false; }
|
||||
ApplyTagsFromEntity(entity);
|
||||
await RefreshAvailableTagsAsync();
|
||||
await LoadAgentSettingsAsync(entity, ct);
|
||||
ct.ThrowIfCancellationRequested();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user