Repository navigation
fix(file-viewer): underline comments on text inside fenced code blocks - #23155
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The fix removes a deliberate skip and places the mark from data the selection toolbar already builds. The new field is optional, and when no position is stored it falls back to marking a quote that occurs once. Notes
[DESIGN-REVIEWED] 5512513 Description read[DESCRIPTION-READ] 94e1fa5b56e2f5448c72303d7121466cf3ed58b919db18ddb560e5a433d723a8 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each item comes from the issue (#21837), has a test that fails on base, or follows from the new code-mark hit test. The new code reuses the existing helpers What this change shipsInventory (6 items) — 6 justifiedIntent: a reviewer can see where a comment made on text inside a fenced code block sits in the markdown preview, and read it on hover. This is a FIX (closes #21837).
[FIRST-PRINCIPLES-REVIEWED] 5512513 Description read[DESCRIPTION-READ] ac32bc917581c643b29a685a49b5fc7969d53d7c7b9ca94842e92c8c70ef9bba That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: both screenshots show the new code-block underline and its hover note, and the blind reader read them correctly ("a comment or question someone attached to that marked text"). Notes
[UX-REVIEWED] 5512513 Description read[DESCRIPTION-READ] c65c81fd5f64da07ff8a1277e700484f25961cee4db35b6a2d9c756d222daca3 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
a83e8ba to
5512513
Compare
|
self-added: yes
|
|
self-added: yes
|
|
Review-ready on |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (6 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: bug fix so a comment on text inside a fenced code block is placed by its stored block position and underlined in the markdown preview, with unit tests and a screenshot harness script.
Problem / Motivation
Goal: A comment on text inside a fenced code block in the markdown preview is underlined at that text and shows its words on hover, like a prose comment.
Since #21133 you can select text in a code block and comment on it. The comment is saved, but the preview shows no mark at that text. The underline pass skips every code-block comment (
if (!comment.anchor || comment.inCode) continueinwebsite/src/components/MarkdownPanel.tsx).Why it matters
A reviewer who comments on a command in a doc cannot see where the comment sits. The note is in the sidebar but nothing in the document points to it, and hover shows nothing.
Not a goal
What changed (motivation → approach → change)
A code-block comment is now underlined in its own block, and the pointer on it shows the comment.
codePosition: which block, line and columncodePositionis the numbercodePassagePosition(from #21133) already builds for the selection toolbar.codeQuoteRangeinwebsite/src/utils/pierreShadow.tsreads it back. If the stored column is past the end of its row, or the text there no longer starts with the quote, or the comment was saved before this change, the quote is marked only when it occurs once across all code blocks. A block that shows only its plain copy gets no mark until the swap;watchTextreports the swap and the pass runs again.Paint uses the same
mc-commentCSS highlight, so token colours, the copy button and selection stay as they were.Backwards compatibility
Compatible:
codePositionis an optional new field. Code comments saved before it are still placed when their words occur once in the code.Removes nothing: the change only adds marks where none were drawn; prose comments take the same path as before.
Tests
MarkdownPanelCodeBlock.test.tsx: a code comment is painted inside the code block's shadow root, not on the same words in the prose; with two blocks holding the same words, the commented block is marked; an older comment with no position is marked; the mark comes back after the block is redrawn; hover over the mark shows the comment; a click on the mark with text selected keeps the selection, and one without clears it; a prose comment is still painted in the prose.pierreShadow.test.ts:codeQuoteRangeplaces by position, across two lines, waits while a block is plain or parked, never searches prose, refuses an ambiguous quote, falls back when the text at the position changed, and ignores a column past the end of a shortened row.The five new panel tests fail on
origin/main(the prose one passes there, by design). Removing thewatchTextcall fails only the redraw test; dropping the stored position fails only the two-blocks test.Manual verification
Ran
website/scripts/capture-21837-code-block-comment-mark.mjsagainst the built SPA with fixture APIs in headless Chromium. It asserts both marks are painted in their places and the tooltip text, then writes the two frames below.Screenshots / video
The prose comment and the code comment, each underlined in place. The same words in the prose and in the first block are not marked.
Pointer on the code mark: the comment text shows.
Related Issues
Closes #21837
Pattern harvest
Not generalizable: the skip was a deliberate scope cut in #21133, not a recurring code shape.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)