Text (character-range) comments: comment on a word / phrase / span - #83
Merged
Conversation
… (#text-select) Comment on exactly a word, phrase, or multi-line span — by mouse, touch, or keyboard — not just whole lines. Adds a new kind=text comment. - Model: Comment.FromCol/ToCol (rune offsets) + Kind="text" + CommentAnchor.Snippet; CSV gains from_col/to_col (length-tolerant reader). - Selectable diff: line <button> → <div role/tabindex> with [data-line-text]; wires the upstream lvt-fx:text-select directive (vendored bundle). - Server: SelectText handler + addTextComment + text composer mode + side-aware composer/card gate (a modified line exists on both sides). - Highlight: server-side gitdiff.MarkRanges wraps [FromCol,ToCol) in <mark class="comment-span">, rendered via zero-arg LineDisplay(). - Drift: relocateTextColumns re-finds the snippet in a moved line. - Load-bearing invariant guarded by gitdiff/textcontent_test.go (.content textContent == raw line, rune-for-rune). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ey41dRwDpRgLtVHZjhYLKt
…nt#140) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ey41dRwDpRgLtVHZjhYLKt
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ey41dRwDpRgLtVHZjhYLKt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently a comment can only anchor to whole lines. This adds sub-line, character-range comments: select a word, a phrase, or a span across lines — by mouse, touch, or keyboard — and comment on exactly that text.
What's new
kind=textcomment withFromCol/ToCol(0-based, half-open, rune offsets) + the selected snippet in the anchor. CSV gainsfrom_col/to_col(reader stays length-tolerant, 7→15 cols).<div role=button tabindex=0>(was<button>, whose content iOS/UA make non-selectable) with a[data-line-text]container; click/Enter still select the line.lvt-fx:text-select(vendored bundle; source in feat(dom): lvt-fx:text-select — character-range selection over diff text client#140): floating Comment button on drag/long-press, and a keyboard block caret (visible on load; ←/→/↑/↓; Shift+arrows select; Ctrl/Alt = word).gitdiff.MarkRangeswraps[FromCol,ToCol)in<mark class="comment-span">(splits across chroma tokens), rendered via the zero-argLineDisplay()map. Works with no JS, survives re-render, theme-aware.kind=textreuses line-anchor relocation, thenrelocateTextColumnsre-finds the snippet in the moved line.Why it's safe
gitdiff/textcontent_test.go: a rendered line's.contenttextContentequals the raw line rune-for-rune — the only reason browser-computed offsets match server-stored ones.Tests
Unit: CSV round-trip + 7→15-col back-compat,
MarkRanges(cross-token / unicode / fallback / merge),textcontentinvariant,LineSpan/predicates, text-column drift. E2E (chromedp): mouse select→CSV, keyboard caret + select, visible-caret-moves, modified-line single-composer, mark highlight. Existing keyboard/line e2e all still green.🤖 Generated with Claude Code