diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c600e..e862f23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), background sync imported (or how many arrived). Clicking it opens the affected project. Only background syncs notify; a sync you started reports into the board you are already looking at. - Test coverage for the MCP handlers, which had none despite the documentation claiming otherwise. +- **MCP `weekly_review` can review one effort** instead of everything: `label` scopes every count to + the tasks carrying it and lists only the boards that have one, even boards quiet that week, and + `days` widens the window past 7. ### Fixed @@ -113,6 +116,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), recoverable. - Starting minimised no longer overwrites the saved window placement on exit. - `actions/checkout` and `actions/setup-dotnet` bumped to v5; v4 forced the deprecated Node 20 runtime. +- **A label typed with a stray space could never be found.** The MCP tools stored labels exactly as + given, so `"cartographer "` sat on a task where neither `weekly_review`, `list_tasks` nor search + would match it. Every write path now trims, drops blanks and removes case-insensitive duplicates + the way the app always did, labels already saved that way are cleaned on load, and the board, + search and review all match by the same rule. ## [1.0.0] - 2026-08-06 diff --git a/CLAUDE.md b/CLAUDE.md index 21c4310..6060d1e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,14 +19,14 @@ user-facing feature list and GitHub-sync setup. ``` dotnet build TaskTracker.sln # whole solution -dotnet test TaskTracker.Core.Tests # 419 tests, ~2s +dotnet test TaskTracker.Core.Tests # whole suite, ~2s dotnet test TaskTracker.Core.Tests --filter FullyQualifiedName~ProjectStoreTests # one class dotnet test TaskTracker.Core.Tests --filter "DisplayName~migrates" # one test dotnet format TaskTracker.sln --verify-no-changes # CI gates on this; run before committing dotnet run --project TaskTracker\TaskTracker.csproj # launches the GUI (blocks — run in background) ``` -- Baseline on a clean tree: **0 errors, 0 warnings, 419 tests passing**. Only new warnings are yours. +- Baseline on a clean tree: **0 errors, 0 warnings, every test passing**. Only new warnings and failures are yours. - `Core` and `Mcp` build with `TreatWarningsAsErrors`; the WPF head does not, but is warning-free — keep it that way. - New files written by tooling often lack the UTF-8 BOM the rest of the tree has, and `dotnet format` adds it. Run the format check before committing or CI fails on files that compile fine. diff --git a/README.md b/README.md index fd29d6a..982afb2 100644 --- a/README.md +++ b/README.md @@ -254,7 +254,7 @@ CI fails a pull request that changes the server or Core without bumping ## Verification status Core logic (storage, board projection, filtering, trash, bulk actions, sync, -search, stats, agenda, cross-project moves, MCP handlers) is covered by 419 +search, stats, agenda, cross-project moves, MCP handlers) is covered by unit tests and runs on any OS. CI builds the whole solution on Linux, runs those tests, and gates on `dotnet format`. diff --git a/TaskTracker.Core.Tests/McpSurfaceTests.cs b/TaskTracker.Core.Tests/McpSurfaceTests.cs index eed6d0b..8847823 100644 --- a/TaskTracker.Core.Tests/McpSurfaceTests.cs +++ b/TaskTracker.Core.Tests/McpSurfaceTests.cs @@ -417,10 +417,18 @@ public void WeeklyReview_Unscoped_OmitsTheLabelKeyEntirely() } [Fact] - public void WeeklyReview_RejectsAWindowThatIsNotAWindow() + public void CreateTask_StoresLabelsTheWayTheAppDoes_SoTheReviewFindsThem() { - var ex = Assert.Throws(() => TaskTrackerTools.WeeklyReview(days: 0)); - Assert.Contains("days", ex.Message); + // The MCP tools used to store labels exactly as typed, so a stray space made a + // label no filter could match: weekly_review trimmed the label it was asked for, + // but the stored one still had its space. + var project = Seed(0); + + var created = Parse(TaskTrackerTools.CreateTask(project.Id.ToString(), "port the analyzer", labels: [" cartographer ", " "])); + + Assert.Equal(new[] { "cartographer" }, created.GetProperty("Labels").EnumerateArray().Select(l => l.GetString())); + var review = Parse(TaskTrackerTools.WeeklyReview(label: "cartographer")); + Assert.Equal("P", review.GetProperty("Projects")[0].GetProperty("ProjectName").GetString()); } private void SeedNamed(string projectName, params (string Title, string? Label)[] tasks) diff --git a/TaskTracker.Core.Tests/ProjectStoreTests.cs b/TaskTracker.Core.Tests/ProjectStoreTests.cs index 900a2a4..f0b9cc3 100644 --- a/TaskTracker.Core.Tests/ProjectStoreTests.cs +++ b/TaskTracker.Core.Tests/ProjectStoreTests.cs @@ -359,4 +359,25 @@ public void Load_NormalizesAnUnknownRecurrence() Assert.False(task.IsRecurring); Assert.Equal(1, task.RecurrenceInterval); } + + [Fact] + public void Load_CleansLabelsSavedBeforeEveryPathNormalizedThem() + { + // The MCP tools stored labels as typed, so existing files can hold "cartographer " + // next to "Cartographer", and no filter matches the spaced one. + var json = $$""" + { + "version": 2, + "revision": "{{Guid.NewGuid()}}", + "projects": [ + { "Name": "P", "Tasks": [ { "Id": "{{Guid.NewGuid()}}", "Title": "T", "Labels": [ "cartographer ", " ", "Cartographer" ] } ] } + ] + } + """; + File.WriteAllText(Path.Combine(_dir, "Save.json"), json); + + var task = NewStore().Load().Projects[0].Tasks[0]; + + Assert.Equal(new[] { "cartographer" }, task.Labels); + } } diff --git a/TaskTracker.Core.Tests/ReviewReportTests.cs b/TaskTracker.Core.Tests/ReviewReportTests.cs index 770970b..37fd4ae 100644 --- a/TaskTracker.Core.Tests/ReviewReportTests.cs +++ b/TaskTracker.Core.Tests/ReviewReportTests.cs @@ -149,13 +149,6 @@ public void Compute_Days_WidensTheWindow() Assert.Equal(Now.AddDays(-30), month.FromUtc); } - [Fact] - public void Compute_Days_RejectsAWindowThatIsNotAWindow() - { - Assert.Throws( - () => ReviewReport.Compute(Array.Empty(), Now, days: 0)); - } - [Fact] public void Compute_Days_LongerThanTheCalendarClampsInsteadOfThrowing() { diff --git a/TaskTracker.Core/Services/BoardFilter.cs b/TaskTracker.Core/Services/BoardFilter.cs index 4b4ca51..312a051 100644 --- a/TaskTracker.Core/Services/BoardFilter.cs +++ b/TaskTracker.Core/Services/BoardFilter.cs @@ -25,7 +25,8 @@ public enum DueFilter /// parameters, so adding a dimension does not ripple through every call site, and /// so is something the UI can ask rather than re-derive. /// - /// Null or empty matches every task. The "all labels" entry is + /// Null or blank matches every task; otherwise matched by + /// . The "all labels" entry is /// a localized display string, so the caller maps it to null rather than Core /// knowing about display text. public record BoardFilter(string? Label = null, DueFilter Due = DueFilter.Any, TaskPriority? Priority = null) @@ -33,7 +34,7 @@ public record BoardFilter(string? Label = null, DueFilter Due = DueFilter.Any, T public static readonly BoardFilter None = new(); /// Whether anything is being hidden — drives "showing a subset" affordances. - public bool IsActive => !string.IsNullOrEmpty(Label) || Due != DueFilter.Any || Priority != null; + public bool IsActive => !string.IsNullOrWhiteSpace(Label) || Due != DueFilter.Any || Priority != null; /// /// Local calendar day the due buckets are measured against. Passed in rather than @@ -44,7 +45,7 @@ public bool Matches(TaskModel task, DateTime today) { ArgumentNullException.ThrowIfNull(task); - if (!string.IsNullOrEmpty(Label) && !task.Labels.Contains(Label, StringComparer.OrdinalIgnoreCase)) + if (!LabelParser.Has(task.Labels, Label)) return false; if (Priority != null && task.Priority != Priority) diff --git a/TaskTracker.Core/Services/LabelParser.cs b/TaskTracker.Core/Services/LabelParser.cs index 82bc2bd..34b3559 100644 --- a/TaskTracker.Core/Services/LabelParser.cs +++ b/TaskTracker.Core/Services/LabelParser.cs @@ -1,12 +1,31 @@ namespace TaskTracker.Core.Services { + /// + /// The one rule for what a stored label looks like and when a task carries one. Every + /// path that writes labels (the app's text boxes, the MCP tools, loading a save file) + /// and every filter that reads them (board, search, weekly review) goes through here, + /// so a label typed with a stray space can't be stored in one shape and looked up in + /// another. + /// public static class LabelParser { /// Parses a comma-separated label string into trimmed, distinct labels. - public static List Parse(string? text) => - (text ?? "") - .Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) + public static List Parse(string? text) => Normalize(text?.Split(',')); + + /// Trimmed, blanks dropped, distinct ignoring case; the first spelling wins. + public static List Normalize(IEnumerable? labels) => + (labels ?? Enumerable.Empty()) + .Select(label => label?.Trim() ?? "") + .Where(label => label.Length > 0) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); + + /// + /// Whether carries , ignoring case + /// and surrounding whitespace. A null or blank filters + /// nothing out. + /// + public static bool Has(IEnumerable labels, string? wanted) => + string.IsNullOrWhiteSpace(wanted) || labels.Contains(wanted.Trim(), StringComparer.OrdinalIgnoreCase); } } diff --git a/TaskTracker.Core/Services/ReviewReport.cs b/TaskTracker.Core/Services/ReviewReport.cs index bce5a7d..673386c 100644 --- a/TaskTracker.Core/Services/ReviewReport.cs +++ b/TaskTracker.Core/Services/ReviewReport.cs @@ -32,8 +32,8 @@ public static class ReviewReport /// When set, every count and title below is measured over only the tasks carrying /// it, and a project is listed if it has any such task at all. This is the one /// report that crosses projects, so a label is the only way to ask about an effort - /// whose set of boards is not known in advance. Matched case-insensitively, the - /// same rule uses. + /// whose set of boards is not known in advance. Matched by + /// , the rule the board and search filter with too. /// /// Length of the window ending at . public static WeeklyReviewResult Compute( @@ -56,7 +56,7 @@ public static WeeklyReviewResult Compute( { var tasks = scoped == null ? project.Tasks.ToList() - : project.Tasks.Where(t => t.Labels.Contains(scoped, StringComparer.OrdinalIgnoreCase)).ToList(); + : project.Tasks.Where(t => LabelParser.Has(t.Labels, scoped)).ToList(); var completed = tasks .Where(t => t.CompletedAtUtc >= from && t.CompletedAtUtc <= to) diff --git a/TaskTracker.Core/Services/TaskSearch.cs b/TaskTracker.Core/Services/TaskSearch.cs index 9a409c6..c82f7e6 100644 --- a/TaskTracker.Core/Services/TaskSearch.cs +++ b/TaskTracker.Core/Services/TaskSearch.cs @@ -29,7 +29,7 @@ public static List Search( { if (!includeDone && task.IsDone) continue; - if (label != null && !task.Labels.Contains(label, StringComparer.OrdinalIgnoreCase)) + if (!LabelParser.Has(task.Labels, label)) continue; if (trimmed.Length > 0 && !Matches(task, trimmed)) continue; diff --git a/TaskTracker.Core/Storage/ProjectStore.cs b/TaskTracker.Core/Storage/ProjectStore.cs index 871130f..d6dda45 100644 --- a/TaskTracker.Core/Storage/ProjectStore.cs +++ b/TaskTracker.Core/Storage/ProjectStore.cs @@ -1,6 +1,7 @@ using System.Collections.ObjectModel; using System.Text.Json; using TaskTracker.Core.Models; +using TaskTracker.Core.Services; namespace TaskTracker.Core.Storage { @@ -189,11 +190,14 @@ public static void NormalizeColumns(ProjectModel project) /// /// Enforces task-level invariants on every load path, alongside /// : an unrecognised recurrence string - /// becomes "none", and the interval is at least 1. + /// becomes "none", the interval is at least 1, and labels take the shape + /// gives them. /// /// Without this, a hand-edited or externally written recurrence value leaves the /// task reporting IsRecurring while Recurrence.SpawnNextIfRecurring refuses to - /// spawn — a recurring task that silently never recurs. + /// spawn — a recurring task that silently never recurs. Labels stored before every + /// write path normalized them (the MCP tools kept them as typed) carry stray spaces + /// that no filter would match. /// public static void NormalizeTasks(StoreData data) { @@ -208,6 +212,14 @@ public static void NormalizeTasks(ProjectModel project) task.Recurrence = RecurrenceRules.Normalize(task.Recurrence); if (task.RecurrenceInterval < 1) task.RecurrenceInterval = 1; + + var labels = LabelParser.Normalize(task.Labels); + if (!labels.SequenceEqual(task.Labels)) + { + task.Labels.Clear(); + foreach (var label in labels) + task.Labels.Add(label); + } } } diff --git a/TaskTracker.Mcp/TaskTracker.Mcp.csproj b/TaskTracker.Mcp/TaskTracker.Mcp.csproj index 1ed58f1..0e5f986 100644 --- a/TaskTracker.Mcp/TaskTracker.Mcp.csproj +++ b/TaskTracker.Mcp/TaskTracker.Mcp.csproj @@ -40,7 +40,7 @@ version, so forgetting leaves users on old code with no signal. Major for a removed/renamed tool or a changed response shape, minor for a new tool, patch for a fix. store_info reports the running value. --> - 2.1.0 + 2.1.1 MCP stdio server for TaskTracker: manage projects, tasks, board columns, checklists, trash and GitHub links from any MCP client. Sebastian Henn mcp;tasktracker;claude;model-context-protocol diff --git a/TaskTracker.Mcp/TaskTrackerTools.cs b/TaskTracker.Mcp/TaskTrackerTools.cs index 8dfdc1c..edfc519 100644 --- a/TaskTracker.Mcp/TaskTrackerTools.cs +++ b/TaskTracker.Mcp/TaskTrackerTools.cs @@ -258,7 +258,7 @@ public static string CreateTask( Priority = priority == null ? TaskPriority.Medium : ParsePriority(priority), CreatedAtUtc = DateTime.UtcNow, }; - foreach (var label in labels ?? Array.Empty()) + foreach (var label in LabelParser.Normalize(labels)) created.Labels.Add(label); project.Tasks.Add(created); project.MoveTaskToColumn(created, column == null ? project.FirstColumn! : FindColumn(project, column)); @@ -308,7 +308,7 @@ public static string UpdateTask( if (labels != null) { task.Labels.Clear(); - foreach (var label in labels) + foreach (var label in LabelParser.Normalize(labels)) task.Labels.Add(label); } updated = task; @@ -382,7 +382,7 @@ public static string CreateTasks( Priority = priority == null ? TaskPriority.Medium : ParsePriority(priority), CreatedAtUtc = DateTime.UtcNow, }; - foreach (var label in labels ?? Array.Empty()) + foreach (var label in LabelParser.Normalize(labels)) task.Labels.Add(label); project.Tasks.Add(task); project.MoveTaskToColumn(task, targetColumn);