feat(ui): copy the comment at the cursor with Y - #570
Merged
Conversation
`dd` deletes the comment at the cursor, but nothing copied just that one. `y` exports the whole review, and visual-mode `y` yanks diff text only, because `content_for_side` returns `None` for comment annotations, so dragging over a comment box yanks nothing. `Y` resolves the comment under the cursor through `find_comment_at_cursor`, the same lookup `dd` and `i` use, then copies its content with `copy_text_to_clipboard`, so the tmux and OSC 52 paths keep working. Remote threads stay out of scope: they are read-only in v1 and their bodies live in `forge_review_threads` rather than the session, so when the cursor is on one the message says where the comment lives instead of claiming there is none. Fixes agavra#569.
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.
Fixes #569.
Problem
dddeletes the comment at the cursor, but there was no way to copy just that one.yexports the whole review, and visual-modeycopies diff text only:content_for_side(src/app/navigation.rs:540) returnsNonefor comment annotations, so dragging over a comment box yanks nothing. Getting one comment out meant leaving the TUI fortuicr review comments --session ... | jq, which needs an id you cannot see from the box you are looking at.Fix
Yin normal mode copies the content of the comment under the cursor.App::comment_content_at_cursorresolves throughfind_comment_at_cursor, the same lookupddandiuse, soYandddalways agree on which comment the cursor is on. It carries over the side guard the delete path uses for line comments.copy_text_to_clipboard, so pbcopy, OSC 52, xclip and wl-copy behave exactly as they do fory, including the "(via terminal)" message.yand visual-modeyare untouched.Remote threads are deliberately out of scope: they are read-only in v1 and their bodies live in
forge_review_threadsrather than the session. When the cursor is on one, the message names the forge instead of claiming there is no comment.Help popup and
docs/KEYBINDINGS.mdboth list the new key.Evidence
cargo test:The two failures are
should_discover_worktree_with_relativeworktrees_extensionanddefault_preference_routes_reftable_repo_to_cli. Both fail identically on an unmodified checkout of8323f13here, because this box runs git 2.43.0, which predates therelativeworktreesandreftableextensions. Nothing else fails.New tests:
should_yank_only_the_comment_under_the_cursorputs two comments on different lines and checks each one yanks its own content, not its neighbour's.should_yank_nothing_when_cursor_is_not_on_a_commentpins theNonepath on a plain diff line.should_map_lowercase_and_uppercase_y_to_separate_yank_actionspinsyandYto different actions.cargo fmt --all --checkandcargo clippy -- -D warningsare both clean. (clippy --all-targetsreports a pre-existingitems_after_test_moduleonsrc/handler.rs, unrelated to this change.)One note on process: I could not dogfood this through the TUI itself, since I am on a Windows box driving the build through WSL2 without an interactive terminal for tuicr. The diff is small and self-reviewed, but I have not watched
Ycopy a comment in a live session, so a quick manual check on your side would be worth it before merge.