Skip to content

Commit 82cee9e

Browse files
authored
assistant2: Don't suggest thread context for inline assist without a ThreadStore (#23506)
This PR makes it so we don't suggest threads as context in the inline assist when we don't have a `ThreadStore` to pull from. Release Notes: - N/A
1 parent ecf70db commit 82cee9e

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

crates/assistant2/src/active_thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl ActiveThread {
259259
h_flex().flex_wrap().gap_1().px_1p5().pb_1p5().children(
260260
context
261261
.into_iter()
262-
.map(|context| ContextPill::new_added(context, false, false, None)),
262+
.map(|context| ContextPill::added(context, false, false, None)),
263263
),
264264
)
265265
} else {

crates/assistant2/src/context_picker.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl ContextPicker {
8989
ContextKind::Directory,
9090
ContextKind::FetchedUrl,
9191
];
92-
if self.thread_store.is_some() {
92+
if self.allow_threads() {
9393
context_kinds.push(ContextKind::Thread);
9494
}
9595

@@ -132,6 +132,11 @@ impl ContextPicker {
132132
menu
133133
}
134134

135+
/// Whether threads are allowed as context.
136+
pub fn allow_threads(&self) -> bool {
137+
self.thread_store.is_some()
138+
}
139+
135140
fn select_kind(&mut self, kind: ContextKind, cx: &mut ViewContext<Self>) {
136141
let context_picker = cx.view().downgrade();
137142

crates/assistant2/src/context_strip.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ impl ContextStrip {
118118
}
119119

120120
fn suggested_thread(&self, cx: &ViewContext<Self>) -> Option<SuggestedContext> {
121+
if !self.context_picker.read(cx).allow_threads() {
122+
return None;
123+
}
124+
121125
let workspace = self.workspace.upgrade()?;
122126
let active_thread = workspace
123127
.read(cx)
@@ -432,7 +436,7 @@ impl Render for ContextStrip {
432436
}
433437
})
434438
.children(context.iter().enumerate().map(|(i, context)| {
435-
ContextPill::new_added(
439+
ContextPill::added(
436440
context.clone(),
437441
dupe_names.contains(&context.name),
438442
self.focused_index == Some(i),
@@ -454,7 +458,7 @@ impl Render for ContextStrip {
454458
}))
455459
.when_some(suggested_context, |el, suggested| {
456460
el.child(
457-
ContextPill::new_suggested(
461+
ContextPill::suggested(
458462
suggested.name().clone(),
459463
suggested.icon_path(),
460464
suggested.kind(),

crates/assistant2/src/ui/context_pill.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum ContextPill {
2424
}
2525

2626
impl ContextPill {
27-
pub fn new_added(
27+
pub fn added(
2828
context: ContextSnapshot,
2929
dupe_name: bool,
3030
focused: bool,
@@ -39,7 +39,7 @@ impl ContextPill {
3939
}
4040
}
4141

42-
pub fn new_suggested(
42+
pub fn suggested(
4343
name: SharedString,
4444
icon_path: Option<SharedString>,
4545
kind: ContextKind,

0 commit comments

Comments
 (0)