From 809c0009da015588ffbf8c4221df04c13aacc215 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 20 Nov 2025 19:06:41 -0500 Subject: feat: implement t-PpYZt2 --- Omni/Task/Core.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Omni/Task/Core.hs') 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 -- cgit v1.2.3