Skip to content

feat(ui): copy the comment at the cursor with Y - #570

Merged
agavra merged 1 commit into
agavra:mainfrom
Dhevenddra:feat-yank-comment-at-cursor
Aug 11, 2026
Merged

feat(ui): copy the comment at the cursor with Y#570
agavra merged 1 commit into
agavra:mainfrom
Dhevenddra:feat-yank-comment-at-cursor

Conversation

@Dhevenddra

Copy link
Copy Markdown
Contributor

Fixes #569.

Problem

dd deletes the comment at the cursor, but there was no way to copy just that one. y exports the whole review, and visual-mode y copies diff text only: content_for_side (src/app/navigation.rs:540) returns None for comment annotations, so dragging over a comment box yanks nothing. Getting one comment out meant leaving the TUI for tuicr review comments --session ... | jq, which needs an id you cannot see from the box you are looking at.

Fix

Y in normal mode copies the content of the comment under the cursor.

  • App::comment_content_at_cursor resolves through find_comment_at_cursor, the same lookup dd and i use, so Y and dd always agree on which comment the cursor is on. It carries over the side guard the delete path uses for line comments.
  • The handler copies with copy_text_to_clipboard, so pbcopy, OSC 52, xclip and wl-copy behave exactly as they do for y, including the "(via terminal)" message.
  • y and visual-mode y are untouched.

Remote threads are deliberately out of scope: they are read-only in v1 and their bodies live in forge_review_threads rather 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.md both list the new key.

Evidence

cargo test:

test result: FAILED. 1300 passed; 2 failed; 2 ignored

The two failures are should_discover_worktree_with_relativeworktrees_extension and default_preference_routes_reftable_repo_to_cli. Both fail identically on an unmodified checkout of 8323f13 here, because this box runs git 2.43.0, which predates the relativeworktrees and reftable extensions. Nothing else fails.

New tests:

  • should_yank_only_the_comment_under_the_cursor puts 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_comment pins the None path on a plain diff line.
  • should_map_lowercase_and_uppercase_y_to_separate_yank_actions pins y and Y to different actions.

cargo fmt --all --check and cargo clippy -- -D warnings are both clean. (clippy --all-targets reports a pre-existing items_after_test_module on src/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 Y copy a comment in a live session, so a quick manual check on your side would be worth it before merge.

`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.

@agavra agavra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @Dhevenddra

@agavra
agavra merged commit 4df1ce3 into agavra:main Aug 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy a single comment to the clipboard (Y at cursor, symmetric with dd)

2 participants