From 3811efc2dfae61e0153604603c7d060cabb8bbf1 Mon Sep 17 00:00:00 2001 From: Raphael Faouakhiri Date: Fri, 17 Jul 2026 06:09:45 -0300 Subject: [PATCH] fix: record real completion date on materialized occurrences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completing a materialized occurrence wrote the occurrence date (occurrence_date) into completedDate, losing the actual completion date. The parent's complete_instances already tracks which occurrence was fulfilled, so completedDate can record when the user actually completed it — matching non-recurring task behavior. Fixes #2125 (callumalpass/tasknotes) Co-Authored-By: Claude Fable 5 --- src/services/TaskService.ts | 5 ++++- tests/unit/services/task-occurrence-materialization.test.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/TaskService.ts b/src/services/TaskService.ts index 533b325c2..ef36ff494 100644 --- a/src/services/TaskService.ts +++ b/src/services/TaskService.ts @@ -204,7 +204,10 @@ export class TaskService { } private getCompletionDateForTask(task: TaskInfo): string { - return task.occurrence_date || getCurrentDateString(); + // Record the real completion date, matching non-recurring task behavior. + // Which occurrence was fulfilled is tracked separately on the parent's + // complete_instances (see buildMaterializedOccurrenceCompletePlan). #2125 + return getCurrentDateString(); } /** diff --git a/tests/unit/services/task-occurrence-materialization.test.ts b/tests/unit/services/task-occurrence-materialization.test.ts index 36010db8c..31ece205c 100644 --- a/tests/unit/services/task-occurrence-materialization.test.ts +++ b/tests/unit/services/task-occurrence-materialization.test.ts @@ -437,9 +437,12 @@ describe("TaskService materialized occurrences", () => { await taskService.updateProperty(occurrence, "status", "done"); + // completedDate records when the user actually completed the occurrence + // (the mocked "today", 2025-01-01), while the parent's complete_instances + // keeps tracking WHICH occurrence was fulfilled (the occurrence date). expect(frontmatterByPath.get(occurrence.path)).toMatchObject({ status: "done", - completedDate: "2026-06-01", + completedDate: "2025-01-01", }); expect(frontmatterByPath.get(parent.path)).toMatchObject({ complete_instances: ["2026-06-01"],