feat(ui): reveal a task by id from anywhere
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using ClaudeDo.Data;
|
||||
using ClaudeDo.Data.Repositories;
|
||||
using ClaudeDo.Ui.Helpers;
|
||||
@@ -131,6 +132,16 @@ public sealed partial class TaskMonitorViewModel : ViewModelBase, IDisposable
|
||||
Roadblocks = null;
|
||||
}
|
||||
|
||||
// Set by the host (e.g. Mission Control) to navigate the main app to this task.
|
||||
public Action<string>? OpenInAppRequested { get; set; }
|
||||
|
||||
[RelayCommand]
|
||||
private void OpenInApp()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_subscribedTaskId))
|
||||
OpenInAppRequested?.Invoke(_subscribedTaskId);
|
||||
}
|
||||
|
||||
public void SetTaskId(string id) => _subscribedTaskId = id;
|
||||
|
||||
public void ApplyState(ClaudeDo.Data.Models.TaskStatus status) =>
|
||||
|
||||
@@ -70,6 +70,8 @@ public sealed partial class TasksIslandViewModel : ViewModelBase, IDisposable
|
||||
[ObservableProperty] private bool _showNotesRow;
|
||||
[ObservableProperty] private bool _isMyDayList;
|
||||
|
||||
internal Task? LoadTask { get; private set; }
|
||||
|
||||
public Func<UnfinishedPlanningModalViewModel, Task>? ShowUnfinishedPlanningModal { get; set; }
|
||||
|
||||
private readonly EventHandler _langChangedHandler;
|
||||
@@ -220,14 +222,14 @@ public sealed partial class TasksIslandViewModel : ViewModelBase, IDisposable
|
||||
HasCompleted = false;
|
||||
ShowOpenLabel = false;
|
||||
ShowNotesRow = false;
|
||||
if (list is null) return;
|
||||
if (list is null) { LoadTask = Task.CompletedTask; return; }
|
||||
|
||||
HeaderTitle = list.Name;
|
||||
HeaderEyebrow = DateTime.Now.ToString("dddd · MMM dd", CultureInfo.InvariantCulture).ToUpperInvariant();
|
||||
ShowNotesRow = list.Id == "smart:my-day";
|
||||
IsMyDayList = list.Id == "smart:my-day";
|
||||
|
||||
_ = LoadForListAsync(list, ct);
|
||||
LoadTask = LoadForListAsync(list, ct);
|
||||
}
|
||||
|
||||
private async Task LoadForListAsync(ListNavItemViewModel list, CancellationToken ct)
|
||||
@@ -778,6 +780,18 @@ public sealed partial class TasksIslandViewModel : ViewModelBase, IDisposable
|
||||
[RelayCommand]
|
||||
private void Select(TaskRowViewModel row) => SelectedTask = row;
|
||||
|
||||
public async System.Threading.Tasks.Task<bool> SelectByIdAsync(string taskId)
|
||||
{
|
||||
if (LoadTask is { } lt)
|
||||
{
|
||||
try { await lt; } catch { /* load cancelled/failed — fall through */ }
|
||||
}
|
||||
var row = Items.FirstOrDefault(r => r.Id == taskId);
|
||||
if (row is null) return false;
|
||||
SelectedTask = row;
|
||||
return true;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ToggleShowCompleted() => IsShowingCompleted = !IsShowingCompleted;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user