Always include context when performing inline transformation (#12426)
Release Notes: - Improved clarity for inline transformations by always including the active assistant context.
This commit is contained in:
parent
16745542b5
commit
1db33b5f4e
2 changed files with 3 additions and 45 deletions
|
@ -36,7 +36,6 @@ actions!(
|
||||||
ResetKey,
|
ResetKey,
|
||||||
InlineAssist,
|
InlineAssist,
|
||||||
InsertActivePrompt,
|
InsertActivePrompt,
|
||||||
ToggleIncludeConversation,
|
|
||||||
ToggleHistory,
|
ToggleHistory,
|
||||||
ApplyEdit,
|
ApplyEdit,
|
||||||
ConfirmCommand
|
ConfirmCommand
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::{
|
||||||
ApplyEdit, Assist, CompletionProvider, ConfirmCommand, CycleMessageRole, InlineAssist,
|
ApplyEdit, Assist, CompletionProvider, ConfirmCommand, CycleMessageRole, InlineAssist,
|
||||||
LanguageModel, LanguageModelRequest, LanguageModelRequestMessage, MessageId, MessageMetadata,
|
LanguageModel, LanguageModelRequest, LanguageModelRequestMessage, MessageId, MessageMetadata,
|
||||||
MessageStatus, QuoteSelection, ResetKey, Role, SavedConversation, SavedConversationMetadata,
|
MessageStatus, QuoteSelection, ResetKey, Role, SavedConversation, SavedConversationMetadata,
|
||||||
SavedMessage, Split, ToggleFocus, ToggleHistory, ToggleIncludeConversation,
|
SavedMessage, Split, ToggleFocus, ToggleHistory,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use assistant_slash_command::{SlashCommandOutput, SlashCommandOutputSection};
|
use assistant_slash_command::{SlashCommandOutput, SlashCommandOutputSection};
|
||||||
|
@ -116,7 +116,6 @@ pub struct AssistantPanel {
|
||||||
next_inline_assist_id: usize,
|
next_inline_assist_id: usize,
|
||||||
pending_inline_assists: HashMap<usize, PendingInlineAssist>,
|
pending_inline_assists: HashMap<usize, PendingInlineAssist>,
|
||||||
pending_inline_assist_ids_by_editor: HashMap<WeakView<Editor>, Vec<usize>>,
|
pending_inline_assist_ids_by_editor: HashMap<WeakView<Editor>, Vec<usize>>,
|
||||||
include_conversation_in_next_inline_assist: bool,
|
|
||||||
inline_prompt_history: VecDeque<String>,
|
inline_prompt_history: VecDeque<String>,
|
||||||
_watch_saved_conversations: Task<Result<()>>,
|
_watch_saved_conversations: Task<Result<()>>,
|
||||||
model: LanguageModel,
|
model: LanguageModel,
|
||||||
|
@ -234,7 +233,6 @@ impl AssistantPanel {
|
||||||
next_inline_assist_id: 0,
|
next_inline_assist_id: 0,
|
||||||
pending_inline_assists: Default::default(),
|
pending_inline_assists: Default::default(),
|
||||||
pending_inline_assist_ids_by_editor: Default::default(),
|
pending_inline_assist_ids_by_editor: Default::default(),
|
||||||
include_conversation_in_next_inline_assist: false,
|
|
||||||
inline_prompt_history: Default::default(),
|
inline_prompt_history: Default::default(),
|
||||||
_watch_saved_conversations,
|
_watch_saved_conversations,
|
||||||
model,
|
model,
|
||||||
|
@ -364,7 +362,7 @@ impl AssistantPanel {
|
||||||
&mut self,
|
&mut self,
|
||||||
editor: &View<Editor>,
|
editor: &View<Editor>,
|
||||||
project: &Model<Project>,
|
project: &Model<Project>,
|
||||||
show_include_conversation: bool,
|
include_conversation: bool,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
let selection = editor.read(cx).selections.newest_anchor().clone();
|
let selection = editor.read(cx).selections.newest_anchor().clone();
|
||||||
|
@ -412,8 +410,7 @@ impl AssistantPanel {
|
||||||
InlineAssistant::new(
|
InlineAssistant::new(
|
||||||
inline_assist_id,
|
inline_assist_id,
|
||||||
measurements.clone(),
|
measurements.clone(),
|
||||||
show_include_conversation,
|
include_conversation,
|
||||||
show_include_conversation && self.include_conversation_in_next_inline_assist,
|
|
||||||
self.inline_prompt_history.clone(),
|
self.inline_prompt_history.clone(),
|
||||||
codegen.clone(),
|
codegen.clone(),
|
||||||
cx,
|
cx,
|
||||||
|
@ -549,11 +546,6 @@ impl AssistantPanel {
|
||||||
InlineAssistantEvent::Dismissed => {
|
InlineAssistantEvent::Dismissed => {
|
||||||
self.hide_inline_assist(assist_id, cx);
|
self.hide_inline_assist(assist_id, cx);
|
||||||
}
|
}
|
||||||
InlineAssistantEvent::IncludeConversationToggled {
|
|
||||||
include_conversation,
|
|
||||||
} => {
|
|
||||||
self.include_conversation_in_next_inline_assist = *include_conversation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3481,16 +3473,12 @@ enum InlineAssistantEvent {
|
||||||
},
|
},
|
||||||
Canceled,
|
Canceled,
|
||||||
Dismissed,
|
Dismissed,
|
||||||
IncludeConversationToggled {
|
|
||||||
include_conversation: bool,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InlineAssistant {
|
struct InlineAssistant {
|
||||||
id: usize,
|
id: usize,
|
||||||
prompt_editor: View<Editor>,
|
prompt_editor: View<Editor>,
|
||||||
confirmed: bool,
|
confirmed: bool,
|
||||||
show_include_conversation: bool,
|
|
||||||
include_conversation: bool,
|
include_conversation: bool,
|
||||||
measurements: Arc<Mutex<BlockMeasurements>>,
|
measurements: Arc<Mutex<BlockMeasurements>>,
|
||||||
prompt_history: VecDeque<String>,
|
prompt_history: VecDeque<String>,
|
||||||
|
@ -3513,27 +3501,12 @@ impl Render for InlineAssistant {
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.on_action(cx.listener(Self::confirm))
|
.on_action(cx.listener(Self::confirm))
|
||||||
.on_action(cx.listener(Self::cancel))
|
.on_action(cx.listener(Self::cancel))
|
||||||
.on_action(cx.listener(Self::toggle_include_conversation))
|
|
||||||
.on_action(cx.listener(Self::move_up))
|
.on_action(cx.listener(Self::move_up))
|
||||||
.on_action(cx.listener(Self::move_down))
|
.on_action(cx.listener(Self::move_down))
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
.w(measurements.gutter_width)
|
.w(measurements.gutter_width)
|
||||||
.children(self.show_include_conversation.then(|| {
|
|
||||||
IconButton::new("include_conversation", IconName::Ai)
|
|
||||||
.on_click(cx.listener(|this, _, cx| {
|
|
||||||
this.toggle_include_conversation(&ToggleIncludeConversation, cx)
|
|
||||||
}))
|
|
||||||
.selected(self.include_conversation)
|
|
||||||
.tooltip(|cx| {
|
|
||||||
Tooltip::for_action(
|
|
||||||
"Include Conversation",
|
|
||||||
&ToggleIncludeConversation,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
.children(if let Some(error) = self.codegen.read(cx).error() {
|
.children(if let Some(error) = self.codegen.read(cx).error() {
|
||||||
let error_message = SharedString::from(error.to_string());
|
let error_message = SharedString::from(error.to_string());
|
||||||
Some(
|
Some(
|
||||||
|
@ -3566,7 +3539,6 @@ impl InlineAssistant {
|
||||||
fn new(
|
fn new(
|
||||||
id: usize,
|
id: usize,
|
||||||
measurements: Arc<Mutex<BlockMeasurements>>,
|
measurements: Arc<Mutex<BlockMeasurements>>,
|
||||||
show_include_conversation: bool,
|
|
||||||
include_conversation: bool,
|
include_conversation: bool,
|
||||||
prompt_history: VecDeque<String>,
|
prompt_history: VecDeque<String>,
|
||||||
codegen: Model<Codegen>,
|
codegen: Model<Codegen>,
|
||||||
|
@ -3592,7 +3564,6 @@ impl InlineAssistant {
|
||||||
id,
|
id,
|
||||||
prompt_editor,
|
prompt_editor,
|
||||||
confirmed: false,
|
confirmed: false,
|
||||||
show_include_conversation,
|
|
||||||
include_conversation,
|
include_conversation,
|
||||||
measurements,
|
measurements,
|
||||||
prompt_history,
|
prompt_history,
|
||||||
|
@ -3651,18 +3622,6 @@ impl InlineAssistant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_include_conversation(
|
|
||||||
&mut self,
|
|
||||||
_: &ToggleIncludeConversation,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) {
|
|
||||||
self.include_conversation = !self.include_conversation;
|
|
||||||
cx.emit(InlineAssistantEvent::IncludeConversationToggled {
|
|
||||||
include_conversation: self.include_conversation,
|
|
||||||
});
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn move_up(&mut self, _: &MoveUp, cx: &mut ViewContext<Self>) {
|
fn move_up(&mut self, _: &MoveUp, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(ix) = self.prompt_history_ix {
|
if let Some(ix) = self.prompt_history_ix {
|
||||||
if ix > 0 {
|
if ix > 0 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue