agent: Remove unused code (#28552)

This code was used before we had a proper completion menu for
at-mentions

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-04-11 17:45:51 -06:00 committed by GitHub
parent b22faf96e0
commit 0036a33263
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 198 deletions

View file

@ -34,12 +34,6 @@ use crate::context_store::ContextStore;
use crate::thread::ThreadId; use crate::thread::ThreadId;
use crate::thread_store::ThreadStore; use crate::thread_store::ThreadStore;
#[derive(Debug, Clone, Copy)]
pub enum ConfirmBehavior {
KeepOpen,
Close,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum ContextPickerMode { enum ContextPickerMode {
File, File,
@ -105,7 +99,6 @@ pub(super) struct ContextPicker {
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
thread_store: Option<WeakEntity<ThreadStore>>, thread_store: Option<WeakEntity<ThreadStore>>,
confirm_behavior: ConfirmBehavior,
_subscriptions: Vec<Subscription>, _subscriptions: Vec<Subscription>,
} }
@ -114,7 +107,6 @@ impl ContextPicker {
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
thread_store: Option<WeakEntity<ThreadStore>>, thread_store: Option<WeakEntity<ThreadStore>>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
@ -143,7 +135,6 @@ impl ContextPicker {
workspace, workspace,
context_store, context_store,
thread_store, thread_store,
confirm_behavior,
_subscriptions: subscriptions, _subscriptions: subscriptions,
} }
} }
@ -166,37 +157,32 @@ impl ContextPicker {
let modes = supported_context_picker_modes(&self.thread_store); let modes = supported_context_picker_modes(&self.thread_store);
let menu = menu menu.when(has_recent, |menu| {
.when(has_recent, |menu| { menu.custom_row(|_, _| {
menu.custom_row(|_, _| { div()
div() .mb_1()
.mb_1() .child(
.child( Label::new("Recent")
Label::new("Recent") .color(Color::Muted)
.color(Color::Muted) .size(LabelSize::Small),
.size(LabelSize::Small), )
) .into_any_element()
.into_any_element()
})
}) })
.extend(recent_entries) })
.when(has_recent, |menu| menu.separator()) .extend(recent_entries)
.extend(modes.into_iter().map(|mode| { .when(has_recent, |menu| menu.separator())
let context_picker = context_picker.clone(); .extend(modes.into_iter().map(|mode| {
let context_picker = context_picker.clone();
ContextMenuEntry::new(mode.label()) ContextMenuEntry::new(mode.label())
.icon(mode.icon()) .icon(mode.icon())
.icon_size(IconSize::XSmall) .icon_size(IconSize::XSmall)
.icon_color(Color::Muted) .icon_color(Color::Muted)
.handler(move |window, cx| { .handler(move |window, cx| {
context_picker.update(cx, |this, cx| this.select_mode(mode, window, cx)) context_picker.update(cx, |this, cx| this.select_mode(mode, window, cx))
}) })
})); }))
.keep_open_on_confirm()
match self.confirm_behavior {
ConfirmBehavior::KeepOpen => menu.keep_open_on_confirm(),
ConfirmBehavior::Close => menu,
}
}); });
cx.subscribe(&menu, move |_, _, _: &DismissEvent, cx| { cx.subscribe(&menu, move |_, _, _: &DismissEvent, cx| {
@ -227,7 +213,6 @@ impl ContextPicker {
context_picker.clone(), context_picker.clone(),
self.workspace.clone(), self.workspace.clone(),
self.context_store.clone(), self.context_store.clone(),
self.confirm_behavior,
window, window,
cx, cx,
) )
@ -239,7 +224,6 @@ impl ContextPicker {
context_picker.clone(), context_picker.clone(),
self.workspace.clone(), self.workspace.clone(),
self.context_store.clone(), self.context_store.clone(),
self.confirm_behavior,
window, window,
cx, cx,
) )
@ -251,7 +235,6 @@ impl ContextPicker {
context_picker.clone(), context_picker.clone(),
self.workspace.clone(), self.workspace.clone(),
self.context_store.clone(), self.context_store.clone(),
self.confirm_behavior,
window, window,
cx, cx,
) )
@ -264,7 +247,6 @@ impl ContextPicker {
thread_store.clone(), thread_store.clone(),
context_picker.clone(), context_picker.clone(),
self.context_store.clone(), self.context_store.clone(),
self.confirm_behavior,
window, window,
cx, cx,
) )

View file

@ -11,7 +11,7 @@ use picker::{Picker, PickerDelegate};
use ui::{Context, ListItem, Window, prelude::*}; use ui::{Context, ListItem, Window, prelude::*};
use workspace::Workspace; use workspace::Workspace;
use crate::context_picker::{ConfirmBehavior, ContextPicker}; use crate::context_picker::ContextPicker;
use crate::context_store::ContextStore; use crate::context_store::ContextStore;
pub struct FetchContextPicker { pub struct FetchContextPicker {
@ -23,16 +23,10 @@ impl FetchContextPicker {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let delegate = FetchContextPickerDelegate::new( let delegate = FetchContextPickerDelegate::new(context_picker, workspace, context_store);
context_picker,
workspace,
context_store,
confirm_behavior,
);
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));
Self { picker } Self { picker }
@ -62,7 +56,6 @@ pub struct FetchContextPickerDelegate {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
url: String, url: String,
} }
@ -71,13 +64,11 @@ impl FetchContextPickerDelegate {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
) -> Self { ) -> Self {
FetchContextPickerDelegate { FetchContextPickerDelegate {
context_picker, context_picker,
workspace, workspace,
context_store, context_store,
confirm_behavior,
url: String::new(), url: String::new(),
} }
} }
@ -204,25 +195,15 @@ impl PickerDelegate for FetchContextPickerDelegate {
let http_client = workspace.read(cx).client().http_client().clone(); let http_client = workspace.read(cx).client().http_client().clone();
let url = self.url.clone(); let url = self.url.clone();
let confirm_behavior = self.confirm_behavior;
cx.spawn_in(window, async move |this, cx| { cx.spawn_in(window, async move |this, cx| {
let text = cx let text = cx
.background_spawn(fetch_url_content(http_client, url.clone())) .background_spawn(fetch_url_content(http_client, url.clone()))
.await?; .await?;
this.update_in(cx, |this, window, cx| { this.update(cx, |this, cx| {
this.delegate this.delegate.context_store.update(cx, |context_store, cx| {
.context_store context_store.add_fetched_url(url, text, cx)
.update(cx, |context_store, cx| { })
context_store.add_fetched_url(url, text, cx)
})?;
match confirm_behavior {
ConfirmBehavior::KeepOpen => {}
ConfirmBehavior::Close => this.delegate.dismissed(window, cx),
}
anyhow::Ok(())
})??; })??;
anyhow::Ok(()) anyhow::Ok(())

View file

@ -11,9 +11,9 @@ use picker::{Picker, PickerDelegate};
use project::{PathMatchCandidateSet, ProjectPath, WorktreeId}; use project::{PathMatchCandidateSet, ProjectPath, WorktreeId};
use ui::{ListItem, Tooltip, prelude::*}; use ui::{ListItem, Tooltip, prelude::*};
use util::ResultExt as _; use util::ResultExt as _;
use workspace::{Workspace, notifications::NotifyResultExt}; use workspace::Workspace;
use crate::context_picker::{ConfirmBehavior, ContextPicker}; use crate::context_picker::ContextPicker;
use crate::context_store::{ContextStore, FileInclusion}; use crate::context_store::{ContextStore, FileInclusion};
pub struct FileContextPicker { pub struct FileContextPicker {
@ -25,16 +25,10 @@ impl FileContextPicker {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let delegate = FileContextPickerDelegate::new( let delegate = FileContextPickerDelegate::new(context_picker, workspace, context_store);
context_picker,
workspace,
context_store,
confirm_behavior,
);
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));
Self { picker } Self { picker }
@ -57,7 +51,6 @@ pub struct FileContextPickerDelegate {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
matches: Vec<FileMatch>, matches: Vec<FileMatch>,
selected_index: usize, selected_index: usize,
} }
@ -67,13 +60,11 @@ impl FileContextPickerDelegate {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
) -> Self { ) -> Self {
Self { Self {
context_picker, context_picker,
workspace, workspace,
context_store, context_store,
confirm_behavior,
matches: Vec::new(), matches: Vec::new(),
selected_index: 0, selected_index: 0,
} }
@ -127,7 +118,7 @@ impl PickerDelegate for FileContextPickerDelegate {
}) })
} }
fn confirm(&mut self, _secondary: bool, window: &mut Window, cx: &mut Context<Picker<Self>>) { fn confirm(&mut self, _secondary: bool, _window: &mut Window, cx: &mut Context<Picker<Self>>) {
let Some(FileMatch { mat, .. }) = self.matches.get(self.selected_index) else { let Some(FileMatch { mat, .. }) = self.matches.get(self.selected_index) else {
return; return;
}; };
@ -153,17 +144,7 @@ impl PickerDelegate for FileContextPickerDelegate {
return; return;
}; };
let confirm_behavior = self.confirm_behavior; task.detach_and_log_err(cx);
cx.spawn_in(window, async move |this, cx| {
match task.await.notify_async_err(cx) {
None => anyhow::Ok(()),
Some(()) => this.update_in(cx, |this, window, cx| match confirm_behavior {
ConfirmBehavior::KeepOpen => {}
ConfirmBehavior::Close => this.delegate.dismissed(window, cx),
}),
}
})
.detach_and_log_err(cx);
} }
fn dismissed(&mut self, _: &mut Window, cx: &mut Context<Picker<Self>>) { fn dismissed(&mut self, _: &mut Window, cx: &mut Context<Picker<Self>>) {

View file

@ -15,7 +15,7 @@ use ui::{ListItem, prelude::*};
use util::ResultExt as _; use util::ResultExt as _;
use workspace::Workspace; use workspace::Workspace;
use crate::context_picker::{ConfirmBehavior, ContextPicker}; use crate::context_picker::ContextPicker;
use crate::context_store::ContextStore; use crate::context_store::ContextStore;
pub struct SymbolContextPicker { pub struct SymbolContextPicker {
@ -27,16 +27,10 @@ impl SymbolContextPicker {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let delegate = SymbolContextPickerDelegate::new( let delegate = SymbolContextPickerDelegate::new(context_picker, workspace, context_store);
context_picker,
workspace,
context_store,
confirm_behavior,
);
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));
Self { picker } Self { picker }
@ -59,7 +53,6 @@ pub struct SymbolContextPickerDelegate {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
matches: Vec<SymbolEntry>, matches: Vec<SymbolEntry>,
selected_index: usize, selected_index: usize,
} }
@ -69,13 +62,11 @@ impl SymbolContextPickerDelegate {
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
workspace: WeakEntity<Workspace>, workspace: WeakEntity<Workspace>,
context_store: WeakEntity<ContextStore>, context_store: WeakEntity<ContextStore>,
confirm_behavior: ConfirmBehavior,
) -> Self { ) -> Self {
Self { Self {
context_picker, context_picker,
workspace, workspace,
context_store, context_store,
confirm_behavior,
matches: Vec::new(), matches: Vec::new(),
selected_index: 0, selected_index: 0,
} }
@ -135,7 +126,7 @@ impl PickerDelegate for SymbolContextPickerDelegate {
}) })
} }
fn confirm(&mut self, _secondary: bool, window: &mut Window, cx: &mut Context<Picker<Self>>) { fn confirm(&mut self, _secondary: bool, _window: &mut Window, cx: &mut Context<Picker<Self>>) {
let Some(mat) = self.matches.get(self.selected_index) else { let Some(mat) = self.matches.get(self.selected_index) else {
return; return;
}; };
@ -143,7 +134,6 @@ impl PickerDelegate for SymbolContextPickerDelegate {
return; return;
}; };
let confirm_behavior = self.confirm_behavior;
let add_symbol_task = add_symbol( let add_symbol_task = add_symbol(
mat.symbol.clone(), mat.symbol.clone(),
true, true,
@ -153,16 +143,12 @@ impl PickerDelegate for SymbolContextPickerDelegate {
); );
let selected_index = self.selected_index; let selected_index = self.selected_index;
cx.spawn_in(window, async move |this, cx| { cx.spawn(async move |this, cx| {
let included = add_symbol_task.await?; let included = add_symbol_task.await?;
this.update_in(cx, |this, window, cx| { this.update(cx, |this, _| {
if let Some(mat) = this.delegate.matches.get_mut(selected_index) { if let Some(mat) = this.delegate.matches.get_mut(selected_index) {
mat.is_included = included; mat.is_included = included;
} }
match confirm_behavior {
ConfirmBehavior::KeepOpen => {}
ConfirmBehavior::Close => this.delegate.dismissed(window, cx),
}
}) })
}) })
.detach_and_log_err(cx); .detach_and_log_err(cx);

View file

@ -6,7 +6,7 @@ use gpui::{App, DismissEvent, Entity, FocusHandle, Focusable, Task, WeakEntity};
use picker::{Picker, PickerDelegate}; use picker::{Picker, PickerDelegate};
use ui::{ListItem, prelude::*}; use ui::{ListItem, prelude::*};
use crate::context_picker::{ConfirmBehavior, ContextPicker}; use crate::context_picker::ContextPicker;
use crate::context_store::{self, ContextStore}; use crate::context_store::{self, ContextStore};
use crate::thread::ThreadId; use crate::thread::ThreadId;
use crate::thread_store::ThreadStore; use crate::thread_store::ThreadStore;
@ -20,16 +20,11 @@ impl ThreadContextPicker {
thread_store: WeakEntity<ThreadStore>, thread_store: WeakEntity<ThreadStore>,
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
context_store: WeakEntity<context_store::ContextStore>, context_store: WeakEntity<context_store::ContextStore>,
confirm_behavior: ConfirmBehavior,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let delegate = ThreadContextPickerDelegate::new( let delegate =
thread_store, ThreadContextPickerDelegate::new(thread_store, context_picker, context_store);
context_picker,
context_store,
confirm_behavior,
);
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));
ThreadContextPicker { picker } ThreadContextPicker { picker }
@ -58,7 +53,6 @@ pub struct ThreadContextPickerDelegate {
thread_store: WeakEntity<ThreadStore>, thread_store: WeakEntity<ThreadStore>,
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
context_store: WeakEntity<context_store::ContextStore>, context_store: WeakEntity<context_store::ContextStore>,
confirm_behavior: ConfirmBehavior,
matches: Vec<ThreadContextEntry>, matches: Vec<ThreadContextEntry>,
selected_index: usize, selected_index: usize,
} }
@ -68,13 +62,11 @@ impl ThreadContextPickerDelegate {
thread_store: WeakEntity<ThreadStore>, thread_store: WeakEntity<ThreadStore>,
context_picker: WeakEntity<ContextPicker>, context_picker: WeakEntity<ContextPicker>,
context_store: WeakEntity<context_store::ContextStore>, context_store: WeakEntity<context_store::ContextStore>,
confirm_behavior: ConfirmBehavior,
) -> Self { ) -> Self {
ThreadContextPickerDelegate { ThreadContextPickerDelegate {
thread_store, thread_store,
context_picker, context_picker,
context_store, context_store,
confirm_behavior,
matches: Vec::new(), matches: Vec::new(),
selected_index: 0, selected_index: 0,
} }
@ -127,7 +119,7 @@ impl PickerDelegate for ThreadContextPickerDelegate {
}) })
} }
fn confirm(&mut self, _secondary: bool, window: &mut Window, cx: &mut Context<Picker<Self>>) { fn confirm(&mut self, _secondary: bool, _window: &mut Window, cx: &mut Context<Picker<Self>>) {
let Some(entry) = self.matches.get(self.selected_index) else { let Some(entry) = self.matches.get(self.selected_index) else {
return; return;
}; };
@ -138,20 +130,15 @@ impl PickerDelegate for ThreadContextPickerDelegate {
let open_thread_task = thread_store.update(cx, |this, cx| this.open_thread(&entry.id, cx)); let open_thread_task = thread_store.update(cx, |this, cx| this.open_thread(&entry.id, cx));
cx.spawn_in(window, async move |this, cx| { cx.spawn(async move |this, cx| {
let thread = open_thread_task.await?; let thread = open_thread_task.await?;
this.update_in(cx, |this, window, cx| { this.update(cx, |this, cx| {
this.delegate this.delegate
.context_store .context_store
.update(cx, |context_store, cx| { .update(cx, |context_store, cx| {
context_store.add_thread(thread, true, cx) context_store.add_thread(thread, true, cx)
}) })
.ok(); .ok();
match this.delegate.confirm_behavior {
ConfirmBehavior::KeepOpen => {}
ConfirmBehavior::Close => this.delegate.dismissed(window, cx),
}
}) })
}) })
.detach_and_log_err(cx); .detach_and_log_err(cx);

View file

@ -15,7 +15,7 @@ use ui::{KeyBinding, PopoverMenu, PopoverMenuHandle, Tooltip, prelude::*};
use workspace::{Workspace, notifications::NotifyResultExt}; use workspace::{Workspace, notifications::NotifyResultExt};
use crate::context::{ContextId, ContextKind}; use crate::context::{ContextId, ContextKind};
use crate::context_picker::{ConfirmBehavior, ContextPicker}; use crate::context_picker::ContextPicker;
use crate::context_store::ContextStore; use crate::context_store::ContextStore;
use crate::thread::Thread; use crate::thread::Thread;
use crate::thread_store::ThreadStore; use crate::thread_store::ThreadStore;
@ -52,7 +52,6 @@ impl ContextStrip {
workspace.clone(), workspace.clone(),
thread_store.clone(), thread_store.clone(),
context_store.downgrade(), context_store.downgrade(),
ConfirmBehavior::KeepOpen,
window, window,
cx, cx,
) )

View file

@ -10,8 +10,8 @@ use editor::{
use file_icons::FileIcons; use file_icons::FileIcons;
use fs::Fs; use fs::Fs;
use gpui::{ use gpui::{
Animation, AnimationExt, App, DismissEvent, Entity, Focusable, Subscription, TextStyle, Animation, AnimationExt, App, Entity, Focusable, Subscription, TextStyle, WeakEntity,
WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between, linear_color_stop, linear_gradient, point, pulsating_between,
}; };
use language::{Buffer, Language}; use language::{Buffer, Language};
use language_model::{ConfiguredModel, LanguageModelRegistry}; use language_model::{ConfiguredModel, LanguageModelRegistry};
@ -21,12 +21,12 @@ use project::Project;
use settings::Settings; use settings::Settings;
use std::time::Duration; use std::time::Duration;
use theme::ThemeSettings; use theme::ThemeSettings;
use ui::{Disclosure, KeyBinding, PopoverMenu, PopoverMenuHandle, Tooltip, prelude::*}; use ui::{Disclosure, KeyBinding, PopoverMenuHandle, Tooltip, prelude::*};
use util::ResultExt as _; use util::ResultExt as _;
use workspace::Workspace; use workspace::Workspace;
use crate::assistant_model_selector::AssistantModelSelector; use crate::assistant_model_selector::AssistantModelSelector;
use crate::context_picker::{ConfirmBehavior, ContextPicker, ContextPickerCompletionProvider}; use crate::context_picker::{ContextPicker, ContextPickerCompletionProvider};
use crate::context_store::{ContextStore, refresh_context_store_text}; use crate::context_store::{ContextStore, refresh_context_store_text};
use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind}; use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
use crate::profile_selector::ProfileSelector; use crate::profile_selector::ProfileSelector;
@ -46,8 +46,6 @@ pub struct MessageEditor {
context_store: Entity<ContextStore>, context_store: Entity<ContextStore>,
context_strip: Entity<ContextStrip>, context_strip: Entity<ContextStrip>,
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>, context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
inline_context_picker: Entity<ContextPicker>,
inline_context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
model_selector: Entity<AssistantModelSelector>, model_selector: Entity<AssistantModelSelector>,
profile_selector: Entity<ProfileSelector>, profile_selector: Entity<ProfileSelector>,
edits_expanded: bool, edits_expanded: bool,
@ -69,7 +67,6 @@ impl MessageEditor {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let context_picker_menu_handle = PopoverMenuHandle::default(); let context_picker_menu_handle = PopoverMenuHandle::default();
let inline_context_picker_menu_handle = PopoverMenuHandle::default();
let model_selector_menu_handle = PopoverMenuHandle::default(); let model_selector_menu_handle = PopoverMenuHandle::default();
let language = Language::new( let language = Language::new(
@ -112,17 +109,6 @@ impl MessageEditor {
)))); ))));
}); });
let inline_context_picker = cx.new(|cx| {
ContextPicker::new(
workspace.clone(),
Some(thread_store.clone()),
context_store.downgrade(),
ConfirmBehavior::Close,
window,
cx,
)
});
let context_strip = cx.new(|cx| { let context_strip = cx.new(|cx| {
ContextStrip::new( ContextStrip::new(
context_store.clone(), context_store.clone(),
@ -135,14 +121,8 @@ impl MessageEditor {
) )
}); });
let subscriptions = vec![ let subscriptions =
cx.subscribe_in( vec![cx.subscribe_in(&context_strip, window, Self::handle_context_strip_event)];
&inline_context_picker,
window,
Self::handle_inline_context_picker_event,
),
cx.subscribe_in(&context_strip, window, Self::handle_context_strip_event),
];
Self { Self {
editor: editor.clone(), editor: editor.clone(),
@ -152,8 +132,6 @@ impl MessageEditor {
context_store, context_store,
context_strip, context_strip,
context_picker_menu_handle, context_picker_menu_handle,
inline_context_picker,
inline_context_picker_menu_handle,
model_selector: cx.new(|cx| { model_selector: cx.new(|cx| {
AssistantModelSelector::new( AssistantModelSelector::new(
fs.clone(), fs.clone(),
@ -316,17 +294,6 @@ impl MessageEditor {
.detach(); .detach();
} }
fn handle_inline_context_picker_event(
&mut self,
_inline_context_picker: &Entity<ContextPicker>,
_event: &DismissEvent,
window: &mut Window,
cx: &mut Context<Self>,
) {
let editor_focus_handle = self.editor.focus_handle(cx);
window.focus(&editor_focus_handle);
}
fn handle_context_strip_event( fn handle_context_strip_event(
&mut self, &mut self,
_context_strip: &Entity<ContextStrip>, _context_strip: &Entity<ContextStrip>,
@ -346,9 +313,7 @@ impl MessageEditor {
} }
fn move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) { fn move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) {
if self.context_picker_menu_handle.is_deployed() if self.context_picker_menu_handle.is_deployed() {
|| self.inline_context_picker_menu_handle.is_deployed()
{
cx.propagate(); cx.propagate();
} else { } else {
self.context_strip.focus_handle(cx).focus(window); self.context_strip.focus_handle(cx).focus(window);
@ -385,8 +350,6 @@ impl Render for MessageEditor {
let line_height = font_size.to_pixels(window.rem_size()) * 1.5; let line_height = font_size.to_pixels(window.rem_size()) * 1.5;
let focus_handle = self.editor.focus_handle(cx); let focus_handle = self.editor.focus_handle(cx);
let focus_handle_clone = focus_handle.clone();
let inline_context_picker = self.inline_context_picker.clone();
let is_editor_expanded = self.editor_is_expanded; let is_editor_expanded = self.editor_is_expanded;
let expand_icon = if is_editor_expanded { let expand_icon = if is_editor_expanded {
@ -716,8 +679,9 @@ impl Render for MessageEditor {
IconButton::new("toggle-height", expand_icon) IconButton::new("toggle-height", expand_icon)
.icon_size(IconSize::XSmall) .icon_size(IconSize::XSmall)
.icon_color(Color::Muted) .icon_color(Color::Muted)
.tooltip(move |window, cx| { .tooltip({
let focus_handle = focus_handle.clone(); let focus_handle = focus_handle.clone();
move |window, cx| {
let expand_label = if is_editor_expanded { let expand_label = if is_editor_expanded {
"Minimize Message Editor".to_string() "Minimize Message Editor".to_string()
} else { } else {
@ -731,7 +695,7 @@ impl Render for MessageEditor {
window, window,
cx, cx,
) )
}) }})
.on_click(cx.listener(|_, _, window, cx| { .on_click(cx.listener(|_, _, window, cx| {
window.dispatch_action(Box::new(ExpandMessageEditor), cx); window.dispatch_action(Box::new(ExpandMessageEditor), cx);
})) }))
@ -766,23 +730,6 @@ impl Render for MessageEditor {
}, },
).into_any() ).into_any()
})) }))
.child(
PopoverMenu::new("inline-context-picker")
.menu(move |window, cx| {
inline_context_picker.update(cx, |this, cx| {
this.init(window, cx);
});
Some(inline_context_picker.clone())
})
.attach(gpui::Corner::TopLeft)
.anchor(gpui::Corner::BottomLeft)
.offset(gpui::Point {
x: px(0.0),
y: (-ThemeSettings::get_global(cx).ui_font_size(cx) * 2)
- px(4.0),
})
.with_handle(self.inline_context_picker_menu_handle.clone()),
)
.child( .child(
h_flex() h_flex()
.flex_none() .flex_none()
@ -791,7 +738,9 @@ impl Render for MessageEditor {
.child( .child(
h_flex().gap_1() h_flex().gap_1()
.child(self.model_selector.clone()) .child(self.model_selector.clone())
.map(move |parent| { .map({
let focus_handle = focus_handle.clone();
move |parent| {
if is_generating { if is_generating {
parent.child( parent.child(
IconButton::new("stop-generation", IconName::StopFilled) IconButton::new("stop-generation", IconName::StopFilled)
@ -806,7 +755,7 @@ impl Render for MessageEditor {
) )
}) })
.on_click({ .on_click({
let focus_handle = focus_handle_clone.clone(); let focus_handle = focus_handle.clone();
move |_event, window, cx| { move |_event, window, cx| {
focus_handle.dispatch_action( focus_handle.dispatch_action(
&editor::actions::Cancel, &editor::actions::Cancel,
@ -834,7 +783,7 @@ impl Render for MessageEditor {
|| self.waiting_for_summaries_to_send || self.waiting_for_summaries_to_send
) )
.on_click({ .on_click({
let focus_handle = focus_handle_clone.clone(); let focus_handle = focus_handle.clone();
move |_event, window, cx| { move |_event, window, cx| {
focus_handle.dispatch_action(&Chat, window, cx); focus_handle.dispatch_action(&Chat, window, cx);
} }
@ -861,7 +810,9 @@ impl Render for MessageEditor {
}) })
) )
} }
}) }
}
)
), ),
), ),
) )