summaryrefslogtreecommitdiff
path: root/Omni/Task
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Task')
-rw-r--r--Omni/Task/Core.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs
index 58744fa..3de42b2 100644
--- a/Omni/Task/Core.hs
+++ b/Omni/Task/Core.hs
@@ -192,7 +192,7 @@ withTaskReadLock action =
action
)
--- Generate a short ID using base62 encoding of timestamp
+-- Generate a short ID using base36 encoding of timestamp (lowercase)
generateId :: IO Text
generateId = do
now <- getCurrentTime
@@ -339,7 +339,7 @@ createTask title taskType parent namespace priority deps description =
deps' = map normalizeDependency deps
tid <- case parent' of
- Nothing -> generateId
+ Nothing -> generateUniqueId
Just pid -> do
tasks <- loadTasksInternal
pure <| computeNextChildId tasks pid
@@ -361,6 +361,18 @@ createTask title taskType parent namespace priority deps description =
saveTaskInternal task
pure task
+-- Generate a unique ID (checking against existing tasks)
+generateUniqueId :: IO Text
+generateUniqueId = do
+ tasks <- loadTasksInternal
+ go tasks
+ where
+ go tasks = do
+ tid <- generateId
+ case findTask tid tasks of
+ Nothing -> pure tid
+ Just _ -> go tasks -- Retry if collision (case-insensitive)
+
-- Update task status
updateTaskStatus :: Text -> Status -> [Dependency] -> IO ()
updateTaskStatus tid newStatus newDeps =