Assistant Context Area for Panel
Check for existing issues
- [X] Completed
Describe the feature
In order to be productive with Zed's assistant panel, you have to copy paste code and error context over. Often, a decent context injection prompt looks like this:
System:
File crates/gpui/src/geometry.rs:
//! The GPUI geometry module is a collection of types and traits that //! can be used to describe common units, concepts, and the relationships //! between them. use core::fmt::Debug; use derive_more::{Add, AddAssign, Div, DivAssign, Mul, Neg, Sub, SubAssign} ... rest of copy/pasted code...Error:
Compiling gpui v0.1.0 (/Users/kylekelley/code/src/github.com/zed-industries/zed/crates/gpui) error[E0599]: the method `step_by` exists for struct `Range<Pixels>`, but its trait bounds were not satisfied --> crates/gpui/src/geometry.rs:2954:46 | 2011 | pub struct Pixels(pub f32); | ----------------- doesn't satisfy `geometry::Pixels: std::iter::Step` ... 2954 | for y in (Pixels(1.0)..Pixels(10.0)).step_by(Pixels(2.0)) { | ^^^^^^^ method cannot be called on `Range<Pixels>` due to unsatisfied trait bounds | ::: /Users/kylekelley/.rustup/toolchains/1.76-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/range.rs:80:1 | 80 | pub struct Range<Idx> { | --------------------- doesn't satisfy `std::ops::Range<geometry::Pixels>: Iterator` | = note: the following trait bounds were not satisfied: `geometry::Pixels: std::iter::Step` which is required by `std::ops::Range<geometry::Pixels>: Iterator` `std::ops::Range<geometry::Pixels>: Iterator` which is required by `&mut std::ops::Range<geometry::Pixels>: Iterator` note: the trait `std::iter::Step` must be implemented --> /Users/kylekelley/.rustup/toolchains/1.76-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/range.rs:26:1 | 26 | pub trait Step: Clone + PartialOrd + Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^You:
I'm trying to add the step_by method to Pixels so I can iterate over a range of pixels. My main goal is being able to write code like this:
for y in (start_y..end_y).step_by(square_size) { // paint a quad }
That'll give me good results to pair with the model for the first message. As I converse with the assistant all that old context sticks around unless I scroll back to delete it. Sometimes that takes up too much of the token limit and other times it can confuse the assistant to have all this extra context around.
Proposal
Introduce context into the assistant panel.
The context view shows to the user what the current context is that will be sent to the model, including:
- File Context
- Project Diagnostics
- Deep Code Context (tree sitter queries, general search against the code base, other tools the model can call on)
The user would have the option of disabling sending any amount of context to the model.
On the model's side, it'll see this as a collection of system messages or tools available for it to call. Importantly, previous contexts don't have to be sent to the model -- only the most recent up to date version.
As you refactor your code, make changes, etc., the context sent should be up to date and wouldn't include old context (unless necessary).
If applicable, add mockups / screenshots to help present your vision of the feature
Why is it enabled by default and how to change it's behaviour so I have to explicitly allow this?
This feature looks very promising. Is there a way to include more the one file as a context?
Surely, I'm aware of context length token limits.
/file command in assistant panel to include whole files.
"Assistant: quote selection" to insert current editor selection into assistant, or "Assistant: Insert into editor" to go the other direction.
Closing as this is finished in its own way with folds, commands, and prompts.