From 4919cf825d4fdbcecc1f69fcf2a32176dfdde5ac Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 1 Dec 2025 07:40:49 -0500 Subject: Add author field to task comments (Human vs Junior) Comments now track whether they were made by a Human or by Junior (the agent). The CommentAuthor type is stored in the database and displayed in the web UI with styled badges. Task-Id: t-201 --- Omni/Task.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Omni/Task.hs') diff --git a/Omni/Task.hs b/Omni/Task.hs index 11d080b..3a68fa5 100644 --- a/Omni/Task.hs +++ b/Omni/Task.hs @@ -286,7 +286,7 @@ move' args | args `Cli.has` Cli.command "comment" = do tid <- getArgText args "id" message <- getArgText args "message" - updatedTask <- addComment tid message + updatedTask <- addComment tid message Human if isJsonMode args then outputJson updatedTask else putStrLn <| "Added comment to task: " <> T.unpack tid @@ -873,24 +873,28 @@ unitTests = (parseQueryParam "Done" :: Either Text Status) Test.@?= Right Done, Test.unit "can add comment to task" <| do task <- createTask "Task with comment" WorkTask Nothing Nothing P2 Nothing [] "Description" - updatedTask <- addComment (taskId task) "This is a test comment" + updatedTask <- addComment (taskId task) "This is a test comment" Human length (taskComments updatedTask) Test.@?= 1 case taskComments updatedTask of - (c : _) -> commentText c Test.@?= "This is a test comment" + (c : _) -> do + commentText c Test.@?= "This is a test comment" + commentAuthor c Test.@?= Human [] -> Test.assertFailure "Expected at least one comment", Test.unit "can add multiple comments to task" <| do task <- createTask "Task with comments" WorkTask Nothing Nothing P2 Nothing [] "Description" - _ <- addComment (taskId task) "First comment" - updatedTask <- addComment (taskId task) "Second comment" + _ <- addComment (taskId task) "First comment" Junior + updatedTask <- addComment (taskId task) "Second comment" Human length (taskComments updatedTask) Test.@?= 2 case taskComments updatedTask of (c1 : c2 : _) -> do commentText c1 Test.@?= "First comment" + commentAuthor c1 Test.@?= Junior commentText c2 Test.@?= "Second comment" + commentAuthor c2 Test.@?= Human _ -> Test.assertFailure "Expected at least two comments", Test.unit "comments are persisted" <| do task <- createTask "Persistent comments" WorkTask Nothing Nothing P2 Nothing [] "Description" - _ <- addComment (taskId task) "Persisted comment" + _ <- addComment (taskId task) "Persisted comment" Junior tasks <- loadTasks case findTask (taskId task) tasks of Nothing -> Test.assertFailure "Could not reload task" -- cgit v1.2.3