diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-20 19:06:41 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-20 19:06:41 -0500 |
| commit | 809c0009da015588ffbf8c4221df04c13aacc215 (patch) | |
| tree | 536cd65caabac0fe24a2cf6c2aa0aef1614fa85b /Omni/Task | |
| parent | feda8ac221d88650850a3eaac2fbe2f2b215beac (diff) | |
feat: implement t-PpYZt2
Diffstat (limited to 'Omni/Task')
| -rw-r--r-- | Omni/Task/Core.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Omni/Task/Core.hs b/Omni/Task/Core.hs index 525ceb4..98ef6f9 100644 --- a/Omni/Task/Core.hs +++ b/Omni/Task/Core.hs @@ -121,9 +121,10 @@ generateId = do generateChildId :: Text -> IO Text generateChildId parentId = do tasks <- loadTasks - let children = filter (\t -> taskParent t == Just parentId) tasks - -- Find the max suffix - suffixes = mapMaybe (getSuffix parentId <. taskId) children + -- Find the max suffix among ALL tasks that look like children (to avoid ID collisions) + -- We check all tasks, not just those with taskParent set, because we want to ensure + -- ID uniqueness even if the parent link is missing. + let suffixes = mapMaybe (getSuffix parentId <. taskId) tasks nextSuffix = case suffixes of [] -> 1 s -> maximum s + 1 |
