From 82629feee5f3a8531f45a5db5bf466d793e8582d Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Sat, 7 Mar 2026 13:21:36 +0530 Subject: [PATCH] fix(tw): fix double date formatting and annotation condition in edit_task.go - Only append T00:00:00 to wait/due fields when the value is a date-only string (no existing 'T'). Full ISO datetimes already formatted by the controller were being corrupted to e.g. '2026-01-28T14:30:00T00:00:00'. - Change len(annotations) >= 0 to len(annotations) > 0. The previous condition was always true, causing the export/denotate/re-annotate block to run on every edit even when no annotations were provided, silently destroying and re-creating all existing task annotations unnecessarily. --- backend/utils/tw/edit_task.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/utils/tw/edit_task.go b/backend/utils/tw/edit_task.go index 59a49054..b944e418 100644 --- a/backend/utils/tw/edit_task.go +++ b/backend/utils/tw/edit_task.go @@ -40,7 +40,10 @@ func EditTaskInTaskwarrior( } if wait != "" { - formattedWait := wait + "T00:00:00" + formattedWait := wait + if !strings.Contains(wait, "T") { + formattedWait = wait + "T00:00:00" + } modifyArgs = append(modifyArgs, "wait:"+formattedWait) } @@ -60,7 +63,10 @@ func EditTaskInTaskwarrior( modifyArgs = append(modifyArgs, "depends:"+dependsStr) if due != "" { - formattedDue := due + "T00:00:00" + formattedDue := due + if !strings.Contains(due, "T") { + formattedDue = due + "T00:00:00" + } modifyArgs = append(modifyArgs, "due:"+formattedDue) } @@ -82,7 +88,7 @@ func EditTaskInTaskwarrior( return fmt.Errorf("failed to edit task: %v", err) } - if len(annotations) >= 0 { + if len(annotations) > 0 { output, err := utils.ExecCommandForOutputInDir(tempDir, "task", taskUUID, "export") if err == nil { var tasks []map[string]interface{}