From b616e753da03d234c7e4e0a0ea50c9e192644cf9 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 28 Nov 2025 04:11:17 -0500 Subject: Add comments field to tasks for providing extra context All tests pass. Here's a summary of the changes I made: 1. **Added `Comment` data type** in `Omni/Task/Core.hs` with `commentTex 2. **Added `taskComments` field** to the `Task` type to store a list of 3. **Updated database schema** with a `comments TEXT` column (stored as 4. **Added SQL instances** for `[Comment]` to serialize/deserialize 5. **Added `addComment` function** to add timestamped comments to tasks 6. **Added CLI command** `task comment [--json]` 7. **Updated `showTaskDetailed`** to display comments in the detailed vi 8. **Added unit tests** for comments functionality 9. **Added CLI tests** for the comment command 10. **Fixed dependent files** (`Omni/Agent/Worker.hs` and `Omni/Jr/Web.h Task-Id: t-167 --- Omni/Jr/Web.hs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'Omni/Jr') diff --git a/Omni/Jr/Web.hs b/Omni/Jr/Web.hs index fbb56a7..a861944 100644 --- a/Omni/Jr/Web.hs +++ b/Omni/Jr/Web.hs @@ -879,10 +879,8 @@ renderEpicCardWithStats allTasks t = Lucid.span_ [Lucid.class_ "priority"] (Lucid.toHtml (tshow (TaskCore.taskPriority t))) Lucid.p_ [Lucid.class_ "task-title"] (Lucid.toHtml (TaskCore.taskTitle t)) when (totalCount > 0) <| epicProgressBar doneCount inProgressCount openAndReview totalCount - case TaskCore.taskDescription t of - Nothing -> pure () - Just desc -> - Lucid.p_ [Lucid.class_ "kb-preview"] (Lucid.toHtml (Text.take 200 desc <> "...")) + unless (Text.null (TaskCore.taskDescription t)) + <| Lucid.p_ [Lucid.class_ "kb-preview"] (Lucid.toHtml (Text.take 200 (TaskCore.taskDescription t) <> "...")) getDescendants :: [TaskCore.Task] -> Text -> [TaskCore.Task] getDescendants allTasks parentId = @@ -1045,9 +1043,9 @@ instance Lucid.ToHtml TaskDetailPage where for_ maybeAggMetrics (renderAggregatedMetrics allTasks task) Lucid.div_ [Lucid.class_ "detail-section"] <| do Lucid.h3_ "Design" - case TaskCore.taskDescription task of - Nothing -> Lucid.p_ [Lucid.class_ "empty-msg"] "No design document yet." - Just desc -> Lucid.div_ [Lucid.class_ "markdown-content"] (renderMarkdown desc) + if Text.null (TaskCore.taskDescription task) + then Lucid.p_ [Lucid.class_ "empty-msg"] "No design document yet." + else Lucid.div_ [Lucid.class_ "markdown-content"] (renderMarkdown (TaskCore.taskDescription task)) Lucid.details_ [Lucid.class_ "edit-description"] <| do Lucid.summary_ "Edit Design" Lucid.form_ [Lucid.method_ "POST", Lucid.action_ ("/tasks/" <> TaskCore.taskId task <> "/description")] <| do @@ -1057,16 +1055,15 @@ instance Lucid.ToHtml TaskDetailPage where Lucid.rows_ "15", Lucid.placeholder_ "Enter design in Markdown format..." ] - (Lucid.toHtml (fromMaybe "" (TaskCore.taskDescription task))) + (Lucid.toHtml (TaskCore.taskDescription task)) Lucid.div_ [Lucid.class_ "form-actions"] <| do Lucid.button_ [Lucid.type_ "submit", Lucid.class_ "submit-btn"] "Save Design" _ -> - case TaskCore.taskDescription task of - Nothing -> pure () - Just desc -> - Lucid.div_ [Lucid.class_ "detail-section"] <| do - Lucid.h3_ "Description" - Lucid.pre_ [Lucid.class_ "description"] (Lucid.toHtml desc) + unless (Text.null (TaskCore.taskDescription task)) + <| Lucid.div_ [Lucid.class_ "detail-section"] + <| do + Lucid.h3_ "Description" + Lucid.pre_ [Lucid.class_ "description"] (Lucid.toHtml (TaskCore.taskDescription task)) let children = filter (maybe False (TaskCore.matchesId (TaskCore.taskId task)) <. TaskCore.taskParent) allTasks unless (null children) <| do @@ -2027,8 +2024,8 @@ server = taskDescriptionHandler :: Text -> DescriptionForm -> Servant.Handler (Headers '[Header "Location" Text] NoContent) taskDescriptionHandler tid (DescriptionForm desc) = do - let descMaybe = if Text.null (Text.strip desc) then Nothing else Just desc - _ <- liftIO <| TaskCore.editTask tid (\t -> t {TaskCore.taskDescription = descMaybe}) + let descText = Text.strip desc + _ <- liftIO <| TaskCore.editTask tid (\t -> t {TaskCore.taskDescription = descText}) pure <| addHeader ("/tasks/" <> tid) NoContent taskNotesHandler :: Text -> NotesForm -> Servant.Handler (Headers '[Header "Location" Text] NoContent) -- cgit v1.2.3