Skip to content

fix(comments): table comment highlight cases left after #25585 - #25825

Merged
KiroCrewCaptain merged 2 commits into
kirodotdev:mainfrom
Recscue:fix/file-viewer-table-comment-gaps
Oct 29, 2026
Merged

KiroCrewCaptain merged 2 commits into
kirodotdev:mainfrom
Recscue:fix/file-viewer-table-comment-gaps

Conversation

@Recscue

@Recscue Recscue commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a comment on table text underlines exactly the text the reader selected, in the file viewer and on artifact pages, in the cases #25585 left open.

#25585 gave a file-viewer comment a renderedQuote to search by, which fixed the common case: a new comment across two cells now underlines. Six cases still go wrong on main, each shown by a test below built on the strings Chrome 155 returned for these selections:

  • In the file viewer, a comment that runs out of a table into the next paragraph also underlines the table's button row (Copy Markdown, Copy CSV), which the reader couldn't select.
  • On an artifact page, or a file artifact, the same comment draws its highlight box over that button row.
  • While the comment box is open, in either place, the highlight on the passage being commented on covers that button row too.
  • In the file viewer, hovering the cell just before a commented cell shows that comment.
  • In the file viewer, a comment saved without renderedQuote (before fix(dashboard): underline a file-viewer comment that spans table cells #25585, or on the toolbar's fallback path) whose quote crosses cells still gets no underline.
  • In the file viewer, when Firefox reports a selection of whole cells as one range per cell, the comment quotes every cell while its offset and line point at the first one.

Why it matters

The underline is how a reader tells which text a comment is on. A highlight on buttons the reader never selected, or a hover card on the wrong cell, points them at the wrong thing, and a comment with no underline can't be found in the table at all.

Not a goal

What changed (motivation → approach → change)

  • The button row, in the file viewer. renderedQuote is Range.toString(), which includes text under user-select: none, so a comment that runs from a table into the next paragraph matches the button labels too and paints them. unselectableSpans (useMarkdownCommentHighlights.ts) finds the text under each select-none element in the preview, which is the table's button row (MarkdownTable.tsx), and rangesForSpan builds the highlight ranges with that text cut out (spanPieces), so the cells and the paragraph are painted and the buttons aren't. A span that no unselectable text touches comes back whole, exactly as before. Finding the spans takes about 0.5 ms on a 124,000-character page with 120 tables, beside the 4.5 ms the panel already spends indexing that page's text nodes each pass.
  • The button row, on artifact pages. InlineCommentOverlay, which draws the comment boxes for ArtifactBody, FileArtifactComments and RemoteArtifactDetailPage, matches the anchorFromRange quote, which is Range.toString() too, and drew one box per line over the whole match, buttons included. rangeForAnchor becomes rangesForAnchor: the same occurrence ranking, then the same rangesForSpan as the file viewer, so the overlay draws boxes over the cells and the paragraph only. Its one caller was the overlay. The overlay finds the unselectable spans once per layout pass, and merges each piece's line fragments on their own, so a box never bridges cut-out text that shares a line with the comment.
  • The button row, while the comment box is open. paintAnnotationHighlight (annotationHighlight.ts), which marks the passage an open comment box is anchored to for all four hosts, painted every text node the selection touched. It now skips a text node under a select-none element inside the selection. A selection made wholly inside such an element still paints, since that element is then the selection's own container.
  • The cell before. Two cells join with nothing between them, so the offset where one cell's text ends is also where the next one's begins. The file viewer's locate put a range's start at the end of the earlier cell's text node, so a hover over that cell counted as on the comment. A start now lands in the node that holds the span's first character. The file viewer and the overlay both build their ranges with rangesForSpan, so the rule lives in one place.
  • Comments without renderedQuote. Their quote is the browser's selection string, with a tab between cells and a newline between rows, so the exact search misses it. When a file-viewer comment has no renderedQuote and no exact match, findLooseSpan compares the quote with the page text, both with whitespace removed and the page with its unselectable text left out. The match nearest startOffset wins. A comment with no offset is painted only when its quote matches in one place: with nothing to say which copy was selected, no underline is better than one on text the reader didn't pick. indexPage builds the page copy, about 11 ms for 232,000 characters, so the panel builds it at most once per highlight pass and only when such a comment reaches it.
  • Firefox. The file viewer's quote now comes from range 0 when a selection has more than one range, the range the offset and line come from, as SelectionToolbar already does for its composer. That comment now quotes its first cell only, which is what the composer showed. A selection whose range 0 is empty still offers no comment, as on main: the toolbar already hides for it, since its composer text is range 0's.

Backwards compatibility

Compatible: stored comments keep their shape and load unchanged. A comment lands on the same occurrence as on main; only what is painted over it changes, to leave out the button row. A highlight that no unselectable text touches is painted exactly as on main, boundary whitespace included. A file-viewer comment saved without renderedQuote whose quote crosses cells now gets its underline when its cells are found in one place, or near its saved offset.

Reader: website/src/components/InlineCommentOverlay.tsx:InlineCommentOverlay -- app -- calls rangesForAnchor, which ranks occurrences exactly as rangeForAnchor did; InlineCommentOverlay.test.tsx and the rangesForAnchor occurrence tests in useMarkdownCommentHighlights.test.tsx
Reader: website/src/test/useMarkdownCommentHighlights.test.tsx:rangeForAnchor -- release -- the four occurrence tests now call rangesForAnchor with nothing to skip and pass unchanged

Tests

  • MarkdownPanelTableCommentGaps.test.tsx (4), through the real panel and SelectionToolbar, with Selection.toString() stubbed to the string Chrome 155 returned for each selection over the same document: a comment out of a table into the next paragraph paints around the button row; comments saved without renderedQuote (one found by its offset on the second of two identical rows, one unique with no offset, one ambiguous with no offset that paints nothing, one out of the table); a hover over the cell before a comment shows nothing and a hover inside it shows the comment; a Firefox one-range-per-cell selection quotes and paints its first cell.
  • InlineCommentOverlay.test.tsx (+2): a comment whose quote runs from a table, over its button row, into the next paragraph draws boxes on the cells and the paragraph and none on the buttons; a comment around an inline select-none span on one line draws a box on each side of it and none over it.
  • annotationHighlight.test.ts (+1): an open comment box's highlight leaves out the button row between two cells and the next paragraph, and still paints a selection made wholly inside a select-none element.
  • useMarkdownCommentHighlights.test.tsx (+16): findLooseSpan on each Chrome string, the nearest-offset and no-offset rules, no match for any non-whitespace difference, non-breaking spaces, skipping unselectable text, unselectableSpans (a select-none element inside another counted once, spans in page order), spanPieces, and rangesForAnchor cutting around the buttons, starting in the cell that holds its first character, and keeping a quote whole, edge whitespace included, when nothing unselectable touches it. The four rangeForAnchor occurrence tests run unchanged against rangesForAnchor.

Proof: not provable -- frontend test (prove.py runs Python only)

With MarkdownPanel.tsx reverted to main, all 4 panel tests fail; with the overlay's skip removed both its new tests fail; with annotationHighlight.ts reverted to main its new test fails. Removing each guard on its own fails a test written for it: the shared start-node rule fails the file viewer's hover test and the start-in-its-own-cell unit test, the range-0 quote fails the Firefox test, painting around the button row fails the out-of-the-table test and the saved-comments test, keeping an untouched span whole fails the edge-whitespace test, merging per piece fails the inline test, the open-box highlight's skip fails its test and so does skipping a select-none container the selection lies inside, counting a nested select-none once fails its unit test, and the loose fallback, the skip in its page copy, the no-offset uniqueness rule and the nearest-offset rule each fail the saved-comments test, the last two also failing their unit tests. The MarkdownPanel, SelectionToolbar, comment, highlight and artifact suites pass (141 files, 2184 tests).

Manual verification

In a local build, on a markdown document with two tables, a code fence, a <br> in a cell, an empty cell and a repeated row, in Chrome 155:

  • File viewer: a comment from the last row's second cell into the next paragraph, added through the composer, painted per changeRyan and After-table. Its renderedQuote held the button row's labels between them.
  • File viewer: on a comment across a row's second and third cells, the mouse over the last character of the row's first cell showed no hover card, and over the third cell showed the comment.
  • File viewer: four comments saved without renderedQuote, loaded on reload: the one with an offset painted the second of the two identical rows, the unique one painted the header cells, the ambiguous one painted nothing, and the one out of the table painted the cells and the paragraph.
  • Artifact page: the same document saved as a markdown artifact, and the same out-of-table selection. While its comment box was open, the highlight painted per change, Ryan, a newline between blocks, and After-table, and none of the button labels. Commented on through the page's composer, its saved quote held the button labels. The overlay drew two boxes, on the last row and on After-table, and none overlapping the button row. A single range over the same quote on that page, as main draws it, has 3 line boxes overlapping the button row.

I didn't check Firefox by hand; its one-range-per-cell path is covered by the panel test above.

Screenshots / video

A comment from the last row into the paragraph after the table, with this change. The cells and the paragraph are highlighted and the Copy Markdown and Copy CSV buttons between them aren't.

File viewer Artifact page
In the file viewer, a comment from the last row's second cell into the paragraph after the table underlines the cells and the paragraph, and not the Copy Markdown and Copy CSV buttons between them On an artifact page, the same comment draws highlight boxes on the last row's cells and on the paragraph, and none on the Copy Markdown and Copy CSV buttons

Related Issues

Part of #25490, which #25585 closed; this covers the cases it left open.

Sibling sweep

Swept: git grep -n "findBestOccurrence(|rangeForAnchor(|paintAnnotationHighlight(|renderedQuote|sel.toString()" -- website/src/components website/src/pages website/src/hooks website/src/utils
Sibling: website/src/components/MarkdownPanel.tsx -- changed here
Sibling: website/src/components/InlineCommentOverlay.tsx -- changed here
Sibling: website/src/components/SelectionToolbar.tsx -- not affected -- its composer already quotes range 0 of a multi-range selection
Sibling: website/src/utils/annotationHighlight.ts -- changed here -- the open comment box's highlight, for MarkdownPanel, FileArtifactComments, RemoteArtifactDetailPage and useArtifactDetailPageComments

Pattern harvest

Rule candidate: review-prompt
Pattern: a highlight painted from a Range.toString() match covers text under user-select: none that the reader never selected

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): N/A, no documented behavior changes
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

N/A, the template has no CLA text yet.

@Recscue
Recscue requested review from a team and KiroCrewCaptain as code owners October 29, 2026 17:15
@Recscue
Recscue requested a review from dodgeblaster October 29, 2026 17:15
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of ad0e877574def66d6e248ad5adc795f87102d7e3 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

This PR adds no controls or copy, only highlight placement. Both committed screenshots show the underline skipping the Copy Markdown / Copy CSV row in the file viewer and on artifact pages. No first-time reader has looked at them; this lane runs without one.

Notes

  • Neither screenshot shows the highlight while the comment box is open, or a hover over the cell just before a commented cell. A still of each would cover the other two cases the PR fixes.

[UX-REVIEWED] ad0e877

Description read

[DESCRIPTION-READ] f20bfe0d3342e59045171dde68ab4b12375dbc52a065ef3a2e5428b8c31c0d4c

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of ad0e877574def66d6e248ad5adc795f87102d7e3 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns: the patch puts the cut-out and range-start rule in one place, rangesForSpan, and every rangeForAnchor reader is updated in the patch.

Notes

  • Text counts as unselectable only when it sits under the Tailwind class .select-none (querySelectorAll('.select-none'), closest('.select-none')). A future control that sets user-select: none some other way would be highlighted again without any warning. Putting the class on such controls, or leaving a comment at MarkdownTable.tsx that ties the class to this rule, keeps that link visible.

[DESIGN-REVIEWED] ad0e877

Description read

[DESCRIPTION-READ] 09e2356d43369b7d4fe40733212a3885ae7b39de5e0d26330b3644718f5b3741

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of ad0e877574def66d6e248ad5adc795f87102d7e3 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Each of the six table-highlight cases is pinned by a test this PR adds, and each fix sits in the shared range builder. All three rangeForAnchor callers move to the new shape.

What this change ships

Inventory (9 items) — 8 justified

Intent: a comment on table text underlines only the text the reader selected, in the file viewer and on artifact pages. This is a FIX.

  1. File viewer: a comment that runs out of a table no longer underlines the Copy Markdown / Copy CSV button row — justified
  2. Artifact pages and file artifacts: the comment box no longer covers that button row — justified
  3. Open comment box: the passage highlight skips that button row — justified
  4. File viewer: hovering the cell before a commented cell no longer shows the comment — justified
  5. File viewer: a cross-cell comment saved without renderedQuote is now underlined when its text is found in one place or near its saved offset; an ambiguous one with no offset stays unpainted — justified
  6. Firefox: a selection with one range per cell now quotes the first cell only, as SelectionToolbar already does — justified
  7. rangeForAnchor renamed rangesForAnchor and returns several ranges; the overlay is its one caller and comments in 3 other files are updated — justified
  8. New exported helpers rangesForSpan, unselectableSpans, findLooseSpan, indexPage, spanPieces, shared by the panel and the overlay — justified
  9. Two screenshots committed under temp-screenshots/ — undeclared

[FIRST-PRINCIPLES-REVIEWED] ad0e877

Description read

[DESCRIPTION-READ] a46783a85e6fcea31b1c258aabe424791a2bd4d5784a947a9b126f8c66811e2c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed ad0e877574def66d6e248ad5adc795f87102d7e3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] ad0e877

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed ad0e877574def66d6e248ad5adc795f87102d7e3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ad0e877

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 29, 2026

@KiroCrewCaptain KiroCrewCaptain 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.

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit fbd2a38 into kirodotdev:main Oct 29, 2026
89 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants