Skip to content

Keep API comments visible when Markdown anchors cannot render - #294

Merged
salamagd merged 6 commits into
mainfrom
codex/hood-6568-visible-comment-anchors
Nov 3, 2026
Merged

salamagd merged 6 commits into
mainfrom
codex/hood-6568-visible-comment-anchors

Conversation

@salamagd

@salamagd salamagd commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

API comments quoting Markdown source, such as inline backticks or a table row, could be accepted but have no visible highlight or entry in Comments. Their direct thread links also opened an apparently empty page.

Project source quotes through the document's Markdown text map before highlighting them, preserving the stored quotes, source offsets, and occurrence selection. Keep a document comment entry when the browser cannot place a text anchor, and refresh that entry on replies, resolution, reopening, and deletion. Existing comments benefit without a data migration.

Pin the lint job to Ubuntu 24.04, matching its last successful run. The moving ubuntu-latest image selected Ubuntu 26.04, for which the Ruby setup action could not install the required Ruby 3.4.7 runtime.

Tracks HOOD-6568.

Evidence

Manually opened a table-row discussion in the local demo in light mode and the source-only fallback discussion in dark mode.

Table-row discussion in light mode

Source-only discussion available from Comments in dark mode

How to try it

  1. Seed the demo library with bin/rails coplan:demo:seed and sign in as hampton@example.com in the example host.
  2. From Demo library, open API comments: Markdown quotes and visible fallbacks. Click the highlighted inline code, table row, or plain cell text to open its discussion.
  3. Expand Comments to open the source-only annotation's discussion. Reply, resolve it, and follow its copied thread link; the resolved discussion remains reachable.

@salamagd
salamagd marked this pull request as ready for review November 2, 2026 19:46

@HamptonMakes HamptonMakes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd rather not change the ubuntu target if we can avoid it... but otherwise LGTM.

Comment thread .github/workflows/ci.yml Resolved
applyFilter() {
if (!this.hasListTarget) return
const filter = this.filterTarget.value || "open"
const comments = [...this.listTarget.querySelectorAll("[data-comment-status]")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

its pre-existing but generally we shouldn't be using querySelectorAll at all...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 Updated in c170cc2. The Comments controller now uses Stimulus targets for its comment entries and disclosure. The text highlighter publishes the IDs of threads it successfully placed, and Comments requests the current snapshot when it connects. The navigation controller also owns its count badge through a target and an event.

This removes the DOM queries from the Comments controller. Browser coverage includes reconnection, Turbo list replacement/removal, and an anchor disappearing so its fallback becomes visible.

@salamagd
salamagd merged commit 2bb5baf into main Nov 3, 2026
1 check passed
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.

2 participants