Commit graph

150 commits

Author SHA1 Message Date
Max Brunsfeld
2283ec5de2
Extract an agent_ui crate from agent (#33284)
This PR moves the UI-dependent logic in the `agent` crate into its own
crate, `agent_ui`. The remaining `agent` crate no longer depends on
`editor`, `picker`, `ui`, `workspace`, etc.

This has compile time benefits, but the main motivation is to isolate
our core agentic logic, so that we can make agents more
pluggable/configurable.

Release Notes:

- N/A
2025-06-23 18:00:28 -07:00
Peter Tripp
bd8471bb40
agent: Add soft-wrap to long terminal command JSON (#33188)
Closes: https://github.com/zed-industries/zed/issues/33179

| Before | After | 
| - | - |
| <img width="341" alt="Screenshot 2025-06-21 at 23 06 01"
src="https://github.com/user-attachments/assets/963a3663-b24f-4946-8b48-2c1222cdef2e"
/> | <img width="424" alt="Screenshot 2025-06-21 at 23 08 13"
src="https://github.com/user-attachments/assets/51051221-fda2-48af-ae42-a04989bb4913"
/> |

Release Notes:

- N/A
2025-06-23 08:35:16 -03:00
Danilo Leal
16f1da1b7e
agent: Fix long previous user message double scroll (#33056)
Previously, if editing a long previous user message in the thread, you'd
have a double scroll situation because the editor used in that case had
its max number of lines capped. To solve that, I made the `max_lines` in
the editor `AutoHeight` mode optional, allowing me to not pass any
arbitrary number to the previous user message editor, and ultimately,
solving the double scroll problem by not having any scroll at all.

Release Notes:

- agent: Fixed double scroll that happened when editing a long previous
user message.

@ConradIrwin adding you as a reviewer as I'm touching editor code
here... want to be careful. :)
2025-06-23 08:32:05 -03:00
Danilo Leal
b9838efaaa
agent: Add button to scroll to top of the thread (#33130)
Release Notes:

- agent: Added a button to scroll to top of the thread.
2025-06-20 20:28:07 -03:00
Danilo Leal
b89ddf3a6e
agent: Improve layout shift on previous message editor (#33055)
Follow up to https://github.com/zed-industries/zed/pull/32765.

This PR creates a slot for the `message_editor::create_editor` to allow
using different values for min and max lines. In practice, the panel's
main editor now has a minimum of 4 lines, whereas the previous message
editor has just one. This makes the layout shift when clicking on a
previous message to edit it much smaller.

Release Notes:

- agent: Improved layout shift when clicking to edit a previous sent
message.
2025-06-19 15:23:33 -03:00
Danilo Leal
5c7e90d494
agent: Move focus to the panel after sending a user message edit (#33049)
Follow up to https://github.com/zed-industries/zed/pull/31611.
Closes https://github.com/zed-industries/zed/issues/33005.

Release Notes:

- agent: Fixed a bug where, after confirming editing a previous user
message while zoomed in, the focus went to the buffer and the panel got
closed.
2025-06-19 14:38:37 -03:00
Danilo Leal
61abfd5930
agent: Avoid layout shift due to the "waiting for confirmation" label (#33046)
Just a tiny, one-line change to avoid the "Waiting for Confirmation"
animated label pushing the "allow" buttons to the side.

Release Notes:

- agent: Fixed layout shift in "waiting for confirmation" state in the
terminal card.
2025-06-19 16:27:18 +00:00
Richard Feldman
5405c2c2d3
Standardize on u64 for token counts (#32869)
Previously we were using a mix of `u32` and `usize`, e.g. `max_tokens:
usize, max_output_tokens: Option<u32>` in the same `struct`.

Although [tiktoken](https://github.com/openai/tiktoken) uses `usize`,
token counts should be consistent across targets (e.g. the same model
doesn't suddenly get a smaller context window if you're compiling for
wasm32), and these token counts could end up getting serialized using a
binary protocol, so `usize` is not the right choice for token counts.

I chose to standardize on `u64` over `u32` because we don't store many
of them (so the extra size should be insignificant) and future models
may exceed `u32::MAX` tokens.

Release Notes:

- N/A
2025-06-17 10:43:07 -04:00
Michael Sloan
681c88d4e7
Fix clicking in to agent message editor and tighten up vertical spacing (#32765)
* Adds `min_lines` to `EditorMode::AutoHeight` and use `min_lines: 4` in
agent message editor. This makes it so that clicks in the blank space
below the first line of the editor also focus it, instead of needing to
click the very first line.

* Removes the div wrapping the editor, as it was only there to set
`min_h_16()`. This also tightens up the min space given to the editor -
before it was not evenly dividing the number of lines.

* Further tightens up vertical spacing by using `gap_1` instead of
`gap_4` between editor and controls below

At 4 line min height (after on the left, before on the right):


![image](https://github.com/user-attachments/assets/e8eefb1b-9ea3-4f98-ad55-25f95760d61f)

At 5 lines, one more than min height (after on the left, before on the
right):


![image](https://github.com/user-attachments/assets/a6ba737c-6a56-4343-a55a-d264f2a06377)

Release Notes:

- Agent: Fixed clicking to focus the message editor to also work for
clicks below the last line.
2025-06-15 18:45:44 +00:00
Ben Brandt
b3a8816c0e
agent: Add completion cancellation when editing messages (#32533)
When editing a message, cancel any in-progress completion before
starting a new request to prevent overlapping model responses.

Release Notes:

- agent: Fixed previous completion not cancelling when editing a
previous message
2025-06-11 09:36:21 +00:00
Danilo Leal
3db00384f4
agent: Improve generating dots display (#32421)
Previously, upon hitting the "Continue" button to restart an interrupted
thread due to consecutive tool calls reaching its limit, you wouldn't
see the loading dots and the UI would be a weird state. This PR improves
when these loading dots actually show up, including in their conditional
a check for `message.is_hidden`.

Also took advantage of the opportunity to quickly organize some of these
variables. The `render_message` function could potentially be chopped up
in more smaller pieces. Lots of things going on here.

Release Notes:

- N/A
2025-06-09 20:52:50 -03:00
Ben Brandt
709523bf36
Store profile per thread (#31907)
This allows storing the profile per thread, as well as moving the logic
of which tools are enabled or not to the profile itself.

This makes it much easier to switch between profiles, means there is
less global state being changed on every profile change.

Release Notes:

- agent panel: allow saving the profile per thread

---------

Co-authored-by: Ben Kunkle <ben.kunkle@gmail.com>
2025-06-06 12:05:27 +00:00
Bennet Bo Fenner
aefb798090
inline assistant: Allow to attach images from clipboard (#32087)
Noticed while working on #31848 that we do not support pasting images as
context in the inline assistant

Release Notes:

- agent: Add support for attaching images as context from clipboard in
the inline assistant
2025-06-04 16:43:52 +00:00
Umesh Yadav
7d54d9f45e
agent: Show warning for image context pill if model doesn't support images (#31848)
Closes #31781

Currently we don't any warning or error if the image is not supported by
the current model in selected in the agent panel which leads for users
to think it's supported as there is no visual feedback provided by zed.
This PR adds a warning on image context pill to show warning when the
model doesn't support it.

| Before | After |
|--------|-------|
| <img width="374" alt="image"
src="https://github.com/user-attachments/assets/da659fb6-d5da-4c53-8878-7a1c4553f168"
/> | <img width="442" alt="image"
src="https://github.com/user-attachments/assets/0f23d184-6095-47e2-8f2b-0eac64a0942e"
/> |

Release Notes:

- Show warning for image context pill in agent panel when selected model
doesn't support images.

---------

Signed-off-by: Umesh Yadav <git@umesh.dev>
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2025-06-04 16:20:56 +00:00
Conrad Irwin
03357f3f7b
Fix panic when re-editing old message with creases (#32017)
Co-authored-by: Cole Miller <m@cole-miller.net>

Release Notes:

- agent: Fixed a panic when re-editing old messages

---------

Co-authored-by: Cole Miller <m@cole-miller.net>
Co-authored-by: Cole Miller <cole@zed.dev>
2025-06-03 20:56:18 +00:00
Danilo Leal
9e75871d48
agent: Make the sound notification play only if Zed is in the background (#31975)
Users were giving feedback about the sound notification being
annoying/unnecessary if Zed is in the foreground, which I agree! So,
this PR changes it so that it only plays if that is not the case.

Release Notes:

- agent: Improved sound notification behavior by making it play only if
Zed is in the background.
2025-06-03 11:14:26 -03:00
Danilo Leal
63c1033448
agent: Generate a notification when reaching tool use limit (#31894)
When reaching the consecutive tool call limit, the agent gets blocked
and without a notification, you wouldn't know that. This PR adds the
ability to be notified when that happens, and you can use either sound
_and_ toast, or just one of them.

Release Notes:

- agent: Added support for getting notified (via toast and/or sound)
when reaching the consecutive tool call limit.
2025-06-02 21:57:42 -03:00
Michael Sloan
9086784038
gpui: Support hitbox blocking mouse interaction except scrolling (#31712)
tl;dr: This adds `.block_mouse_except_scroll()` which should typically
be used instead of `.occlude()` for cases when the mouse shouldn't
interact with elements drawn below an element. The rationale for
treating scroll events differently:

* Mouse move / click / styles / tooltips are for elements the user is
interacting with directly.
* Mouse scroll events are about finding the current outer scroll
container.

Most use of `occlude` should probably be switched to this, but I figured
I'd derisk this change by minimizing behavior changes to just the 3 uses
of `block_mouse_except_scroll`.

GPUI changes:

* Added `InteractiveElement::block_mouse_except_scroll()`, and removes
`stop_mouse_events_except_scroll()`

* Added `Hitbox::should_handle_scroll()` to be used when handling scroll
wheel events.

* `Window::insert_hitbox` now takes `HitboxBehavior` instead of
`occlude: bool`.

    - `false` for that bool is now `HitboxBehavior::Normal`.

    - `true` for that bool is now `HitboxBehavior::BlockMouse`.
    
    - The new mode is `HitboxBehavior::BlockMouseExceptScroll`.

* Removes `Default` impl for `HitboxId` since applications should not
manually create `HitboxId(0)`.

Release Notes:

- N/A
2025-05-29 21:41:15 +00:00
Marshall Bowers
a23ee61a4b
Pass up intent with completion requests (#31710)
This PR adds a new `intent` field to completion requests to assist in
categorizing them correctly.

Release Notes:

- N/A

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2025-05-29 20:43:12 +00:00
Danilo Leal
68724ea99e
agent: Make clicking on the backdrop to dismiss message editing more reliable (#31614)
Previously, the click on the backdrop to dismiss the message editing was
unreliable. You would click on it and sometimes it would work and others
it wouldn't. This PR fixes that now.

Release Notes:

- agent: Fixes the previous message dismissal by clicking on the
backdrop
2025-05-28 15:29:52 -03:00
Danilo Leal
e12106e025
agent: Move focus to the panel after dismissing a user message edit (#31611)
Previously, when you clicked on a previous message to edit it and then
dismissed it, your focus would jump to the buffer. This caught me
several times as the most obvious place to return to for me was the
agent panel main message editor, so I can continue prompting something
else. And this is what this PR changes.

Release Notes:

- agent: Improved previous message editing UX by returning focus to the
main panel's text area after dismissing it.
2025-05-28 15:24:58 -03:00
Danilo Leal
0731097ee5
agent: Improve consecutive tool call UX and rebrand Max Mode (#31470)
This PR improves the consecutive tool call UX by allowing users to
quickly continue an interrupted with one-click. What we do here is
insert a hidden "Continue" message that will just nudge the LLM to keep
going. We're also using the opportunity to upsell the previously called
"Max Mode", now rebranded as "Burn Mode", which allows users to don't be
interrupted anymore if they ever have 25 consecutive tool calls again.

Release Notes:

- agent: Improve consecutive tool call UX by allowing users to quickly
continue an interrupted thread with one click.

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
Co-authored-by: Agus Zubiaga <hi@aguz.me>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
2025-05-27 19:44:10 -03:00
Richard Feldman
f54c057001
Add warning message when editing a message in a thread (#31508)
<img width="479" alt="Screenshot 2025-05-27 at 9 42 44 AM"
src="https://github.com/user-attachments/assets/7bd9e1b9-26b4-4396-9f93-e92a5f4ac2e1"
/>

Release Notes:

- Added notice that editing a message in the agent panel will restart
the thread from that point.

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-05-27 16:26:47 -04:00
Marshall Bowers
8faeb34367
Rename assistant_settings to agent_settings (#31513)
This PR renames the `assistant_settings` crate to `agent_settings`, as
well a number of constructs within it.

Release Notes:

- N/A
2025-05-27 15:16:55 +00:00
Danilo Leal
d211f88d23
agent: Add sound notification when done generating (#31472)
This PR adds the ability to hear a sound notification when the agent is
done generating and/or needs user input. This setting is turned off by
default and can be used together with the visual notification. The
specific sound I'm using here comes from the [Material Design 2 Sound
Library](https://m2.material.io/design/sound/sound-resources.html#).

Release Notes:

- agent: Added the ability to have a sound notification when the agent
is done generating and/or needs user input.
2025-05-26 21:20:41 -03:00
Mani Rash Ahmadi
51b25b5c22
agent: Ensure context meter updates when context is cleared (#30320)
Addresses an issue where the agent context token meter in the panel
toolbar (showing usage like "X / Y tokens") failed to update its count
after the user cleared the current context via the context editor UI.
While the meter updated correctly when adding items, clearing them left
the display showing the old count.

The root cause was traced to the `ContextStore::clear` method in
`crates/agent/src/context_store.rs`. This method correctly cleared the
internal data structures holding the context items but neglected to call
`cx.notify()` to inform listeners of the state change. Consequently, the
UI components responsible for displaying the token count were not
triggered to re-render with the new (presumably lower) count.

This PR fixes the issue by adding the missing `cx.notify()` call to the
`ContextStore::clear` method. This ensures listeners are notified when
the context set is cleared, allowing the token meter UI to update
correctly.

Release Notes:

- Fixed an issue where the agent context token meter did not update when
the context was cleared.
2025-05-26 09:51:00 +02:00
Richard Feldman
208f525a11
Don't always scroll to bottom on every new message (#31295)
This is a partial reversion of
https://github.com/zed-industries/zed/pull/30878 - having it always
scroll to bottom whenever a new message is added makes it so that when
you're scrolled up, you don't have time to read what you're trying to
read before it autoscrolls to the end.

@danilo-leal when you're back, we can pair on addressing that in a
different way!

Release Notes:

- Fixed bug where scrolling up in the agent panel didn't prevent
automatic scroll-to-end whenever a new message arrived.
2025-05-23 15:11:29 -04:00
Ben Brandt
0201d1e0b4
agent: Unfollow agent on completion cancellation (#31258)
Handle unfollowing agent and clearing agent location when completion
is canceled.

Release Notes:

- N/A
2025-05-23 14:55:08 +02:00
Danilo Leal
e1a2e8a3aa
agent: Adjust codeblock design across edit file tool call card and Markdown (#30931)
This PR makes the edit tool call codeblock cards expanded by default, to
be consistent with https://github.com/zed-industries/zed/pull/30806.
Also, I am removing the collapsing behavior of Markdown codeblocks where
we'd add a gradient while capping the container's height based on an
arbitrary number of lines. Figured if they're all now initially
expanded, we could simplify how the design/code operates here
altogether.

Open for feedback, as I can see an argument where the previous Markdown
codeblock design of "collapsed but not fully; it shows a preview" should
stay as it is useful.

Release Notes:

- N/A
2025-05-19 06:38:12 +00:00
Max Brunsfeld
1ce2652a89
agent: Create checkpoints when editing a past message (#30831)
Release Notes:

- N/A
2025-05-18 09:02:15 -07:00
Danilo Leal
19e89a8b2d
agent: Scroll to the bottom after sending a new message (#30878)
Closes https://github.com/zed-industries/zed/issues/30572

Release Notes:

- agent: Improved UX by scrolling to the bottom of the thread after
submitting a new message or editing a previous one.
2025-05-17 12:57:00 -03:00
Danilo Leal
f2dcc98216
agent: Improve layout shift in the previous message editor (#30825)
This PR also moves the context strip to be at the top, so it matches the
main message editor, making the arrow-up keyboard interaction to focus
on it to work the same way.

Release Notes:

- agent: Made the previous message editing UX more consistent with the
main message editor.
2025-05-16 11:36:37 -03:00
Danilo Leal
6bec76cd5d
agent: Allow dismissing previous message by clicking on the backdrop (#30822)
Release Notes:

- agent: Improved UX for dismissing an edit to a previous message.
2025-05-16 10:25:21 -03:00
Danilo Leal
0f4e52bde8
agent: Ensure background color is the same even while zoomed in (#30804)
Release Notes:

- agent: Fixed the background color of the agent panel changing if you
zoomed it in.
2025-05-16 06:48:22 -03:00
Danilo Leal
dfe37b0a07
agent: Make Markdown codeblocks expanded by default (#30806)
Release Notes:

- N/A
2025-05-16 06:48:15 -03:00
Danilo Leal
234d6ce5f5
agent: Fix Markdown codeblock header buttons (#30645)
Closes https://github.com/zed-industries/zed/issues/30592

Release Notes:

- agent: Fixed Markdown codeblock header buttons being pushed by long
paths/file names.
2025-05-14 10:49:02 -03:00
Tristan Hume
d01559f9bc
Add setting for enabling/disabling feedback (#30448)
This is useful for enterprises, especially in combination with #30444,
to ensure code never gets sent to Zed.

Release Notes:

- N/A
2025-05-14 15:10:31 +02:00
Richard Feldman
8fdf309a4a
Have read_file support images (#30435)
This is very basic support for them. There are a number of other TODOs
before this is really a first-class supported feature, so not adding any
release notes for it; for now, this PR just makes it so that if
read_file tries to read a PNG (which has come up in practice), it at
least correctly sends it to Anthropic instead of messing up.

This also lays the groundwork for future PRs for more first-class
support for images in tool calls across more image file formats and LLM
providers.

Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <hi@aguz.me>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
2025-05-13 10:58:00 +02:00
Michael Sloan
4deb8cce8d
agent: Fix 10 line code blocks being expandable despite fitting (#30540)
Release Notes:

- N/A
2025-05-12 09:17:37 +00:00
Michael Sloan
5abca0f867
Fix codeblock expansion initial state + refactor (#30539)
Release Notes:

- N/A
2025-05-12 09:05:00 +00:00
Agus Zubiaga
f0da3b74f8
agent: Handle thread title generation errors (#30273)
The title of a (text) thread would get stuck in "Loading Summary..."
when the request to generate it failed. We now handle this case by
falling back to the default title, and letting the user manually edit
the title or retry generating it.



https://github.com/user-attachments/assets/898d26ad-d31f-4b62-9b05-519d923b1b22



Release Notes:

- agent: Handle thread title generation errors

---------

Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2025-05-12 07:45:48 +00:00
Danilo Leal
39da72161f
agent: Make terminal command render with Markdown in the tool card (#30430)
Closes https://github.com/zed-industries/zed/issues/30411

Rendering as markdown gives us text selection and copying for free. In
the future, we may want to explore having these commands be actual
editors, allowing you to step in, change the command, and re-run it
right from there.

Release Notes:

- agent: Made the terminal command in the tool card selectable and
copyable.
2025-05-09 21:53:11 -03:00
Cole Miller
000077facf
agent: Fix reinsertion of creases when editing past messages (#30417)
Just noticed this got lost when main was merged in #29828.

Release Notes:

- agent: Fixed the rendering of added context when editing past messages
in a thread.
2025-05-09 20:53:30 +00:00
Michael Sloan
863d7ccb6d
Fix agent panel scroll while editing a past message (#30394)
This is similar to the `block_mouse_down` method added in #20649 (which
has a very similar motivation), but is more comprehensive in stopping
mouse events. Since I want to cherry-pick this to the releases, keeping
this change just to the agent panel. In a follow-up will replace
existing use of `block_mouse_down` to instead use this.

Release Notes:

- N/A
2025-05-09 15:33:33 +00:00
Michael Sloan
08f516ce9a
Misc improvement of code for agent markdown codeblock (#30388)
Release Notes:

- N/A
2025-05-09 14:48:24 +00:00
Michael Sloan
0abee5668a
Fix text overlap with markdown code block in list in agent response (#30377)
Seems that `h_full` was causing it to use the height of the overall list
item for some reason.

Closes #30002 

Release Notes:

- Agent Panel: Fixed text overlap for code blocks nested in lists in
agent response.
2025-05-09 12:48:16 +00:00
Antonio Scandurra
9f6809a28d
Reuse conversation cache when streaming edits (#30245)
Release Notes:

- Improved latency when the agent applies edits.
2025-05-08 14:36:34 +02:00
Marshall Bowers
6cc6e4d4b3
agent: Rename a number of constructs from Assistant to Agent (#30196)
This PR renames a number of constructs in the `agent` crate from the
"Assistant" terminology to "Agent".

Not comprehensive, but it's a start.

Release Notes:

- N/A
2025-05-08 01:18:51 +00:00
Antonio Scandurra
89430a019c
Fix agent reading and editing files over SSH (#30144)
Release Notes:

- Fixed a bug that would prevent the agent from working over SSH.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Cole Miller <m@cole-miller.net>
2025-05-07 17:07:01 +00:00
Danilo Leal
5ca114be24
agent: Make feedback buttons more minimal (#30133)
Also swapped out the svgs for `ThumbsDown` and `ThumbsUp`, and added
`DocumentText`.

Release Notes:

- N/A
2025-05-07 12:43:46 -03:00