Skip to content

agent_ui: Serialize copied selection mentions as links#54031

Merged
NeelChotai merged 9 commits intozed-industries:mainfrom
DevDonzo:codex-agent-copy-selection-links
Apr 23, 2026
Merged

agent_ui: Serialize copied selection mentions as links#54031
NeelChotai merged 9 commits intozed-industries:mainfrom
DevDonzo:codex-agent-copy-selection-links

Conversation

@DevDonzo
Copy link
Copy Markdown
Contributor

@DevDonzo DevDonzo commented Apr 16, 2026

Fixes #53981

Selection mentions inserted from the agent panel are stored as folded placeholder text in the message editor. That meant a normal copy would put the literal selection token on the clipboard, and pasting into a new thread would lose the original mention context.

This teaches MessageEditor to serialize selected folded mentions as their mention links before writing to the clipboard. The surrounding text stays intact, and the existing paste path can rebuild the mentions in a fresh thread.

Release Notes:

  • Fixed copied agent prompts replacing selection mentions with the literal word selection.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 16, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, bennetbo and osyvokon and removed request for a team April 16, 2026 03:06
@NeelChotai NeelChotai assigned NeelChotai and unassigned bennetbo Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 13:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes copying/cutting text from the Agent panel message editor so that folded “selection” mentions are serialized to their mention links (e.g. [@…](...)) instead of the literal placeholder text, allowing paste into a new thread to reconstruct mentions.

Changes:

  • Added copy/cut action interception in MessageEditor to serialize selected mention creases as mention links when writing to the clipboard.
  • Added MentionSet::mention_uri_for_crease to look up a mention URI given a crease id.
  • Added tests covering copy/cut serialization behavior for selection mentions and paste round-tripping.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/agent_ui/src/message_editor.rs Intercepts copy/cut, adds serialized_copy_text mention-aware serialization, and adds tests for copy/cut + paste behavior.
crates/agent_ui/src/mention_set.rs Exposes crease-id → mention-URI lookup used during serialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/agent_ui/src/message_editor.rs
Comment thread crates/agent_ui/src/message_editor.rs Outdated
@NeelChotai
Copy link
Copy Markdown
Member

Nice! Thank you for the contribution.

@NeelChotai NeelChotai enabled auto-merge April 23, 2026 14:28
The WHATWG URL parser normalizes `\` to `/` inside `file://` URLs, so
`MentionUri::parse` must convert them back on Windows so the resulting
`PathBuf` matches how worktrees store absolute paths (native
separators).
@NeelChotai NeelChotai disabled auto-merge April 23, 2026 16:23
@NeelChotai NeelChotai enabled auto-merge April 23, 2026 16:31
@NeelChotai NeelChotai added this pull request to the merge queue Apr 23, 2026
Merged via the queue into zed-industries:main with commit 4733ae4 Apr 23, 2026
54 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copying prompt with code selections pastes only the word “selection” and discards original input in the Agent Panel

5 participants