assistant2: Don't suggest thread context for inline assist without a ThreadStore (#23506)
Some checks are pending
CI / Check Postgres and Protobuf migrations, mergability (push) Waiting to run
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Linux x86_x64 release bundle (push) Blocked by required conditions
CI / Linux arm64 release bundle (push) Blocked by required conditions
CI / Auto release preview (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Script / ShellCheck Scripts (push) Waiting to run

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
This commit is contained in:
Marshall Bowers 2025-01-22 18:47:56 -05:00 committed by GitHub
parent ecf70db7f0
commit 82cee9e9a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View file

@ -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 {

View file

@ -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<Self>) {
let context_picker = cx.view().downgrade();

View file

@ -118,6 +118,10 @@ impl ContextStrip {
}
fn suggested_thread(&self, cx: &ViewContext<Self>) -> Option<SuggestedContext> {
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(),

View file

@ -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<SharedString>,
kind: ContextKind,