From 8ca820b05e9e699a7b563a2e37ff2a0629a5505a Mon Sep 17 00:00:00 2001 From: Doot Agent Date: Sun, 5 Jul 2026 08:22:17 +0000 Subject: fix: native tasks missing from Tasks tab and blank title on completion Bug 1: BuildUnifiedAtomList never called GetNativeTasks(), so doot-sourced tasks were absent from the web Tasks tab. Added GetNativeTasks() fetch and NativeTaskToAtom conversion (new model helper, SourceDoot constant). Bug 2: handleAtomToggle called getAtomDetails after CompleteNativeTask, but GetNativeTasks filters WHERE completed=0, so the task was already gone and the title came back blank. Moved getAtomDetails call to before the completion switch so all sources (including doot) capture title/dueDate first. Also fixed widget_test.go compile error: TestHandleWidgetComplete_NonTodoist called HandleWidgetComplete as a package-level function but it is a method on *Handler. Rewrote the file as package handlers (internal) and construct &Handler{} directly. Regression tests added for both bugs in atoms_test.go and handlers_test.go. Co-Authored-By: Claude Sonnet 4.6 --- internal/handlers/handlers.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'internal/handlers/handlers.go') diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index eaef558..6c74fff 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -607,6 +607,14 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl return } + // Capture title/dueDate before mutating state so doot tasks (which are + // queried with WHERE completed=0) are still findable. + var preTitle string + var preDueDate *time.Time + if complete { + preTitle, preDueDate = h.getAtomDetails(id, source) + } + var err error switch source { case "doot": @@ -658,8 +666,8 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl } if complete { - // Get task details before removing from cache - title, dueDate := h.getAtomDetails(id, source) + // Use pre-fetched details (captured before mutation above). + title, dueDate := preTitle, preDueDate // Log to completed tasks _ = h.store.SaveCompletedTask(source, id, title, dueDate) -- cgit v1.2.3