diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-17 22:46:18 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-17 22:46:18 +0000 |
| commit | be4d606e9a1f5b068abcc21bbac58d1e4705ea1f (patch) | |
| tree | 220aea277125aee4aa35a10201ab0a8a6c1caf89 /internal/handlers/widget.go | |
| parent | 9460b768335dcaf7f89020caf00f1a125de14b20 (diff) | |
Extend chain creation to accept per-task description and priority
CreateChain and POST /api/widget/chains previously only took bare
title strings, with priority hardcoded to 1 -- narrower than the
spec's "an ordered list of task titles/descriptions" API line. Now
accepts []models.ChainTaskInput{Content, Description, Priority} per
position, priority defaulting to 1 when omitted.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ7ikw2ukGJFTHE3bJS7zL
Diffstat (limited to 'internal/handlers/widget.go')
| -rw-r--r-- | internal/handlers/widget.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/handlers/widget.go b/internal/handlers/widget.go index de2e856..a7f7b66 100644 --- a/internal/handlers/widget.go +++ b/internal/handlers/widget.go @@ -963,8 +963,8 @@ func (h *Handler) HandleWidgetLabelsBudgetTracked(w http.ResponseWriter, r *http } type chainCreateRequest struct { - Name string `json:"name"` - Tasks []string `json:"tasks"` + Name string `json:"name"` + Tasks []models.ChainTaskInput `json:"tasks"` } type chainCreateResponse struct { @@ -972,8 +972,9 @@ type chainCreateResponse struct { } // HandleWidgetChainsCreate creates a linear task chain: a backing project -// plus one native_tasks row per title in req.Tasks, position 0 unlocked and -// due now, the rest locked with no due date. +// plus one native_tasks row per entry in req.Tasks (content required; +// description and priority optional, priority defaulting to 1), position 0 +// unlocked and due now, the rest locked with no due date. func (h *Handler) HandleWidgetChainsCreate(w http.ResponseWriter, r *http.Request) { var req chainCreateRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { @@ -984,6 +985,12 @@ func (h *Handler) HandleWidgetChainsCreate(w http.ResponseWriter, r *http.Reques http.Error(w, "name and at least one task are required", http.StatusBadRequest) return } + for _, t := range req.Tasks { + if strings.TrimSpace(t.Content) == "" { + http.Error(w, "every task requires non-empty content", http.StatusBadRequest) + return + } + } chain, err := h.store.CreateChain(req.Name, req.Tasks) if err != nil { http.Error(w, "failed to create chain", http.StatusInternalServerError) |
