# markdown: Add "Copy Link" to right-click context menu \(\#53758\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/481407479d3c7e1a0943090d63b606ff3b02d064)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 481407479d3c7e1a0943090d63b606ff3b02d064

Requested commit: 481407479d3c7e1a0943090d63b606ff3b02d064

Commit: 481407479d3c7e1a0943090d63b606ff3b02d064

Tree: 26ed8103d0c5b80b896d2a8455e25b809dc007c8

Author: saberoueslati

Committer: GitHub

## Message

```
markdown: Add "Copy Link" to right-click context menu (#53758)

## Context

Closes #53741

Right-clicking on a link in any Markdown view showed no way to copy the
URL. The right-click handler already detected links for left-click
navigation, but the context menu was never extended to surface a
link-specific action.

Video of the manual test below :

[Screencast from 2026-04-13
00-29-49.webm](https://github.com/user-attachments/assets/fbde09ab-78da-4366-b1e0-e15e0d43442b)

## How to Review

- **`crates/markdown/src/markdown.rs`** — Added a `context_menu_link:
Option<SharedString>` field to `Markdown`. Added
`capture_for_context_menu(link)` (replaces the old
`capture_selection_for_context_menu`) which saves both selected text and
the hovered link together. Added a `context_menu_link()` accessor.
Updated the capture-phase right-click handler to detect the link under
the cursor via `rendered_text.link_for_source_index`. Added a
`event.button != MouseButton::Right` guard to the bubble-phase
`MouseDownEvent` handler to prevent selection logic from running on
right-click.

- **`crates/agent_ui/src/conversation_view/thread_view.rs`** — In
`render_message_context_menu`, after computing `has_selection`, also
reads `context_menu_link` from the same markdown chunks. Adds a "Copy
Link" entry with a separator at the top of the menu when a link URL is
present.

- **`crates/markdown_preview/src/markdown_preview_view.rs`** — Wraps the
markdown element in a `right_click_menu` with a "Copy Link" entry (when
a link is present).

Edit: There was a mention of a "Copy" and "Copy as Markdown" buttons.
After discussion, it was decided that I would re-add them fully fleshed
out in a separate PR

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the UI/UX checklist
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Added "Copy Link" to the right-click context menu when clicking on a
  link in Markdown views (agent panel and Markdown preview)
```

## Parents

- [80ab7481254581cb3b7316fc05cc6019c6305930](https://git.cafe/gitcafe/zed/commit/80ab7481254581cb3b7316fc05cc6019c6305930?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/481407479d3c7e1a0943090d63b606ff3b02d064?format=markdown)
