summaryrefslogtreecommitdiff
path: root/Omni/Task
diff options
context:
space:
mode:
authorOmni Worker <bot@omni.agent>2025-11-22 05:55:10 -0500
committerBen Sima <ben@bensima.com>2025-11-22 12:46:07 -0500
commit7c649a257aa79f01bcaf989191a065acf8105132 (patch)
tree840bf87ce42111e36c5b8e5441ddffa8617f3dcd /Omni/Task
parent1fcf654b30c5ca9e1d680805df40435e6fe20e4e (diff)
Implement task edit command
Amp-Thread-ID: https://ampcode.com/threads/T-a65df310-235f-4d63-9f78-4affc537b80b Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Task')
-rw-r--r--Omni/Task/Core.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index b17c2aa..58744fa 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -377,6 +377,34 @@ updateTaskStatus tid newStatus newDeps =
TIO.writeFile tasksFile ""
traverse_ saveTaskInternal updatedTasks
+-- Edit a task by applying a modification function
+editTask :: Text -> (Task -> Task) -> IO Task
+editTask tid modifyFn =
+ withTaskWriteLock <| do
+ tasks <- loadTasksInternal
+ now <- getCurrentTime
+
+ -- Find the task first to ensure it exists
+ case findTask tid tasks of
+ Nothing -> panic "Task not found"
+ Just original -> do
+ let modified = modifyFn original
+ -- Only update timestamp if something actually changed
+ -- But for simplicity, we always update it if the user explicitly ran 'edit'
+ finalTask = modified {taskUpdatedAt = now}
+
+ updateIfMatch t =
+ if matchesId (taskId t) tid
+ then finalTask
+ else t
+ updatedTasks = map updateIfMatch tasks
+
+ -- Rewrite the entire file
+ tasksFile <- getTasksFilePath
+ TIO.writeFile tasksFile ""
+ traverse_ saveTaskInternal updatedTasks
+ pure finalTask
+
-- List tasks, optionally filtered by type, parent, status, or namespace
listTasks :: Maybe TaskType -> Maybe Text -> Maybe Status -> Maybe Text -> IO [Task]
listTasks maybeType maybeParent maybeStatus maybeNamespace = do