Repository navigation
feat(ui): right-click context menus across the app - #575
Merged
Merged
Conversation
…inal and composer
Every text field gets Cut / Copy / Paste / Select All on right-click,
built in the Input wrapper from the editor's own capabilities. The
Markdown view's menu no longer needs a link under the pointer: it offers
Copy (with a window selection) and Select All, then the link, code block
("Copy code") or image under the pointer, then the hosting surface's own
items through a new `menu_extension` hook.
Shared menu actions (CopyText, OpenUrl, OpenPath, OpenPathInZed,
RevealPath) are handled by every context-menu trigger, with
`path_items` and `selection_items` as reusable groups; the two local
`open_in_zed` helpers collapse into one.
Surfaces gaining a menu: assistant and user messages (copy message,
rewind modes), user attachments, tool-call and command rows (copy
command / input / output / text), error cards, changed-file chips and
live edit rows (view diff, path items), proposed plan cards and the plan
panel (copy / download / save), the chat header title, diff file headers
(path items) and code rows (copy line, copy selected lines, add
comment), terminal tabs (restart, split, close), composer context chips,
queued messages (copy, send now, edit, remove), pending images, and the
provider update command.
Co-Authored-By: Claude <noreply@anthropic.com>
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.
What changes
Right-click menus for every surface that lacked one. Before this, only Markdown links, sidebar project headers, thread rows and the terminal pane had a menu; text inputs had none on desktop (gpui-base only shows one when a handler is registered, and none was).
widgets/input.rs): Cut / Copy / Paste / Select All on right-click for everyInputandTextarea, from the editor's ownInputContextMenuCapabilities, items disabled rather than hidden. Choices are forwarded to the field's focus handle, as the touch edit menu already does.Copy) and Select All, then the link, code block ("Copy code") or image under the pointer (open image, copy image address, or path items for a local file), then the hosting surface's items via a newMarkdownView::menu_extensionhook.pending_context_linkbecame aPendingContextTargetenum.widgets/menu.rs):CopyText,OpenUrl,OpenPath,OpenPathInZed,RevealPathare handled by everyContextMenutrigger, so a surface can offer them without wiring handlers.PopupMenu::path_itemsandselection_itemsare the reusable groups. The two identicalopen_in_zedhelpers in chat and markdown collapse into one here.PlanMenuaction the chat's plan card also dispatches.Not touched: the preview panel (a wry webview with the system's own native menu) and the terminal pane menu, which was already complete.
Tests
markdown::view::tests::right_click_off_link_is_swallowed_so_no_menu_opensstated the old contract (no menu on plain text). It is rewritten asright_click_on_text_opens_the_selection_menu_and_is_swallowed: a plain-text right-click still does not propagate, now opens the view's menu, Select All from it selects the view, and Copy then writes the selection to the clipboard. Both right-click tests now mount undergpui_base::Root, as the shell does, since Root owns Copy for the window selection.link_context_menu_action_opens_the_urladjusts its keystrokes for the two items now preceding "Open link".changed_filesprobe andgallery_supporttake the newcwd/rewind_menuparameters.Checks run
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo nextest run -p tcode-ui— 349 passed