assistant2: Remove unnecessary Pane
(#21183)
This PR removes an unnecessary `Pane` that was copied over from `assistant::AssistantPanel` to `assistant2::AssistantPanel`. Release Notes: - N/A
This commit is contained in:
parent
9ee1aba80a
commit
e7b0047562
2 changed files with 10 additions and 33 deletions
|
@ -7,7 +7,7 @@ use language_model::LanguageModelRegistry;
|
||||||
use language_model_selector::LanguageModelSelector;
|
use language_model_selector::LanguageModelSelector;
|
||||||
use ui::{prelude::*, ButtonLike, Divider, IconButtonShape, Tab, Tooltip};
|
use ui::{prelude::*, ButtonLike, Divider, IconButtonShape, Tab, Tooltip};
|
||||||
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
||||||
use workspace::{Pane, Workspace};
|
use workspace::Workspace;
|
||||||
|
|
||||||
use crate::message_editor::MessageEditor;
|
use crate::message_editor::MessageEditor;
|
||||||
use crate::thread::Thread;
|
use crate::thread::Thread;
|
||||||
|
@ -25,7 +25,6 @@ pub fn init(cx: &mut AppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AssistantPanel {
|
pub struct AssistantPanel {
|
||||||
pane: View<Pane>,
|
|
||||||
thread: Model<Thread>,
|
thread: Model<Thread>,
|
||||||
message_editor: View<MessageEditor>,
|
message_editor: View<MessageEditor>,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
|
@ -43,27 +42,11 @@ impl AssistantPanel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
|
fn new(_workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
|
||||||
let pane = cx.new_view(|cx| {
|
|
||||||
let mut pane = Pane::new(
|
|
||||||
workspace.weak_handle(),
|
|
||||||
workspace.project().clone(),
|
|
||||||
Default::default(),
|
|
||||||
None,
|
|
||||||
NewThread.boxed_clone(),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
pane.set_can_split(false, cx);
|
|
||||||
pane.set_can_navigate(true, cx);
|
|
||||||
|
|
||||||
pane
|
|
||||||
});
|
|
||||||
|
|
||||||
let thread = cx.new_model(Thread::new);
|
let thread = cx.new_model(Thread::new);
|
||||||
let subscriptions = vec![cx.observe(&thread, |_, _, cx| cx.notify())];
|
let subscriptions = vec![cx.observe(&thread, |_, _, cx| cx.notify())];
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
pane,
|
|
||||||
thread: thread.clone(),
|
thread: thread.clone(),
|
||||||
message_editor: cx.new_view(|cx| MessageEditor::new(thread, cx)),
|
message_editor: cx.new_view(|cx| MessageEditor::new(thread, cx)),
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
|
@ -73,7 +56,7 @@ impl AssistantPanel {
|
||||||
|
|
||||||
impl FocusableView for AssistantPanel {
|
impl FocusableView for AssistantPanel {
|
||||||
fn focus_handle(&self, cx: &AppContext) -> FocusHandle {
|
fn focus_handle(&self, cx: &AppContext) -> FocusHandle {
|
||||||
self.pane.focus_handle(cx)
|
self.message_editor.focus_handle(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,20 +83,8 @@ impl Panel for AssistantPanel {
|
||||||
|
|
||||||
fn set_size(&mut self, _size: Option<Pixels>, _cx: &mut ViewContext<Self>) {}
|
fn set_size(&mut self, _size: Option<Pixels>, _cx: &mut ViewContext<Self>) {}
|
||||||
|
|
||||||
fn is_zoomed(&self, cx: &WindowContext) -> bool {
|
|
||||||
self.pane.read(cx).is_zoomed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
|
|
||||||
self.pane.update(cx, |pane, cx| pane.set_zoomed(zoomed, cx));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
||||||
|
|
||||||
fn pane(&self) -> Option<View<Pane>> {
|
|
||||||
Some(self.pane.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remote_id() -> Option<proto::PanelId> {
|
fn remote_id() -> Option<proto::PanelId> {
|
||||||
Some(proto::PanelId::AssistantPanel)
|
Some(proto::PanelId::AssistantPanel)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use editor::{Editor, EditorElement, EditorStyle};
|
use editor::{Editor, EditorElement, EditorStyle};
|
||||||
use gpui::{AppContext, Model, TextStyle, View};
|
use gpui::{AppContext, FocusableView, Model, TextStyle, View};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, MessageContent, Role,
|
LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, MessageContent, Role,
|
||||||
};
|
};
|
||||||
|
@ -97,6 +97,12 @@ impl MessageEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FocusableView for MessageEditor {
|
||||||
|
fn focus_handle(&self, cx: &AppContext) -> gpui::FocusHandle {
|
||||||
|
self.editor.focus_handle(cx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for MessageEditor {
|
impl Render for MessageEditor {
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
let font_size = TextSize::Default.rems(cx);
|
let font_size = TextSize::Default.rems(cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue