Add a commentOnLineClick setting to keep line clicks from opening comment drafts - #166
Closed
azhadsyed wants to merge 1 commit into
Closed
Add a commentOnLineClick setting to keep line clicks from opening comment drafts#166azhadsyed wants to merge 1 commit into
azhadsyed wants to merge 1 commit into
Conversation
…ment drafts Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Author
|
Visual evidence: before this change, selecting text inside a diff line opened an empty review comment draft under the line. Screenshot of that state to be attached here. |
Member
|
Thank you for the PR. This is a regression. I noticed it as well when highlighting code and it is annoying. I will fix that without adding a new option. |
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.
TL;DR
Adds
settings.commentOnLineClick(defaulttrue). When set tofalse, clicking or dragging on diff lines no longer opens a review comment draft, and the gutter comment button remains the way to start one.Risk: Low
Change type: Additive
References
Background
Selecting text in a diff opened an empty comment draft under the line
To reproduce on main: open a diff, press the mouse inside a changed line, drag across a few characters, and release. An empty review comment draft opens under that line.
I select spans of code constantly while reading, so every selection left a stray draft to dismiss. The browser fires a click after a drag that starts and ends on one element, the diff library forwards it as a line click, and Codiff turns every line click into a draft. The text-selection guard only helps while the selection is still non-collapsed when that click fires.
With this change, a reader who prefers explicit commenting sets
commentOnLineClicktofalseand keeps the gutter button (the comment control in the line-number gutter) as the one deliberate way to add a comment. Everyone else sees no change.Architecture
One setting gating two callbacks, with the gutter button left as the explicit path
onLineSelectionEndtoo. The code view starts a line-range selection only from a pointer-down in the line-number column (startLineSelectionFromPointerDownin@pierre/diffs) and reports it through that callback, so a number-column drag also ended in a draft.onGutterUtilityClickis untouched, so the gutter button stays a working, explicit path.enableLineSelection: false, so a number-column drag no longer highlights a range that then does nothing.true, so existing users see no change.Testing
Vitest cases for the gated callbacks and the config normalizer
core/__tests__/ReviewCodeView-scroll.test.tsx: withcommentOnLineClick={false}, a line click and a line-range selection end create no comment, the code view receivesenableLineSelection: false, and a gutter button click still creates the comment at the expected line and section.core/__tests__/config-defaults.test.ts: the Electron reader keepsfalsewhen set and falls back totrueon a missing or non-boolean value.vp check,vp run build, and the fullvp testsuite ran locally before pushing; CI is authoritative."commentOnLineClick": falsein~/.codiff/codiff.jsonc, run this branch, then drag across text in a diff line and drag in the line-number column. No draft opens in either case, and the gutter button still opens one.AI assistance: the code, tests, and this description were written with Claude Code (Claude Fable 5.1), directed and reviewed by the author.