Repository navigation
fix(comments): table comment highlight cases left after #25585 - #25825
Conversation
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of 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
[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 |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: the patch puts the cut-out and range-start rule in one place, Notes
[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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of 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 What this change shipsInventory (9 items) — 8 justifiedIntent: a comment on table text underlines only the text the reader selected, in the file viewer and on artifact pages. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ad0e877 Description read[DESCRIPTION-READ] a46783a85e6fcea31b1c258aabe424791a2bd4d5784a947a9b126f8c66811e2c That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.
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
renderedQuoteto 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: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.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
startOffset, and artifact pages still rank by prefix, suffix and then offset.What changed (motivation → approach → change)
renderedQuoteisRange.toString(), which includes text underuser-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 eachselect-noneelement in the preview, which is the table's button row (MarkdownTable.tsx), andrangesForSpanbuilds 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.InlineCommentOverlay, which draws the comment boxes for ArtifactBody, FileArtifactComments and RemoteArtifactDetailPage, matches theanchorFromRangequote, which isRange.toString()too, and drew one box per line over the whole match, buttons included.rangeForAnchorbecomesrangesForAnchor: the same occurrence ranking, then the samerangesForSpanas 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.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 aselect-noneelement inside the selection. A selection made wholly inside such an element still paints, since that element is then the selection's own container.locateput 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 withrangesForSpan, so the rule lives in one place.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 norenderedQuoteand no exact match,findLooseSpancompares the quote with the page text, both with whitespace removed and the page with its unselectable text left out. The match neareststartOffsetwins. 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.indexPagebuilds 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.SelectionToolbaralready 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
renderedQuotewhose 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
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 withoutrenderedQuote(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.select-nonespan on one line draws a box on each side of it and none over it.select-noneelement.findLooseSpanon each Chrome string, the nearest-offset and no-offset rules, no match for any non-whitespace difference, non-breaking spaces, skipping unselectable text,unselectableSpans(aselect-noneelement inside another counted once, spans in page order),spanPieces, andrangesForAnchorcutting 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 fourrangeForAnchoroccurrence tests run unchanged againstrangesForAnchor.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-nonecontainer the selection lies inside, counting a nestedselect-noneonce 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:per changeRyanandAfter-table. ItsrenderedQuoteheld the button row's labels between them.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.per change,Ryan, a newline between blocks, andAfter-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 onAfter-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.
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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
N/A, the template has no CLA text yet.