feat: improve CLI output with relative dates, rich feedback, and recurring task info

Add relative date formatting (today, tomorrow, in 3d, etc.) for list and
detail views. Add structured feedback helpers for add/complete/delete
operations showing display IDs and parsed modifiers. Change Complete() to
return spawned recurring instance so callers can display recurrence info.
Add AppendTask to working set for immediate display ID assignment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 13:44:56 +01:00
parent 779da6ddfd
commit b02c40f716
14 changed files with 323 additions and 48 deletions
+29
View File
@@ -142,3 +142,32 @@ func (ws *WorkingSet) GetTasks() []*Task {
func (ws *WorkingSet) Size() int {
return len(ws.byID)
}
// ByID returns the display_id -> UUID mapping.
func (ws *WorkingSet) ByID() map[int]uuid.UUID {
return ws.byID
}
// AppendTask inserts a task into the working set at MAX(display_id) + 1.
// Returns the assigned display ID. The ID is valid until the next report
// render, at which point the entire working set is rebuilt.
func AppendTask(task *Task) (int, error) {
db := GetDB()
if db == nil {
return 0, fmt.Errorf("database not initialized")
}
var maxID int
err := db.QueryRow("SELECT COALESCE(MAX(display_id), 0) FROM working_set").Scan(&maxID)
if err != nil {
return 0, fmt.Errorf("failed to query max display_id: %w", err)
}
newID := maxID + 1
_, err = db.Exec("INSERT INTO working_set (display_id, task_uuid) VALUES (?, ?)", newID, task.UUID.String())
if err != nil {
return 0, fmt.Errorf("failed to append to working set: %w", err)
}
return newID, nil
}