Skip to content

Commit

Permalink
Do not suggest file in inline assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
agu-z committed Dec 31, 2024
1 parent 5b3e3f3 commit 2fb529f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
16 changes: 15 additions & 1 deletion crates/assistant2/src/context_strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ pub struct ContextStrip {
_subscription: Option<Subscription>,
}

pub enum SuggestContextKind {
File,
Thread,
}

#[derive(Clone)]
pub struct SuggestedContext {
entry_id: ProjectEntryId,
Expand All @@ -38,10 +43,19 @@ impl ContextStrip {
thread_store: Option<WeakModel<ThreadStore>>,
focus_handle: FocusHandle,
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
suggest_context_kind: SuggestContextKind,
cx: &mut ViewContext<Self>,
) -> 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
};
Expand Down
4 changes: 3 additions & 1 deletion crates/assistant2/src/inline_prompt_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -793,6 +793,7 @@ impl PromptEditor<BufferCodegen> {
thread_store.clone(),
prompt_editor.focus_handle(cx),
context_picker_menu_handle.clone(),
SuggestContextKind::Thread,
cx,
)
}),
Expand Down Expand Up @@ -932,6 +933,7 @@ impl PromptEditor<TerminalCodegen> {
thread_store.clone(),
prompt_editor.focus_handle(cx),
context_picker_menu_handle.clone(),
SuggestContextKind::Thread,
cx,
)
}),
Expand Down
3 changes: 2 additions & 1 deletion crates/assistant2/src/message_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -87,6 +87,7 @@ impl MessageEditor {
Some(thread_store.clone()),
editor.focus_handle(cx),
context_picker_menu_handle.clone(),
SuggestContextKind::File,
cx,
)
}),
Expand Down

0 comments on commit 2fb529f

Please sign in to comment.