This PR adjusts how the `AssistantPanelDelegate` global is set to be
based on the state of the feature flag.
This should prevent `assistant` and `assistant2` from potentially
clobbering each other.
Release Notes:
- N/A
This PR consolidates the two Assistant panels into one for users in the
`assistant2` feature flag.
Now that the Assistant1 prompt editor is accessible through the
Assistant2 panel, we no longer have a need to show both panels.
Release Notes:
- N/A
`@mention`ed files in assistant2 now get replaced by the full path of
the file in what gets sent to the model, while rendering visually as
just the filename (in a crease, so they can only be selected/deleted as
a whole unit, not character by character).
https://github.com/user-attachments/assets/a5867a93-d656-4a17-aced-58424c6e8cf6
Release Notes:
- N/A
---------
Co-authored-by: João Marcos <joao@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This PR fixes two visual issues, that were caused by the fact that we
were always painting the horizontal scrollbar even if there is no
horizontal scrolling possible
Obscuring deleted lines when using the inline assistant:
https://github.com/user-attachments/assets/f8460c3f-403e-40a6-8622-65268ba2d875
Cutting off text even when horizontal scrolling is not possible:
https://github.com/user-attachments/assets/23c909f7-1c23-4693-8edc-40a2f089d4a8
This issue was only present in some themes (e.g. Nord, Catpuccin)
Closes#22716
Release Notes:
- Fixed an issue where horizontal scrollbars of editors would always be
painted (even if there is no horizontal scrolling to be done)
This PR extracts the streaming diff implementation to its own
`streaming_diff` crate.
It was duplicated between `assistant` and `assistant2`, but their
implementations were exactly the same (and I don't see a reason why they
would need to diverge).
Release Notes:
- N/A
This PR adds a new `prompt_library` crate and extracts the `PromptStore`
and `PromptBuilder` to it.
Eventually we'll want to house the `PromptLibrary` itself in this crate,
but right now that involves untangling a few dependencies.
Release Notes:
- N/A
This PR makes the assistant 2 panel switch work with the keyboard via
the `cmd-e` keybinding.
Release Notes:
- N/A
---------
Co-authored-by: Agus Zubiaga <hi@aguz.me>
This PR removes the `SwitchWithLabel` component because we're adding
`label` as a method to `Switch`. Thus, we no longer need an extra
component just to append a label. Additionally, we're also adding
`keybinding` as a method.
Release Notes:
- N/A
---------
Co-authored-by: Agus Zubiaga <hi@aguz.me>
This PR dedupes the `AssistantSettings` so we can use the same settings
for both Assistant1 and Assistant2.
We originally forked them so we could change the Assistant2 settings
freely, but given our rollout strategy for the new Assistant, I don't
think that makes sense.
This also fixes the issue where the JSON language server would show a
"Matches multiple schemas when only one must validate" warning in
`settings.json`.
Closes#23171.
Release Notes:
- Fixed the "Matches multiple schemas when only one must validate"
warning for the `assistant` setting.
This PR adjusts the design of the assistant 2 threads with the goal of
reducing visual busyness. My intention is to remove the amount of lines
and borders given it is a relatively tight space. It also refines the
"generating" floating container style, finally leveraging linear
gradients that were recently added to GPUI! Now, we only display headers
for "you" messages. Assistant responses will be rendered right in the
panel; not bounded by a card container.
<img width="800" alt="Screenshot 2025-01-14 at 7 08 39 PM"
src="https://github.com/user-attachments/assets/a8ffa780-0ef2-4d4b-ae19-3f02fd2d63a6"
/>
Release Notes:
- N/A
This PR makes it so the pending completion is cleared when an error
occurs.
This makes it so `Thread::is_streaming()` will return `false` in the
error case (and thus hide the streaming indicator in the UI).
Release Notes:
- N/A
Context pills are now focusable and intractable via the keyboard.
- <kbd>←</kbd> and <kbd>→</kbd> move the focus to the previous or next
item (wrapping if necessary)
- <kbd>↓</kbd> and <kbd>↑</kbd> move the focus vertically
- If the cursor is in the first/last row of the assistant/inline editor,
they will move the focus to the strip
- Inside the strip, they will move the focus to the pill horizontally
overlapping the most
- If already in the first/last row of the strip, they will move to the
first/last pill (like in editors)
- If the first/last pill is focused, they will move the focus back to
the editor
- <kbd>⌫</kbd> removes the focused pill (unless it's the suggested one)
- <kbd>⏎</kbd> accepts the suggested pill if focused
https://github.com/user-attachments/assets/040bc71c-a3ae-4961-9886-2d5c3d290a73
Release Notes:
- N/A
This PR is a follow-up to
https://github.com/zed-industries/zed/pull/22911 to further improve the
registration of code action providers for the Assistant in order to
prevent duplicates.
The `CodeActionProvider` trait now has an `id` method that is used to
return a unique ID for a code action provider. We use this to prevent
registering duplicates of the same provider.
The registration of the code action providers for Assistant1 and
Assistant2 have also been reworked. Previously we were not call the
registration function—and thus setting up the subscriptions—until we
resolved the feature flags. However, this could lead to the registration
happening too late for existing workspace items.
We now perform the registration right away and then remove the undesired
code action providers once the feature flags have been resolved.
Release Notes:
- N/A
The new `ContextMenu`-based `ContextPicker` requires initialization when
opened, but we were only doing this for the `ContextStrip` picker, not
the inline one.
Additionally, because we have a wrapper element around ContextMenu, we
need to propagate the `DismissEvent` so that it properly closes when
Escape is pressed.
Release Notes:
- N/A
This PR removes some unneeded `#[allow(unused)]`s from the context types
in Assistant2.
We're using these fields now, so we no longer need to suppress the
unused lint.
Release Notes:
- N/A
We weren't showing the keybinding in none of the places where the model
selector was visible. Also, I took advantage of the opportunity to
change the keybinding for two reasons:
1. `cmd-shift-m` caused conflict if on an editor (inline assistant case)
2. `cmd-opt-/` is the one Cursor uses; so consistency with something
that might be already consolidated sounds like a low-hanging fruit
| Editor Inline Assist | Terminal Inline Assist | Assistant Panel |
|--------|--------|--------|
| <img width="1336" alt="Screenshot 2025-01-10 at 11 01 24 AM"
src="https://github.com/user-attachments/assets/0782f217-025f-4bc0-b2fa-64b3524c968b"
/> | <img width="1336" alt="Screenshot 2025-01-10 at 11 01 29 AM"
src="https://github.com/user-attachments/assets/d05a3b5c-33fd-4593-b1d8-aa9944de816a"
/> | <img width="1336" alt="Screenshot 2025-01-10 at 11 01 33 AM"
src="https://github.com/user-attachments/assets/8cb075e7-ccde-46f5-aa05-d20a9d42b286"
/> |
Release Notes:
- N/A
The context picker will now display up to 6 recent files/threads to add
as a context:
<img
src="https://github.com/user-attachments/assets/80c87bf9-70ad-4e81-ba24-7a624378b991"
width=400>
Note: We decided to use a `ContextMenu` instead of `Picker` for the
initial one since the latter didn't quite fit the design for the
"Recent" section.
Release Notes:
- N/A
---------
Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Piotr <piotr@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
* Now loads context on background threads.
- For file and directory context, buffer ropes can be shared between
threads as they are immutable. This allows for traversal and
accumulation of buffer text on a background thread.
- For url context, the request, parsing, and rendering is now done on a
background thread.
* Prepares for support of buffer reload by individually storing the text
of directory buffers.
* Avoids some string copying / redundant strings.
- When attaching message context, no longer builds a string for each
context type.
- For directory context, does not build a `SharedString` for the full
text, instead has a slice of `SharedString` chunks which are then
directly appended to the message context.
- Building a fenced codeblock for a buffer now computes a precise
capacity in advance.
Release Notes:
- N/A
This PR fixes the duplicated `Fix with Assistant` code actions that were
being shown in the code actions menu.
This fix isn't 100% ideal, as there is an edge case in buffers that are
already open when the workspace loads, as we may not observe the feature
flags in time to register the code action providers by the time we
receive the event that an item was added to the workspace.
Closes https://github.com/zed-industries/zed/issues/22400.
Release Notes:
- Fixed duplicate "Fix with Assistant" entries showing in the code
action list.