Rename 'chat' to 'thread' in assistant2 (#21141)

Release Notes:

- N/A
This commit is contained in:
Nathan Sobo 2024-11-25 05:27:35 -07:00 committed by GitHub
parent aa58cab766
commit 08b214dfb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 17 deletions

View file

@ -1,5 +1,5 @@
mod assistant_panel; mod assistant_panel;
mod chat_editor; mod message_editor;
use command_palette_hooks::CommandPaletteFilter; use command_palette_hooks::CommandPaletteFilter;
use feature_flags::{Assistant2FeatureFlag, FeatureFlagAppExt}; use feature_flags::{Assistant2FeatureFlag, FeatureFlagAppExt};
@ -7,7 +7,7 @@ use gpui::{actions, AppContext};
pub use crate::assistant_panel::AssistantPanel; pub use crate::assistant_panel::AssistantPanel;
actions!(assistant2, [ToggleFocus, NewChat, ToggleModelSelector]); actions!(assistant2, [ToggleFocus, NewThread, ToggleModelSelector]);
const NAMESPACE: &str = "assistant2"; const NAMESPACE: &str = "assistant2";

View file

@ -9,8 +9,8 @@ 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::{Pane, Workspace};
use crate::chat_editor::ChatEditor; use crate::message_editor::MessageEditor;
use crate::{NewChat, ToggleFocus, ToggleModelSelector}; use crate::{NewThread, ToggleFocus, ToggleModelSelector};
pub fn init(cx: &mut AppContext) { pub fn init(cx: &mut AppContext) {
cx.observe_new_views( cx.observe_new_views(
@ -25,7 +25,7 @@ pub fn init(cx: &mut AppContext) {
pub struct AssistantPanel { pub struct AssistantPanel {
pane: View<Pane>, pane: View<Pane>,
chat_editor: View<ChatEditor>, message_editor: View<MessageEditor>,
} }
impl AssistantPanel { impl AssistantPanel {
@ -47,7 +47,7 @@ impl AssistantPanel {
workspace.project().clone(), workspace.project().clone(),
Default::default(), Default::default(),
None, None,
NewChat.boxed_clone(), NewThread.boxed_clone(),
cx, cx,
); );
pane.set_can_split(false, cx); pane.set_can_split(false, cx);
@ -58,7 +58,7 @@ impl AssistantPanel {
Self { Self {
pane, pane,
chat_editor: cx.new_view(ChatEditor::new), message_editor: cx.new_view(MessageEditor::new),
} }
} }
} }
@ -136,25 +136,30 @@ impl AssistantPanel {
.bg(cx.theme().colors().tab_bar_background) .bg(cx.theme().colors().tab_bar_background)
.border_b_1() .border_b_1()
.border_color(cx.theme().colors().border_variant) .border_color(cx.theme().colors().border_variant)
.child(h_flex().child(Label::new("Chat Title Goes Here"))) .child(h_flex().child(Label::new("Thread Title Goes Here")))
.child( .child(
h_flex() h_flex()
.gap(DynamicSpacing::Base08.rems(cx)) .gap(DynamicSpacing::Base08.rems(cx))
.child(self.render_language_model_selector(cx)) .child(self.render_language_model_selector(cx))
.child(Divider::vertical()) .child(Divider::vertical())
.child( .child(
IconButton::new("new-chat", IconName::Plus) IconButton::new("new-thread", IconName::Plus)
.shape(IconButtonShape::Square) .shape(IconButtonShape::Square)
.icon_size(IconSize::Small) .icon_size(IconSize::Small)
.style(ButtonStyle::Subtle) .style(ButtonStyle::Subtle)
.tooltip({ .tooltip({
let focus_handle = focus_handle.clone(); let focus_handle = focus_handle.clone();
move |cx| { move |cx| {
Tooltip::for_action_in("New Chat", &NewChat, &focus_handle, cx) Tooltip::for_action_in(
"New Thread",
&NewThread,
&focus_handle,
cx,
)
} }
}) })
.on_click(move |_event, _cx| { .on_click(move |_event, _cx| {
println!("New Chat"); println!("New Thread");
}), }),
) )
.child( .child(
@ -238,8 +243,8 @@ impl Render for AssistantPanel {
.key_context("AssistantPanel2") .key_context("AssistantPanel2")
.justify_between() .justify_between()
.size_full() .size_full()
.on_action(cx.listener(|_this, _: &NewChat, _cx| { .on_action(cx.listener(|_this, _: &NewThread, _cx| {
println!("Action: New Chat"); println!("Action: New Thread");
})) }))
.child(self.render_toolbar(cx)) .child(self.render_toolbar(cx))
.child(v_flex().bg(cx.theme().colors().panel_background)) .child(v_flex().bg(cx.theme().colors().panel_background))
@ -247,7 +252,7 @@ impl Render for AssistantPanel {
h_flex() h_flex()
.border_t_1() .border_t_1()
.border_color(cx.theme().colors().border_variant) .border_color(cx.theme().colors().border_variant)
.child(self.chat_editor.clone()), .child(self.message_editor.clone()),
) )
} }
} }

View file

@ -4,11 +4,11 @@ use settings::Settings;
use theme::ThemeSettings; use theme::ThemeSettings;
use ui::prelude::*; use ui::prelude::*;
pub struct ChatEditor { pub struct MessageEditor {
editor: View<Editor>, editor: View<Editor>,
} }
impl ChatEditor { impl MessageEditor {
pub fn new(cx: &mut ViewContext<Self>) -> Self { pub fn new(cx: &mut ViewContext<Self>) -> Self {
Self { Self {
editor: cx.new_view(|cx| { editor: cx.new_view(|cx| {
@ -21,7 +21,7 @@ impl ChatEditor {
} }
} }
impl Render for ChatEditor { 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);
let line_height = font_size.to_pixels(cx.rem_size()) * 1.3; let line_height = font_size.to_pixels(cx.rem_size()) * 1.3;