Skip to content

fix: order mermaid diagram comments by document position - #239

Merged
blimmer merged 1 commit into
mainfrom
fix/mermaid-comment-sidebar-order
Jul 10, 2026
Merged

fix: order mermaid diagram comments by document position#239
blimmer merged 1 commit into
mainfrom
fix/mermaid-comment-sidebar-order

Conversation

@blimmer

@blimmer blimmer commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Comments anchored to mermaid diagram elements always sank to the bottom of the comments sidebar and were skipped by prev/next navigation and the "Comment X of Y" counter, because thread.range doubled as the ordering and navigation-eligibility signal — and element anchors never resolve to a DOM Range by design. Sidebar ordering now uses the stored anchor's source lines (the one position every anchor kind shares), and navigation eligibility keys off the semantic unresolved field. Closes #238.

Review focus

  • Ordering now comes from creation-time source coordinates rather than the live DOM. The two diverge only for pre-existing threads whose anchors get quote-relocated after content drift — those sort at their original location. Unresolved ("Needs restore") threads also now sit at their last-known position instead of clumping at the end.
  • Diagram comments becoming navigable is a deliberate behavior change: the "Comment X of Y" total grows wherever element threads are present.

Commits

  • 89b4452 — fix: order mermaid diagram comments by document position

Element anchors (mermaid diagrams) always resolve with a null range by
design, so the sidebar comparator sank every diagram comment below all
resolved text comments, and navigation excluded them from prev/next and
the "Comment X of Y" counter.

Collapse compareResolvedThreads to pure source-document ordering using
the required sourceLines on both anchor kinds, and switch navigation
eligibility from the range proxy to the semantic unresolved field so
resolved element threads become navigable.

Fixes #238
];
}

// Source lines are the one position every anchor kind shares — element anchors never resolve to a DOM Range.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually get a bit less complicated with this fix

expect(annotated.hovered).toBe(annotated.resting);
});

it('orders the sidebar by document position when a diagram comment precedes a text comment', async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I TDD'ed this

@blimmer
blimmer marked this pull request as ready for review July 9, 2026 18:58
@blimmer
blimmer requested a review from jcarver989 as a code owner July 9, 2026 18:58
@blimmer
blimmer merged commit a4487d7 into main Jul 10, 2026
14 checks passed
@blimmer
blimmer deleted the fix/mermaid-comment-sidebar-order branch July 10, 2026 22:16
blimmer pushed a commit that referenced this pull request Jul 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.3](v0.9.2...v0.9.3)
(2026-07-10)


### Bug Fixes

* order mermaid diagram comments by document position
([#239](#239))
([a4487d7](a4487d7))
* restore automatic plan approval on Claude Code 2.1.199+
([#235](#235))
([9fe93d8](9fe93d8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: contextbridge-pr-automation[bot] <259134118+contextbridge-pr-automation[bot]@users.noreply.github.com>
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.

bug: comments on mermaid diagrams always sink to the bottom of the comments sidebar

2 participants