assistant2: Deploy inline assistant in PromptEditor (#25094)
Release Notes: - N/A Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
parent
48f87a8d9a
commit
6885b28c22
2 changed files with 25 additions and 3 deletions
|
@ -478,6 +478,10 @@ impl AssistantPanel {
|
||||||
.update(cx, |this, cx| this.delete_thread(thread_id, cx))
|
.update(cx, |this, cx| this.delete_thread(thread_id, cx))
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn active_context_editor(&self) -> Option<Entity<ContextEditor>> {
|
||||||
|
self.context_editor.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Focusable for AssistantPanel {
|
impl Focusable for AssistantPanel {
|
||||||
|
|
|
@ -228,8 +228,12 @@ impl InlineAssistant {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(inline_assist_target) = Self::resolve_inline_assist_target(workspace, window, cx)
|
let Some(inline_assist_target) = Self::resolve_inline_assist_target(
|
||||||
else {
|
workspace,
|
||||||
|
workspace.panel::<AssistantPanel>(cx),
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1383,6 +1387,7 @@ impl InlineAssistant {
|
||||||
|
|
||||||
fn resolve_inline_assist_target(
|
fn resolve_inline_assist_target(
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
|
assistant_panel: Option<Entity<AssistantPanel>>,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<InlineAssistTarget> {
|
) -> Option<InlineAssistTarget> {
|
||||||
|
@ -1402,7 +1407,20 @@ impl InlineAssistant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(workspace_editor) = workspace
|
let context_editor = assistant_panel
|
||||||
|
.and_then(|panel| panel.read(cx).active_context_editor())
|
||||||
|
.and_then(|editor| {
|
||||||
|
let editor = &editor.read(cx).editor().clone();
|
||||||
|
if editor.read(cx).is_focused(window) {
|
||||||
|
Some(editor.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Some(context_editor) = context_editor {
|
||||||
|
Some(InlineAssistTarget::Editor(context_editor))
|
||||||
|
} else if let Some(workspace_editor) = workspace
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
.and_then(|item| item.act_as::<Editor>(cx))
|
.and_then(|item| item.act_as::<Editor>(cx))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue