agent: Fix message editor's button positions when expanded (#30311)
Fixes an issue introduced by #29959 which caused the message editor to overflow from the agent panel bounds, making the bottom buttons invisible when the editor was expanded (cmd+esc). Fixing this required changing the base structure of the agent panel, but things seem to work as expected: https://github.com/user-attachments/assets/fc4c97fb-f7cb-4f54-a268-c30fbcb1649f Release Notes: - agent: Fix message editor's button positions when expanded
This commit is contained in:
parent
b4fbb9bc08
commit
4b61d4ba6a
1 changed files with 41 additions and 37 deletions
|
@ -2744,42 +2744,16 @@ impl AgentPanel {
|
||||||
|
|
||||||
impl Render for AgentPanel {
|
impl Render for AgentPanel {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let content = match &self.active_view {
|
// WARNING: Changes to this element hierarchy can have
|
||||||
ActiveView::Thread { .. } => v_flex()
|
// non-obvious implications to the layout of children.
|
||||||
.relative()
|
//
|
||||||
.justify_between()
|
// If you need to change it, please confirm:
|
||||||
.size_full()
|
// - The message editor expands (⌘esc) correctly
|
||||||
.child(self.render_active_thread_or_empty_state(window, cx))
|
// - When expanded, the buttons at the bottom of the panel are displayed correctly
|
||||||
.children(self.render_tool_use_limit_reached(cx))
|
// - Font size works as expected and can be changed with ⌘+/⌘-
|
||||||
.child(h_flex().child(self.message_editor.clone()))
|
// - Scrolling in all views works as expected
|
||||||
.children(self.render_last_error(cx))
|
// - Files can be dropped into the panel
|
||||||
.child(self.render_drag_target(cx))
|
let content = v_flex()
|
||||||
.into_any(),
|
|
||||||
ActiveView::History => self.history.clone().into_any_element(),
|
|
||||||
ActiveView::PromptEditor {
|
|
||||||
context_editor,
|
|
||||||
buffer_search_bar,
|
|
||||||
..
|
|
||||||
} => self
|
|
||||||
.render_prompt_editor(context_editor, buffer_search_bar, window, cx)
|
|
||||||
.into_any(),
|
|
||||||
ActiveView::Configuration => v_flex()
|
|
||||||
.size_full()
|
|
||||||
.children(self.configuration.clone())
|
|
||||||
.into_any(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let content = match self.active_view.which_font_size_used() {
|
|
||||||
WhichFontSize::AgentFont => {
|
|
||||||
WithRemSize::new(ThemeSettings::get_global(cx).agent_font_size(cx))
|
|
||||||
.size_full()
|
|
||||||
.child(content)
|
|
||||||
.into_any()
|
|
||||||
}
|
|
||||||
_ => content,
|
|
||||||
};
|
|
||||||
|
|
||||||
v_flex()
|
|
||||||
.key_context(self.key_context())
|
.key_context(self.key_context())
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.size_full()
|
.size_full()
|
||||||
|
@ -2804,7 +2778,37 @@ impl Render for AgentPanel {
|
||||||
.on_action(cx.listener(Self::reset_font_size))
|
.on_action(cx.listener(Self::reset_font_size))
|
||||||
.child(self.render_toolbar(window, cx))
|
.child(self.render_toolbar(window, cx))
|
||||||
.children(self.render_trial_upsell(window, cx))
|
.children(self.render_trial_upsell(window, cx))
|
||||||
.child(content)
|
.map(|parent| match &self.active_view {
|
||||||
|
ActiveView::Thread { .. } => parent
|
||||||
|
.relative()
|
||||||
|
.child(self.render_active_thread_or_empty_state(window, cx))
|
||||||
|
.children(self.render_tool_use_limit_reached(cx))
|
||||||
|
.child(h_flex().child(self.message_editor.clone()))
|
||||||
|
.children(self.render_last_error(cx))
|
||||||
|
.child(self.render_drag_target(cx)),
|
||||||
|
ActiveView::History => parent.child(self.history.clone()),
|
||||||
|
ActiveView::PromptEditor {
|
||||||
|
context_editor,
|
||||||
|
buffer_search_bar,
|
||||||
|
..
|
||||||
|
} => parent.child(self.render_prompt_editor(
|
||||||
|
context_editor,
|
||||||
|
buffer_search_bar,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)),
|
||||||
|
ActiveView::Configuration => parent.children(self.configuration.clone()),
|
||||||
|
});
|
||||||
|
|
||||||
|
match self.active_view.which_font_size_used() {
|
||||||
|
WhichFontSize::AgentFont => {
|
||||||
|
WithRemSize::new(ThemeSettings::get_global(cx).agent_font_size(cx))
|
||||||
|
.size_full()
|
||||||
|
.child(content)
|
||||||
|
.into_any()
|
||||||
|
}
|
||||||
|
_ => content.into_any(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue