Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
14 changes: 11 additions & 3 deletions TaskTracker.Core.Tests/McpSurfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,18 @@ public void WeeklyReview_Unscoped_OmitsTheLabelKeyEntirely()
}

[Fact]
public void WeeklyReview_RejectsAWindowThatIsNotAWindow()
public void CreateTask_StoresLabelsTheWayTheAppDoes_SoTheReviewFindsThem()
{
var ex = Assert.Throws<ModelContextProtocol.McpException>(() => 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)
Expand Down
21 changes: 21 additions & 0 deletions TaskTracker.Core.Tests/ProjectStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 0 additions & 7 deletions TaskTracker.Core.Tests/ReviewReportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ public void Compute_Days_WidensTheWindow()
Assert.Equal(Now.AddDays(-30), month.FromUtc);
}

[Fact]
public void Compute_Days_RejectsAWindowThatIsNotAWindow()
{
Assert.Throws<ArgumentOutOfRangeException>(
() => ReviewReport.Compute(Array.Empty<ProjectModel>(), Now, days: 0));
}

[Fact]
public void Compute_Days_LongerThanTheCalendarClampsInsteadOfThrowing()
{
Expand Down
7 changes: 4 additions & 3 deletions TaskTracker.Core/Services/BoardFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ public enum DueFilter
/// parameters, so adding a dimension does not ripple through every call site, and
/// so <see cref="IsActive"/> is something the UI can ask rather than re-derive.
/// </summary>
/// <param name="Label">Null or empty matches every task. The "all labels" entry is
/// <param name="Label">Null or blank matches every task; otherwise matched by
/// <see cref="LabelParser.Has"/>. The "all labels" entry is
/// a localized display string, so the caller maps it to null rather than Core
/// knowing about display text.</param>
public record BoardFilter(string? Label = null, DueFilter Due = DueFilter.Any, TaskPriority? Priority = null)
{
public static readonly BoardFilter None = new();

/// <summary>Whether anything is being hidden — drives "showing a subset" affordances.</summary>
public bool IsActive => !string.IsNullOrEmpty(Label) || Due != DueFilter.Any || Priority != null;
public bool IsActive => !string.IsNullOrWhiteSpace(Label) || Due != DueFilter.Any || Priority != null;

/// <param name="today">
/// Local calendar day the due buckets are measured against. Passed in rather than
Expand All @@ -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)
Expand Down
25 changes: 22 additions & 3 deletions TaskTracker.Core/Services/LabelParser.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
namespace TaskTracker.Core.Services
{
/// <summary>
/// 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.
/// </summary>
public static class LabelParser
{
/// <summary>Parses a comma-separated label string into trimmed, distinct labels.</summary>
public static List<string> Parse(string? text) =>
(text ?? "")
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
public static List<string> Parse(string? text) => Normalize(text?.Split(','));

/// <summary>Trimmed, blanks dropped, distinct ignoring case; the first spelling wins.</summary>
public static List<string> Normalize(IEnumerable<string?>? labels) =>
(labels ?? Enumerable.Empty<string?>())
.Select(label => label?.Trim() ?? "")
.Where(label => label.Length > 0)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();

/// <summary>
/// Whether <paramref name="labels"/> carries <paramref name="wanted"/>, ignoring case
/// and surrounding whitespace. A null or blank <paramref name="wanted"/> filters
/// nothing out.
/// </summary>
public static bool Has(IEnumerable<string> labels, string? wanted) =>
string.IsNullOrWhiteSpace(wanted) || labels.Contains(wanted.Trim(), StringComparer.OrdinalIgnoreCase);
}
}
6 changes: 3 additions & 3 deletions TaskTracker.Core/Services/ReviewReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <see cref="BoardFilter"/> uses.
/// whose set of boards is not known in advance. Matched by
/// <see cref="LabelParser.Has"/>, the rule the board and search filter with too.
/// </param>
/// <param name="days">Length of the window ending at <paramref name="nowUtc"/>.</param>
public static WeeklyReviewResult Compute(
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion TaskTracker.Core/Services/TaskSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static List<SearchResult> 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;
Expand Down
16 changes: 14 additions & 2 deletions TaskTracker.Core/Storage/ProjectStore.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using System.Text.Json;
using TaskTracker.Core.Models;
using TaskTracker.Core.Services;

namespace TaskTracker.Core.Storage
{
Expand Down Expand Up @@ -189,11 +190,14 @@ public static void NormalizeColumns(ProjectModel project)
/// <summary>
/// Enforces task-level invariants on every load path, alongside
/// <see cref="NormalizeColumns(StoreData)"/>: 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
/// <see cref="LabelParser.Normalize"/> 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.
/// </summary>
public static void NormalizeTasks(StoreData data)
{
Expand All @@ -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);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion TaskTracker.Mcp/TaskTracker.Mcp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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. -->
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<Description>MCP stdio server for TaskTracker: manage projects, tasks, board columns, checklists, trash and GitHub links from any MCP client.</Description>
<Authors>Sebastian Henn</Authors>
<PackageTags>mcp;tasktracker;claude;model-context-protocol</PackageTags>
Expand Down
6 changes: 3 additions & 3 deletions TaskTracker.Mcp/TaskTrackerTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>())
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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<string>())
foreach (var label in LabelParser.Normalize(labels))
task.Labels.Add(label);
project.Tasks.Add(task);
project.MoveTaskToColumn(task, targetColumn);
Expand Down