assistant2: Use icons for tool call status communication (#26617)
It was hard to catch the running & pending states, though. When running, it will appear as a spinning arrow circle icon. <img src="https://github.com/user-attachments/assets/dbf1bc0a-6fa3-41c6-bcd7-2226e89c87b4" width="500px" /> Release Notes: - N/A
This commit is contained in:
parent
e80df25386
commit
0a0c163692
1 changed files with 38 additions and 17 deletions
|
@ -1,11 +1,13 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use editor::{Editor, MultiBuffer};
|
use editor::{Editor, MultiBuffer};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
list, AbsoluteLength, AnyElement, App, ClickEvent, DefiniteLength, EdgesRefinement, Empty,
|
list, percentage, AbsoluteLength, Animation, AnimationExt, AnyElement, App, ClickEvent,
|
||||||
Entity, Focusable, Length, ListAlignment, ListOffset, ListState, StyleRefinement, Subscription,
|
DefiniteLength, EdgesRefinement, Empty, Entity, Focusable, Length, ListAlignment, ListOffset,
|
||||||
Task, TextStyleRefinement, UnderlineStyle,
|
ListState, StyleRefinement, Subscription, Task, TextStyleRefinement, Transformation,
|
||||||
|
UnderlineStyle,
|
||||||
};
|
};
|
||||||
use language::{Buffer, LanguageRegistry};
|
use language::{Buffer, LanguageRegistry};
|
||||||
use language_model::{LanguageModelRegistry, LanguageModelToolUseId, Role};
|
use language_model::{LanguageModelRegistry, LanguageModelToolUseId, Role};
|
||||||
|
@ -701,13 +703,13 @@ impl ActiveThread {
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.py_0p5()
|
.py_1()
|
||||||
.pl_1()
|
.pl_1()
|
||||||
.pr_2()
|
.pr_2()
|
||||||
.bg(cx.theme().colors().editor_foreground.opacity(0.02))
|
.bg(cx.theme().colors().editor_foreground.opacity(0.025))
|
||||||
.map(|element| {
|
.map(|element| {
|
||||||
if is_open {
|
if is_open {
|
||||||
element.border_b_1().rounded_t(px(6.))
|
element.border_b_1().rounded_t_md()
|
||||||
} else {
|
} else {
|
||||||
element.rounded_md()
|
element.rounded_md()
|
||||||
}
|
}
|
||||||
|
@ -731,16 +733,35 @@ impl ActiveThread {
|
||||||
))
|
))
|
||||||
.child(Label::new(tool_use.name)),
|
.child(Label::new(tool_use.name)),
|
||||||
)
|
)
|
||||||
.child(
|
.child({
|
||||||
Label::new(match tool_use.status {
|
let (icon_name, color, animated) = match &tool_use.status {
|
||||||
ToolUseStatus::Pending => "Pending",
|
ToolUseStatus::Pending => {
|
||||||
ToolUseStatus::Running => "Running",
|
(IconName::Warning, Color::Warning, false)
|
||||||
ToolUseStatus::Finished(_) => "Finished",
|
}
|
||||||
ToolUseStatus::Error(_) => "Error",
|
ToolUseStatus::Running => {
|
||||||
})
|
(IconName::ArrowCircle, Color::Accent, true)
|
||||||
.size(LabelSize::XSmall)
|
}
|
||||||
.buffer_font(cx),
|
ToolUseStatus::Finished(_) => {
|
||||||
),
|
(IconName::Check, Color::Success, false)
|
||||||
|
}
|
||||||
|
ToolUseStatus::Error(_) => (IconName::Close, Color::Error, false),
|
||||||
|
};
|
||||||
|
|
||||||
|
let icon = Icon::new(icon_name).color(color).size(IconSize::Small);
|
||||||
|
|
||||||
|
if animated {
|
||||||
|
icon.with_animation(
|
||||||
|
"arrow-circle",
|
||||||
|
Animation::new(Duration::from_secs(2)).repeat(),
|
||||||
|
|icon, delta| {
|
||||||
|
icon.transform(Transformation::rotate(percentage(delta)))
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.into_any_element()
|
||||||
|
} else {
|
||||||
|
icon.into_any_element()
|
||||||
|
}
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.map(|parent| {
|
.map(|parent| {
|
||||||
if !is_open {
|
if !is_open {
|
||||||
|
@ -812,7 +833,7 @@ impl ActiveThread {
|
||||||
.bg(cx.theme().colors().editor_foreground.opacity(0.02))
|
.bg(cx.theme().colors().editor_foreground.opacity(0.02))
|
||||||
.map(|element| {
|
.map(|element| {
|
||||||
if is_open {
|
if is_open {
|
||||||
element.border_b_1().rounded_t(px(6.))
|
element.border_b_1().rounded_t_md()
|
||||||
} else {
|
} else {
|
||||||
element.rounded_md()
|
element.rounded_md()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue