using ClaudeDo.Data.Models;
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;

namespace ClaudeDo.Data.Filtering.Filters;

/// <summary>
/// Virtual list filter matching tasks by a single status (Queued, Running).
/// Planning parents appear contextually when they host a matching child.
/// </summary>
public sealed class StatusFilter(string id, TaskStatus status) : ITaskListFilter
{
    public string Id => id;
    public bool Matches(TaskEntity t) => t.Status == status;
    public bool ShouldCount(TaskEntity t) => t.Status == status;
    public bool MatchesAsContext(TaskEntity t, IReadOnlyList<TaskEntity> all) =>
        PlanningRules.IsPlanningParent(t) &&
        PlanningRules.HasMatchingChild(t, all, c => c.Status == status);
}
