assistant2: Make context pill names work like editor tabs (#22741)

Context pills for files will now only display the basename of the file.
If two files have the same base name, we will also show their parent
directories, mimicking the behavior of editor tabs.


https://github.com/user-attachments/assets/ee88ee3b-80ff-4115-9ff9-8fe4845a67d8

Note: The double `/` in the file picker is a known separate issue.

Release Notes:

- N/A

---------

Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Agus Zubiaga 2025-01-07 09:18:46 -03:00 committed by GitHub
parent a827f54022
commit bcc6d95529
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 218 additions and 85 deletions

View file

@ -17,6 +17,8 @@ impl ContextId {
pub struct Context {
pub id: ContextId,
pub name: SharedString,
pub parent: Option<SharedString>,
pub tooltip: Option<SharedString>,
pub kind: ContextKind,
pub text: SharedString,
}
@ -40,7 +42,7 @@ pub fn attach_context_to_message(
for context in context.into_iter() {
match context.kind {
ContextKind::File => {
ContextKind::File { .. } => {
file_context.push_str(&context.text);
file_context.push('\n');
}