Skip to content

feat(markdown-review): enable per-list-item commenting - #16

Merged
jfyne merged 3 commits into
masterfrom
worktree-list-comment
Apr 2, 2026
Merged

feat(markdown-review): enable per-list-item commenting#16
jfyne merged 3 commits into
masterfrom
worktree-list-comment

Conversation

@jfyne

@jfyne jfyne commented Apr 2, 2026

Copy link
Copy Markdown
Owner

What changed

Splits markdown ast.List nodes into per-item MarkdownBlock entries with ListOpen/ListClose wrapper tags, adds resolveLineRange() helper to eliminate duplicated byte-to-line resolution, and styles list-item blocks with CSS counters for correct ordered list numbering.

Requirements

Functional Requirements (EARS):

  • When a user clicks on a list item in rendered markdown view, the system shall select only that item's line range (not the entire list).
  • When a user submits a comment while a single list item is selected, the system shall anchor the comment to that item's StartLine and EndLine.
  • When a rendered markdown file contains a list, the system shall display each list item as an independently clickable and commentable block.
  • When a list item has a comment, the system shall display the comment thread directly below that item (not after the entire list).
  • While rendering per-item blocks, the system shall wrap consecutive list-item blocks in the correct <ul> or <ol> HTML tag for proper list styling.
  • If an ordered list starts at a number other than 1, the system shall include the start attribute on the <ol> tag.
  • When rendering GFM task list items as individual blocks, the system shall correctly display checkboxes.

Acceptance Criteria:

Feature: Per-list-item commenting in markdown review

  Scenario: Click selects individual list item
    Given a markdown file with a 3-item unordered list on lines 5-7
    When the user clicks on the second list item
    Then only line 6 is selected
    And the first and third items are not selected

  Scenario: Comment anchors to single list item
    Given a markdown file with a 3-item list
    And the user has selected the second item (line 6)
    When the user submits a comment "Fix this item"
    Then the comment is created with StartLine=6 and EndLine=6
    And the comment thread appears below the second item only

  Scenario: Ordered list preserves numbering
    Given a markdown file with an ordered list starting at 3
    When the file is rendered in markdown preview mode
    Then the list items are numbered starting from 3
    And each item is independently clickable

  Scenario: GFM task list checkboxes render correctly
    Given a markdown file containing "- [ ] todo" and "- [x] done"
    When the file is rendered in markdown preview mode
    Then each task item shows its checkbox (unchecked or checked)
    And each task item is independently commentable

  Scenario: Nested lists stay within parent item
    Given a markdown file with a list item containing a nested sub-list
    When the file is rendered in markdown preview mode
    Then the parent item's block includes the nested list HTML
    And the nested items are not split into separate commentable blocks

  Scenario: Non-list blocks are unaffected
    Given a markdown file with headings, paragraphs, and blockquotes
    When the file is rendered in markdown preview mode
    Then these blocks render exactly as before
    And they carry no list wrapper metadata

  Scenario: Shift-click selects range across list items
    Given a markdown file with a 3-item list
    And the user has clicked item 1 (line 5)
    When the user shift-clicks item 3 (line 7)
    Then lines 5-7 are selected (spanning all three items)

  Scenario: Legacy comment on full list range displays correctly
    Given a comment anchored to lines 5-7 (the full list range)
    And the list is now rendered as 3 per-item blocks
    Then all three items show the "commented" visual indicator
    And the comment text displays below the first item

Risk Profile

Signal Value Risk
Size 311 LOC (+289, -22) Medium
Files 5 files across 2 directories Medium
Sensitive paths None Normal
Test coverage 1 test file / 4 production files Moderate
Type Feature Normal

Overall: HIGH — Size and Files are both Medium, and Test coverage is Moderate. Three signals at level 2+ escalate the floor from Medium to High.

Suggested Review Order

# File What it does Link
1 model.go Adds ListOpen and ListClose fields to MarkdownBlock struct View
2 assets.go Splits ast.List into per-item blocks, extracts resolveLineRange() helper, adds image-parse fast-path View
3 template.html Emits ListOpen/ListClose wrapper tags around .md-block divs View
4 styles.css CSS for list-item blocks: counter-based numbering, disc markers, indentation View
5 markdown_test.go 7 test functions covering per-item splitting, ordered lists, nested lists, task lists, comment/selection projection View

jfyne added 3 commits April 2, 2026 20:28
Investigate how meatcheck's markdown block rendering treats lists as
single atomic blocks and what changes are needed to enable commenting
on individual list items. Covers goldmark AST traversal, rendering API,
template click handling, comment projection, CSS styling, and external
tool comparison.
Create implementation plan to enable users to click individual markdown
list items and leave comments anchored to that item's line range. Current
system treats entire lists as single blocks. Plan covers backend (model
struct changes, renderMarkdownBlocks() splitting logic), frontend (template
wrapper tags, CSS styling), and comprehensive tests with TDD approach.

Also merge per-list-item commenting requirements into existing review-ui
requirements file, including 8 Gherkin acceptance criteria covering happy
path, error cases, and edge cases (ordered lists, task lists, nested lists).

- docs/plans/list-item-commenting.md (new): 5 implementation tasks across
  model, rendering, template, CSS, and tests. Stage 1 TDD workflow with
  parallel test creation and sequential implementation phases.
- docs/requirements/review-ui.md (updated): add 8 EARS requirements and
  8 Gherkin scenarios for per-item list commenting feature
…l selection

Split markdown list nodes into per-item blocks with ListOpen/ListClose wrapper tags.
Each list item now independently selectable and commentable. Ordered list numbering
fixed via CSS counters. Includes refactored resolveLineRange() helper, buffer reuse
optimization, and image parsing fast-path. All tests passing with 7 new test functions.
@jfyne
jfyne marked this pull request as ready for review April 2, 2026 20:10
@jfyne
jfyne merged commit a65aa63 into master Apr 2, 2026
1 check passed
@jfyne
jfyne deleted the worktree-list-comment branch April 2, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant