Skip to content

agent_ui: Auto-capture file context on paste#42982

Merged
bennetbo merged 9 commits intozed-industries:mainfrom
ddoemonn:agent-paste-context
Dec 8, 2025
Merged

agent_ui: Auto-capture file context on paste#42982
bennetbo merged 9 commits intozed-industries:mainfrom
ddoemonn:agent-paste-context

Conversation

@ddoemonn
Copy link
Contributor

Closes #42972

Screen.Recording.2025-11-18.at.18.12.20.mov

Release Notes:

  • Added automatic file context detection when pasting code into the AI agent panel. Pasted code now displays as collapsible badges showing the file path and line numbers (e.g., "app/layout.tsx (18-25)").

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 18, 2025
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Nov 18, 2025
@SomeoneToIgnore SomeoneToIgnore added the area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Nov 18, 2025
@JosephTLyons
Copy link
Collaborator

Hey, thank you for the PR @ddoemonn. Would you be able to look at the failing tests? If you need help, someone on the pr review team should be sweeping through at some point, but not sure when.

@ddoemonn
Copy link
Contributor Author

@JosephTLyons I'm so sorry for late response I was busy about git issues assigned to me in Zed.

I will look at failing tests as soon as possible

@ddoemonn
Copy link
Contributor Author

It's ready! @danilo-leal @JosephTLyons

@danilo-leal danilo-leal changed the title Auto-capture file context on paste to agent panel agent_ui: Auto-capture file context on paste Nov 23, 2025
@bennetbo bennetbo self-assigned this Dec 1, 2025
Copy link
Member

@bennetbo bennetbo left a comment

Choose a reason for hiding this comment

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

Pushed a bunch of fixes & cleanup. Should be good to merge now, thank you!

@bennetbo bennetbo merged commit f6a6630 into zed-industries:main Dec 8, 2025
23 checks passed
@franciskafyi franciskafyi moved this from Community Champion PRs to Done in Quality Week – December 2025 Dec 11, 2025
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
Closes zed-industries#42972


https://github.com/user-attachments/assets/98f2d3dc-5682-4670-b636-fa8ea2495c69

Release Notes:

- Added automatic file context detection when pasting code into the AI
agent panel. Pasted code now displays as collapsible badges showing the
file path and line numbers (e.g., "app/layout.tsx (18-25)").

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
Closes zed-industries#42972


https://github.com/user-attachments/assets/98f2d3dc-5682-4670-b636-fa8ea2495c69

Release Notes:

- Added automatic file context detection when pasting code into the AI
agent panel. Pasted code now displays as collapsible badges showing the
file path and line numbers (e.g., "app/layout.tsx (18-25)").

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
@apcamargo
Copy link

Is it possible to allow users to paste raw strings if they choose? Context is not always needed, so making Ctrl+Shift+V / Cmd+Shift+V paste raw strings would be useful.

@admtech
Copy link

admtech commented Dec 17, 2025

How can I deactivate this feature again? I can no longer see what I copied into the agent field. For me, it's often just words, db-fields or short sentences, and I don't want it to display only lines 1-20 or something similar. Please let us toggle it on or off through the settings. This feature is disrupting my entire development process. Let users decide whether they want to activate it or not.

Addendum: This is the most idiotic feature I've seen here so far. I want to copy a field name, an attribute, a database field, or something similar into the agent input, and I only get a 'file.php (123:129)'. Please turn this off immediately!

@joaqo
Copy link

joaqo commented Dec 18, 2025

Yeah this is kinda dumb, specially considering we have the @Selection feature in the agent chat for this exact use case.

@makscee
Copy link

makscee commented Dec 18, 2025

Yeah this is kinda dumb, specially considering we have the @Selection feature in the agent chat for this exact use case.

exactly, no idea why this feature would even exist, but introducing it to break existing behavior without an option to disable is just insane

@jamesthurley
Copy link
Contributor

jamesthurley commented Dec 18, 2025

I can see why this feature is kinda cool, but it needs a way to bypass it and I'd be happy with Cmd+Shift+V as @apcamargo suggested.

99% of the time I'm just copying a simple string like a function name (otherwise I'd use @Selection), and I can't do that any more.

As a workaround I'm now copying the string, doing Cmd+Space to open spotlight, Cmd+V to paste the string there, Cmd+A then Cmd+X to copy it again, Esc to close spotlight, and finally Cmd+V to paste the plain text into the agent window. There must be a simpler way 😅

@ddoemonn ddoemonn deleted the agent-paste-context branch December 18, 2025 10:11
@esthertrapadoux
Copy link

Hey everyone, I've asked the team to look at this PR again and take your feedback into consideration.

Also want to drop a note that while the current deployment may not fit your workflow and that's clearly frustrating some of our users, let's stick with the actionable, honest feedback bits and leave the rest out of it.

@admtech
Copy link

admtech commented Dec 18, 2025

Is it possible to allow users to paste raw strings if they choose? Context is not always needed, so making Ctrl+Shift+V / Cmd+Shift+V paste raw strings would be useful.

I would do it the exact opposite way. The normal behavior as always with Copy&Paste (Ctrl+V) and when pressing Ctrl+Shift+V you could use this feature - but only if it is activated in the settings.

I struggled with this feature all day yesterday and I internally exploded every time I wanted to copy a database field. Please make this feature optional. I can't think of any reason why we need this feature. If I want to give the AI multiple lines, I tell it the function name or simply say 'line 20 to 150'. Additionally, there is the inline assistant that reacts to my marked code.

But why lines numbers instead of content are pasted into the agent field is still a complete mystery to me after 2 days of intensive use. What is this feature good for?

I find Zed absolutely fantastic, but with actions like this one or the removal of the @-icon when adding files a few months ago, you're really not making it easy for developers to continue using Zed daily. Why don't you make such fundamental interface changes optional?

@m-ar-c
Copy link

m-ar-c commented Dec 18, 2025

Also want to drop a note that while the current deployment may not fit your workflow and that's clearly frustrating some of our users, let's stick with the actionable, honest feedback bits and leave the rest out of it.

It's not (only) a question of user workflow preference. The issue with this change is that we now have no way anymore to copy raw text in the agent panel (the convoluted and horrible workaround of first copying the text in another software doesn't count).

So while this PR doesn't add much value IMO (we could already do the same thing with selection) it breaks another basic feature.

@danilo-leal
Copy link
Member

Hey all — we're working on a follow-up iteration linked above, but here goes the link again #45254. We'll make it so cmd-shift-v pastes the raw text and also if you copy just one line, pasting it will paste the raw text. Appreciate everyone chiming in here!

@joaqo
Copy link

joaqo commented Dec 18, 2025

Thats awesome to hear @danilo-leal, thanks! Would this cmd-shift-v be remapable? Asking for the people that want paste to just be paste, and will use @Selection for this use case.

bennetbo added a commit that referenced this pull request Dec 18, 2025
Follow up to #42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
@danilo-leal
Copy link
Member

Yes, you'll be able to remap it normally the same way as any other action 👍

bennetbo added a commit that referenced this pull request Dec 18, 2025
Follow up to #42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
bennetbo added a commit that referenced this pull request Dec 18, 2025
Follow up to #42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
@kch
Copy link

kch commented Dec 18, 2025

Yet another workaround for the Mac until this is live: pbpaste -Prefer txt | pbcopy

@bennetbo
Copy link
Member

bennetbo commented Dec 18, 2025

We just released new stable/preview versions, in which we adjusted this:

  • Pasting single lines/words inserts the raw text
  • Pasting multiple lines from the same codebase inserts the creases (including the file path of the pasted text)
  • Pasting via cmd-shift-v (agent: Paste raw) always inserts the raw text

If you'd still like to opt-out of inserting creases for multiline texts, you can rebind cmd/ctrl-v like this:

{
    "context": "MessageEditor > Editor",
    "bindings": {
        "cmd-v": "agent::PasteRaw",
    }
}

@kch
Copy link

kch commented Dec 19, 2025

@bennetbo why the default keymap file has && !Picker too?

I also added

  {
    "context": "ContextEditor > Editor",
    "bindings": {
      "cmd-v": "agent::PasteRaw"
    },
  },

@jamesthurley
Copy link
Contributor

@bennetbo Thanks for getting an update out so quickly. I think the new default behaviour works well.

rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
Follow up to #42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…tries#45254)

Follow up to zed-industries#42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…tries#45254)

Follow up to zed-industries#42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Feb 15, 2026
…tries#45254)

Follow up to zed-industries#42982

Release Notes:

- agent: Allow pasting code without formatting via ctrl/cmd-shift-v.
- agent: Fixed an issue where pasting a single line of code would always
insert an @mention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

Development

Successfully merging this pull request may close these issues.

AI: Agent panel doesn't automatically capture file context when pasting code