Honor the prompt field of inline assist action (#29960)

Closes https://github.com/zed-industries/zed/issues/29337

Release Notes:

- Fixed a bug where the `prompt` field was ignored on custom key
bindings for `InlineAssist`

Co-authored-by: Michael Sloan <mgsloan@gmail.com>
This commit is contained in:
Max Brunsfeld 2025-05-05 17:24:31 -07:00 committed by GitHub
parent 275c808b03
commit 34e10e4e56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 6 deletions

View file

@ -2789,7 +2789,7 @@ impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist {
fn assist( fn assist(
&self, &self,
prompt_editor: &Entity<Editor>, prompt_editor: &Entity<Editor>,
_initial_prompt: Option<String>, initial_prompt: Option<String>,
window: &mut Window, window: &mut Window,
cx: &mut Context<RulesLibrary>, cx: &mut Context<RulesLibrary>,
) { ) {
@ -2813,6 +2813,7 @@ impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist {
prompt_store, prompt_store,
thread_store, thread_store,
text_thread_store, text_thread_store,
initial_prompt,
window, window,
cx, cx,
) )

View file

@ -227,7 +227,7 @@ impl InlineAssistant {
pub fn inline_assist( pub fn inline_assist(
workspace: &mut Workspace, workspace: &mut Workspace,
_action: &zed_actions::assistant::InlineAssist, action: &zed_actions::assistant::InlineAssist,
window: &mut Window, window: &mut Window,
cx: &mut Context<Workspace>, cx: &mut Context<Workspace>,
) { ) {
@ -273,6 +273,7 @@ impl InlineAssistant {
prompt_store, prompt_store,
thread_store, thread_store,
text_thread_store, text_thread_store,
action.prompt.clone(),
window, window,
cx, cx,
) )
@ -287,6 +288,7 @@ impl InlineAssistant {
prompt_store, prompt_store,
thread_store, thread_store,
text_thread_store, text_thread_store,
action.prompt.clone(),
window, window,
cx, cx,
) )
@ -344,6 +346,7 @@ impl InlineAssistant {
prompt_store: Option<Entity<PromptStore>>, prompt_store: Option<Entity<PromptStore>>,
thread_store: Option<WeakEntity<ThreadStore>>, thread_store: Option<WeakEntity<ThreadStore>>,
text_thread_store: Option<WeakEntity<TextThreadStore>>, text_thread_store: Option<WeakEntity<TextThreadStore>>,
initial_prompt: Option<String>,
window: &mut Window, window: &mut Window,
cx: &mut App, cx: &mut App,
) { ) {
@ -442,8 +445,12 @@ impl InlineAssistant {
} }
let assist_group_id = self.next_assist_group_id.post_inc(); let assist_group_id = self.next_assist_group_id.post_inc();
let prompt_buffer = let prompt_buffer = cx.new(|cx| {
cx.new(|cx| MultiBuffer::singleton(cx.new(|cx| Buffer::local(String::new(), cx)), cx)); MultiBuffer::singleton(
cx.new(|cx| Buffer::local(initial_prompt.unwrap_or_default(), cx)),
cx,
)
});
let mut assists = Vec::new(); let mut assists = Vec::new();
let mut assist_to_focus = None; let mut assist_to_focus = None;

View file

@ -72,13 +72,18 @@ impl TerminalInlineAssistant {
prompt_store: Option<Entity<PromptStore>>, prompt_store: Option<Entity<PromptStore>>,
thread_store: Option<WeakEntity<ThreadStore>>, thread_store: Option<WeakEntity<ThreadStore>>,
text_thread_store: Option<WeakEntity<TextThreadStore>>, text_thread_store: Option<WeakEntity<TextThreadStore>>,
initial_prompt: Option<String>,
window: &mut Window, window: &mut Window,
cx: &mut App, cx: &mut App,
) { ) {
let terminal = terminal_view.read(cx).terminal().clone(); let terminal = terminal_view.read(cx).terminal().clone();
let assist_id = self.next_assist_id.post_inc(); let assist_id = self.next_assist_id.post_inc();
let prompt_buffer = let prompt_buffer = cx.new(|cx| {
cx.new(|cx| MultiBuffer::singleton(cx.new(|cx| Buffer::local(String::new(), cx)), cx)); MultiBuffer::singleton(
cx.new(|cx| Buffer::local(initial_prompt.unwrap_or_default(), cx)),
cx,
)
});
let context_store = cx.new(|_cx| ContextStore::new(project, thread_store.clone())); let context_store = cx.new(|_cx| ContextStore::new(project, thread_store.clone()));
let codegen = cx.new(|_| TerminalCodegen::new(terminal, self.telemetry.clone())); let codegen = cx.new(|_| TerminalCodegen::new(terminal, self.telemetry.clone()));