diff --git a/crates/assistant2/src/active_thread.rs b/crates/assistant2/src/active_thread.rs index 1bfd607866dfe8dd0b12b6b199786fb9fbbd07b8..e87bae48cc524eb4d14586d60f914f98224ce458 100644 --- a/crates/assistant2/src/active_thread.rs +++ b/crates/assistant2/src/active_thread.rs @@ -259,7 +259,7 @@ impl ActiveThread { h_flex().flex_wrap().gap_1().px_1p5().pb_1p5().children( context .into_iter() - .map(|context| ContextPill::new_added(context, false, false, None)), + .map(|context| ContextPill::added(context, false, false, None)), ), ) } else { diff --git a/crates/assistant2/src/context_picker.rs b/crates/assistant2/src/context_picker.rs index 01e7e2dd33ee051a1837714aedabedaa40d49d79..dbca3a115ae1eaca212dc6cd2c3dae0420c41800 100644 --- a/crates/assistant2/src/context_picker.rs +++ b/crates/assistant2/src/context_picker.rs @@ -89,7 +89,7 @@ impl ContextPicker { ContextKind::Directory, ContextKind::FetchedUrl, ]; - if self.thread_store.is_some() { + if self.allow_threads() { context_kinds.push(ContextKind::Thread); } @@ -132,6 +132,11 @@ impl ContextPicker { menu } + /// Whether threads are allowed as context. + pub fn allow_threads(&self) -> bool { + self.thread_store.is_some() + } + fn select_kind(&mut self, kind: ContextKind, cx: &mut ViewContext) { let context_picker = cx.view().downgrade(); diff --git a/crates/assistant2/src/context_strip.rs b/crates/assistant2/src/context_strip.rs index 2f4e1c3846764b6fee1cf85f4cb71f433fb04e0a..9e69d1eea91af3033708932279b5edf913eb9eb3 100644 --- a/crates/assistant2/src/context_strip.rs +++ b/crates/assistant2/src/context_strip.rs @@ -118,6 +118,10 @@ impl ContextStrip { } fn suggested_thread(&self, cx: &ViewContext) -> Option { + if !self.context_picker.read(cx).allow_threads() { + return None; + } + let workspace = self.workspace.upgrade()?; let active_thread = workspace .read(cx) @@ -432,7 +436,7 @@ impl Render for ContextStrip { } }) .children(context.iter().enumerate().map(|(i, context)| { - ContextPill::new_added( + ContextPill::added( context.clone(), dupe_names.contains(&context.name), self.focused_index == Some(i), @@ -454,7 +458,7 @@ impl Render for ContextStrip { })) .when_some(suggested_context, |el, suggested| { el.child( - ContextPill::new_suggested( + ContextPill::suggested( suggested.name().clone(), suggested.icon_path(), suggested.kind(), diff --git a/crates/assistant2/src/ui/context_pill.rs b/crates/assistant2/src/ui/context_pill.rs index 7e82ed7b69455b6f73ac3bd076c9b2cb120e3d2c..58ec54a2d41e020630696505f2e470f4eafa25d4 100644 --- a/crates/assistant2/src/ui/context_pill.rs +++ b/crates/assistant2/src/ui/context_pill.rs @@ -24,7 +24,7 @@ pub enum ContextPill { } impl ContextPill { - pub fn new_added( + pub fn added( context: ContextSnapshot, dupe_name: bool, focused: bool, @@ -39,7 +39,7 @@ impl ContextPill { } } - pub fn new_suggested( + pub fn suggested( name: SharedString, icon_path: Option, kind: ContextKind,