diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-22 05:55:10 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-22 12:46:07 -0500 |
| commit | 7c649a257aa79f01bcaf989191a065acf8105132 (patch) | |
| tree | 840bf87ce42111e36c5b8e5441ddffa8617f3dcd /Omni/Task/Core.hs | |
| parent | 1fcf654b30c5ca9e1d680805df40435e6fe20e4e (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/Core.hs')
| -rw-r--r-- | Omni/Task/Core.hs | 28 |
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 |
