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:
Marshall Bowers 2024-11-25 16:28:38 -05:00 committed by GitHub
parent 9ee1aba80a
commit e7b0047562
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 33 deletions

View file

@ -7,7 +7,7 @@ use language_model::LanguageModelRegistry;
use language_model_selector::LanguageModelSelector;
use ui::{prelude::*, ButtonLike, Divider, IconButtonShape, Tab, Tooltip};
use workspace::dock::{DockPosition, Panel, PanelEvent};
use workspace::{Pane, Workspace};
use workspace::Workspace;
use crate::message_editor::MessageEditor;
use crate::thread::Thread;
@ -25,7 +25,6 @@ pub fn init(cx: &mut AppContext) {
}
pub struct AssistantPanel {
pane: View<Pane>,
thread: Model<Thread>,
message_editor: View<MessageEditor>,
_subscriptions: Vec<Subscription>,
@ -43,27 +42,11 @@ impl AssistantPanel {
})
}
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
});
fn new(_workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
let thread = cx.new_model(Thread::new);
let subscriptions = vec![cx.observe(&thread, |_, _, cx| cx.notify())];
Self {
pane,
thread: thread.clone(),
message_editor: cx.new_view(|cx| MessageEditor::new(thread, cx)),
_subscriptions: subscriptions,
@ -73,7 +56,7 @@ impl AssistantPanel {
impl FocusableView for AssistantPanel {
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 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 pane(&self) -> Option<View<Pane>> {
Some(self.pane.clone())
}
fn remote_id() -> Option<proto::PanelId> {
Some(proto::PanelId::AssistantPanel)
}

View file

@ -1,5 +1,5 @@
use editor::{Editor, EditorElement, EditorStyle};
use gpui::{AppContext, Model, TextStyle, View};
use gpui::{AppContext, FocusableView, Model, TextStyle, View};
use language_model::{
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 {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let font_size = TextSize::Default.rems(cx);