From 57401badbd422d69cff7b3793f33a324548254c1 Mon Sep 17 00:00:00 2001 From: Eshaan Date: Sun, 16 Nov 2025 22:34:32 +1100 Subject: [PATCH 1/2] Add start (scheduled) field to Add Task feature - Add start date field to frontend Add Task dialog (desktop & mobile) - Update newTask state to include start field - Update addTaskToBackend API call with start parameter - Add Start field to backend AddTaskRequestBody model - Update AddTaskHandler to extract and pass start field - Update AddTaskToTaskwarrior to include scheduled date in taskwarrior command - Use 'scheduled' attribute in taskwarrior (maps to start date) - Start field is optional and only added if provided Implements #188 (Start field) --- backend/controllers/add_task.go | 3 +- backend/models/request_body.go | 1 + backend/utils/tw/add_task.go | 5 +- .../components/HomeComponents/Tasks/Tasks.tsx | 52 +++++++++++++++++++ .../components/HomeComponents/Tasks/hooks.ts | 3 ++ 5 files changed, 62 insertions(+), 2 deletions(-) diff --git a/backend/controllers/add_task.go b/backend/controllers/add_task.go index 6c6a0aac..6fae32ed 100644 --- a/backend/controllers/add_task.go +++ b/backend/controllers/add_task.go @@ -46,6 +46,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) { project := requestBody.Project priority := requestBody.Priority dueDate := requestBody.DueDate + start := requestBody.Start tags := requestBody.Tags if description == "" { @@ -62,7 +63,7 @@ func AddTaskHandler(w http.ResponseWriter, r *http.Request) { Name: "Add Task", Execute: func() error { logStore.AddLog("INFO", fmt.Sprintf("Adding task: %s", description), uuid, "Add Task") - err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, tags) + err := tw.AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start, tags) if err != nil { logStore.AddLog("ERROR", fmt.Sprintf("Failed to add task: %v", err), uuid, "Add Task") return err diff --git a/backend/models/request_body.go b/backend/models/request_body.go index 725a6075..0bf8c703 100644 --- a/backend/models/request_body.go +++ b/backend/models/request_body.go @@ -9,6 +9,7 @@ type AddTaskRequestBody struct { Project string `json:"project"` Priority string `json:"priority"` DueDate string `json:"due"` + Start string `json:"start"` Tags []string `json:"tags"` } type ModifyTaskRequestBody struct { diff --git a/backend/utils/tw/add_task.go b/backend/utils/tw/add_task.go index 16105f7b..b6bfa77b 100644 --- a/backend/utils/tw/add_task.go +++ b/backend/utils/tw/add_task.go @@ -8,7 +8,7 @@ import ( ) // add task to the user's tw client -func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate string, tags []string) error { +func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, priority, dueDate, start string, tags []string) error { if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil { return fmt.Errorf("error deleting Taskwarrior data: %v", err) } @@ -38,6 +38,9 @@ func AddTaskToTaskwarrior(email, encryptionSecret, uuid, description, project, p if dueDate != "" { cmdArgs = append(cmdArgs, "due:"+dueDate) } + if start != "" { + cmdArgs = append(cmdArgs, "scheduled:"+start) + } // Add tags to the task if len(tags) > 0 { for _, tag := range tags { diff --git a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx index 140288db..a65c659d 100644 --- a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx +++ b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx @@ -99,6 +99,7 @@ export const Tasks = ( priority: '', project: '', due: '', + start: '', tags: [] as string[], }); const [isAddTaskOpen, setIsAddTaskOpen] = useState(false); @@ -280,6 +281,7 @@ export const Tasks = ( project: string, priority: string, due: string, + start: string, tags: string[] ) { if (handleDate(newTask.due)) { @@ -292,6 +294,7 @@ export const Tasks = ( project, priority, due, + start, tags, backendURL: url.backendURL, }); @@ -302,6 +305,7 @@ export const Tasks = ( priority: '', project: '', due: '', + start: '', tags: [], }); setIsAddTaskOpen(false); @@ -738,6 +742,29 @@ export const Tasks = ( /> +
+ +
+ { + setNewTask({ + ...newTask, + start: date + ? format(date, 'yyyy-MM-dd') + : '', + }); + }} + placeholder="Select a start date" + /> +
+
+
+ +
+ { + setNewTask({ + ...newTask, + start: date + ? format(date, 'yyyy-MM-dd') + : '', + }); + }} + placeholder="Select a start date" + /> +
+
+ + ))} + + )} +