From 1d2a76f5f476d338735f4257f8b0e26238dc3170 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Wed, 15 Jul 2026 01:38:06 +0000 Subject: fix(agent): restore doot-native task support in Agent API, remove stale test Two independent pre-existing failures, both from incomplete refactors: - agent.go's four task write/create switches (complete/uncomplete, update due date, update details, create) never got a "doot" case added when the Todoist integration was removed (945c345) in favor of native tasks -- the test file was updated to use source=doot, but the handlers themselves still only recognized "trello"/"gtasks", so every native-task Agent API call 400'd with "Unknown source". getAtomDetails already had a "doot" case, confirming this was an incomplete migration, not an intentional gap. - TestMealToAtom in atom_test.go tested MealToAtom, a function removed from atom.go months earlier (b2d8fc4) when meals were dropped from the unified Atom/timeline system; the Meal struct itself is still used elsewhere (shopping/meals feature) but no longer produces atoms, and the test was never cleaned up to match. go test ./internal/... ./cmd/... is now fully green with no failures. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01VTUSAEKfsPc6WGDq45yPHD --- internal/handlers/agent.go | 38 ++++++++++++++++++++++++++++++++++++++ internal/models/atom_test.go | 32 -------------------------------- 2 files changed, 38 insertions(+), 32 deletions(-) (limited to 'internal') diff --git a/internal/handlers/agent.go b/internal/handlers/agent.go index 073084f..cf1eaa1 100644 --- a/internal/handlers/agent.go +++ b/internal/handlers/agent.go @@ -414,6 +414,12 @@ func (h *Handler) handleAgentTaskToggle(w http.ResponseWriter, r *http.Request, var err error ctx := r.Context() switch source { + case "doot": + if complete { + err = h.store.CompleteNativeTask(id) + } else { + err = h.store.UncompleteNativeTask(id) + } case "trello": err = h.trelloClient.UpdateCard(ctx, id, map[string]interface{}{"closed": complete}) case "gtasks": @@ -473,6 +479,12 @@ func (h *Handler) HandleAgentTaskUpdateDue(w http.ResponseWriter, r *http.Reques var err error ctx := r.Context() switch source { + case "doot": + if req.Due == nil { + http.Error(w, "due is required", http.StatusBadRequest) + return + } + err = h.store.RescheduleNativeTask(id, *req.Due) case "trello": err = h.trelloClient.UpdateCard(ctx, id, map[string]interface{}{"due": req.Due}) default: @@ -508,6 +520,20 @@ func (h *Handler) HandleAgentTaskUpdate(w http.ResponseWriter, r *http.Request) var err error ctx := r.Context() switch source { + case "doot": + var existing *models.Task + existing, err = h.store.GetNativeTaskByID(id) + if err == nil { + content := existing.Content + if title, ok := updates["title"].(string); ok { + content = title + } + description := existing.Description + if desc, ok := updates["description"].(string); ok { + description = desc + } + err = h.store.UpdateNativeTask(id, content, description) + } case "trello": if title, ok := updates["title"].(string); ok { updates["name"] = title @@ -560,6 +586,18 @@ func (h *Handler) HandleAgentTaskCreate(w http.ResponseWriter, r *http.Request) var err error ctx := r.Context() switch req.Source { + case "doot": + priority := req.Priority + if priority == 0 { + priority = 1 + } + task := models.Task{ + ID: newID(), + Content: req.Title, + DueDate: req.DueDate, + Priority: priority, + } + err = h.store.CreateNativeTask(task) case "trello": if req.ListID == "" { http.Error(w, "list_id is required for Trello", http.StatusBadRequest) diff --git a/internal/models/atom_test.go b/internal/models/atom_test.go index 6f86949..bedb09c 100644 --- a/internal/models/atom_test.go +++ b/internal/models/atom_test.go @@ -37,38 +37,6 @@ func TestCardToAtom(t *testing.T) { } } -func TestMealToAtom(t *testing.T) { - date := time.Now() - meal := Meal{ - ID: "meal-789", - RecipeName: "Pasta", - MealType: "dinner", - Date: date, - RecipeURL: "https://plantoeat.com/recipe/789", - } - - atom := MealToAtom(meal) - - if atom.ID != "meal-789" { - t.Errorf("Expected ID 'meal-789', got '%s'", atom.ID) - } - if atom.Title != "Pasta" { - t.Errorf("Expected title 'Pasta', got '%s'", atom.Title) - } - if atom.Description != "dinner" { - t.Errorf("Expected description 'dinner', got '%s'", atom.Description) - } - if atom.Source != SourceMeal { - t.Errorf("Expected source Meal, got '%s'", atom.Source) - } - if atom.Type != TypeMeal { - t.Errorf("Expected type Meal, got '%s'", atom.Type) - } - if atom.Priority != 1 { - t.Errorf("Expected priority 1, got %d", atom.Priority) - } -} - func TestAtom_ComputeUIFields(t *testing.T) { // Test nil due date t.Run("nil due date", func(t *testing.T) { -- cgit v1.2.3