agent: Fix layout shift due to the "Generating" label (#30422)
Closes https://github.com/zed-industries/zed/issues/30238 Release Notes: - agent: Fixed layout shift happening in the toolbar (both in the singleton and multibuffers) due to the "Generating" label that appeared while the agent is still generating a response.
This commit is contained in:
parent
82d271cb5b
commit
9afc6f6f5c
3 changed files with 23 additions and 10 deletions
1
assets/icons/load_circle.svg
Normal file
1
assets/icons/load_circle.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-circle-icon lucide-loader-circle"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
|
After Width: | Height: | Size: 289 B |
|
@ -1,6 +1,4 @@
|
||||||
use crate::{
|
use crate::{Keep, KeepAll, OpenAgentDiff, Reject, RejectAll, Thread, ThreadEvent};
|
||||||
Keep, KeepAll, OpenAgentDiff, Reject, RejectAll, Thread, ThreadEvent, ui::AnimatedLabel,
|
|
||||||
};
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use assistant_settings::AssistantSettings;
|
use assistant_settings::AssistantSettings;
|
||||||
use buffer_diff::DiffHunkStatus;
|
use buffer_diff::DiffHunkStatus;
|
||||||
|
@ -11,8 +9,9 @@ use editor::{
|
||||||
scroll::Autoscroll,
|
scroll::Autoscroll,
|
||||||
};
|
};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
Action, AnyElement, AnyView, App, AppContext, Empty, Entity, EventEmitter, FocusHandle,
|
Action, Animation, AnimationExt, AnyElement, AnyView, App, AppContext, Empty, Entity,
|
||||||
Focusable, Global, SharedString, Subscription, Task, WeakEntity, Window, prelude::*,
|
EventEmitter, FocusHandle, Focusable, Global, SharedString, Subscription, Task, Transformation,
|
||||||
|
WeakEntity, Window, percentage, prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use language::{Buffer, Capability, DiskState, OffsetRangeExt, Point};
|
use language::{Buffer, Capability, DiskState, OffsetRangeExt, Point};
|
||||||
|
@ -25,6 +24,7 @@ use std::{
|
||||||
collections::hash_map::Entry,
|
collections::hash_map::Entry,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
use ui::{IconButtonShape, KeyBinding, Tooltip, prelude::*, vertical_divider};
|
use ui::{IconButtonShape, KeyBinding, Tooltip, prelude::*, vertical_divider};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
@ -978,9 +978,20 @@ impl ToolbarItemView for AgentDiffToolbar {
|
||||||
|
|
||||||
impl Render for AgentDiffToolbar {
|
impl Render for AgentDiffToolbar {
|
||||||
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 generating_label = div()
|
let spinner_icon = div()
|
||||||
.w(rems_from_px(110.)) // Arbitrary size so the label doesn't dance around
|
.px_0p5()
|
||||||
.child(AnimatedLabel::new("Generating"))
|
.id("generating")
|
||||||
|
.tooltip(Tooltip::text("Generating Changes…"))
|
||||||
|
.child(
|
||||||
|
Icon::new(IconName::LoadCircle)
|
||||||
|
.size(IconSize::Small)
|
||||||
|
.color(Color::Accent)
|
||||||
|
.with_animation(
|
||||||
|
"load_circle",
|
||||||
|
Animation::new(Duration::from_secs(3)).repeat(),
|
||||||
|
|icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
|
||||||
|
),
|
||||||
|
)
|
||||||
.into_any();
|
.into_any();
|
||||||
|
|
||||||
let Some(active_item) = self.active_item.as_ref() else {
|
let Some(active_item) = self.active_item.as_ref() else {
|
||||||
|
@ -997,7 +1008,7 @@ impl Render for AgentDiffToolbar {
|
||||||
|
|
||||||
let content = match state {
|
let content = match state {
|
||||||
EditorState::Idle => return Empty.into_any(),
|
EditorState::Idle => return Empty.into_any(),
|
||||||
EditorState::Generating => vec![generating_label],
|
EditorState::Generating => vec![spinner_icon],
|
||||||
EditorState::Reviewing => vec![
|
EditorState::Reviewing => vec![
|
||||||
h_flex()
|
h_flex()
|
||||||
.child(
|
.child(
|
||||||
|
@ -1115,7 +1126,7 @@ impl Render for AgentDiffToolbar {
|
||||||
|
|
||||||
let is_generating = agent_diff.read(cx).thread.read(cx).is_generating();
|
let is_generating = agent_diff.read(cx).thread.read(cx).is_generating();
|
||||||
if is_generating {
|
if is_generating {
|
||||||
return div().px_2().child(generating_label).into_any();
|
return div().px_2().child(spinner_icon).into_any();
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_empty = agent_diff.read(cx).multibuffer.read(cx).is_empty();
|
let is_empty = agent_diff.read(cx).multibuffer.read(cx).is_empty();
|
||||||
|
|
|
@ -155,6 +155,7 @@ pub enum IconName {
|
||||||
ListCollapse,
|
ListCollapse,
|
||||||
ListTree,
|
ListTree,
|
||||||
ListX,
|
ListX,
|
||||||
|
LoadCircle,
|
||||||
LockOutlined,
|
LockOutlined,
|
||||||
MagnifyingGlass,
|
MagnifyingGlass,
|
||||||
MailOpen,
|
MailOpen,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue