From 2fb529f666ddefe32116976961126c5b31b43c3b Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Tue, 31 Dec 2024 16:39:56 -0300 Subject: [PATCH] Do not suggest file in inline assistant --- crates/assistant2/src/context_strip.rs | 16 +++++++++++++++- crates/assistant2/src/inline_prompt_editor.rs | 4 +++- crates/assistant2/src/message_editor.rs | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/assistant2/src/context_strip.rs b/crates/assistant2/src/context_strip.rs index 40296187045dad..6f2589991fe445 100644 --- a/crates/assistant2/src/context_strip.rs +++ b/crates/assistant2/src/context_strip.rs @@ -24,6 +24,11 @@ pub struct ContextStrip { _subscription: Option, } +pub enum SuggestContextKind { + File, + Thread, +} + #[derive(Clone)] pub struct SuggestedContext { entry_id: ProjectEntryId, @@ -38,10 +43,19 @@ impl ContextStrip { thread_store: Option>, focus_handle: FocusHandle, context_picker_menu_handle: PopoverMenuHandle, + suggest_context_kind: SuggestContextKind, cx: &mut ViewContext, ) -> Self { let subscription = if let Some(workspace) = workspace.upgrade() { - Some(cx.subscribe(&workspace, Self::handle_workspace_event)) + match suggest_context_kind { + SuggestContextKind::File => { + Some(cx.subscribe(&workspace, Self::handle_workspace_event)) + } + SuggestContextKind::Thread => { + // TODO: Suggest current thread + None + } + } } else { None }; diff --git a/crates/assistant2/src/inline_prompt_editor.rs b/crates/assistant2/src/inline_prompt_editor.rs index 4df5fe33b55bf9..f14ba83c175e34 100644 --- a/crates/assistant2/src/inline_prompt_editor.rs +++ b/crates/assistant2/src/inline_prompt_editor.rs @@ -2,7 +2,7 @@ use crate::assistant_model_selector::AssistantModelSelector; use crate::buffer_codegen::BufferCodegen; use crate::context_picker::ContextPicker; use crate::context_store::ContextStore; -use crate::context_strip::ContextStrip; +use crate::context_strip::{ContextStrip, SuggestContextKind}; use crate::terminal_codegen::TerminalCodegen; use crate::thread_store::ThreadStore; use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist}; @@ -793,6 +793,7 @@ impl PromptEditor { thread_store.clone(), prompt_editor.focus_handle(cx), context_picker_menu_handle.clone(), + SuggestContextKind::Thread, cx, ) }), @@ -932,6 +933,7 @@ impl PromptEditor { thread_store.clone(), prompt_editor.focus_handle(cx), context_picker_menu_handle.clone(), + SuggestContextKind::Thread, cx, ) }), diff --git a/crates/assistant2/src/message_editor.rs b/crates/assistant2/src/message_editor.rs index 3f31552e463130..7b67d93091d51b 100644 --- a/crates/assistant2/src/message_editor.rs +++ b/crates/assistant2/src/message_editor.rs @@ -20,7 +20,7 @@ use workspace::Workspace; use crate::assistant_model_selector::AssistantModelSelector; use crate::context_picker::{ConfirmBehavior, ContextPicker}; use crate::context_store::ContextStore; -use crate::context_strip::ContextStrip; +use crate::context_strip::{ContextStrip, SuggestContextKind}; use crate::thread::{RequestKind, Thread}; use crate::thread_store::ThreadStore; use crate::{Chat, ToggleContextPicker, ToggleModelSelector}; @@ -87,6 +87,7 @@ impl MessageEditor { Some(thread_store.clone()), editor.focus_handle(cx), context_picker_menu_handle.clone(), + SuggestContextKind::File, cx, ) }),