agent: Adjust permission card design (#27911)

<img
src="https://github.com/user-attachments/assets/76ae380c-6d5b-4ed6-9b47-9a4c44b00042"
width="500" />

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-04-02 10:03:43 -03:00 committed by GitHub
parent 2846c55cde
commit ad42a8ad9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1965,49 +1965,79 @@ impl ActiveThread {
) -> impl Iterator<Item = AnyElement> + 'a { ) -> impl Iterator<Item = AnyElement> + 'a {
let thread = self.thread.read(cx); let thread = self.thread.read(cx);
thread thread.tools_needing_confirmation().map(|tool| {
.tools_needing_confirmation() // Note: This element should be removed once a more full-fledged permission UX is implemented.
.map(|tool| { let beta_tag = h_flex()
div() .id("beta-tag")
.m_3() .h(px(18.))
.p_2() .px_1()
.bg(cx.theme().colors().editor_background) .gap_1()
.border_1() .border_1()
.border_color(cx.theme().colors().border) .border_color(cx.theme().colors().text_accent.opacity(0.2))
.border_dashed()
.rounded_sm()
.bg(cx.theme().colors().text_accent.opacity(0.1))
.hover(|style| style.bg(cx.theme().colors().text_accent.opacity(0.2)))
.child(Label::new("Beta").size(LabelSize::XSmall))
.child(Icon::new(IconName::Info).color(Color::Accent).size(IconSize::Indicator))
.tooltip(
Tooltip::text(
"A future release will introduce a way to remember your answers to these. In the meantime, you can avoid these prompts by adding \"assistant\": { \"always_allow_tool_actions\": true } to your settings.json."
)
);
v_flex()
.mt_2()
.mx_4()
.border_1()
.border_color(self.tool_card_border_color(cx))
.rounded_lg() .rounded_lg()
.child( .child(
v_flex() h_flex()
.py_1()
.pl_2()
.pr_1()
.justify_between()
.rounded_t_lg()
.border_b_1()
.border_color(self.tool_card_border_color(cx))
.bg(self.tool_card_header_bg(cx))
.child(
h_flex()
.gap_1() .gap_1()
.child( .child(Label::new("Action Confirmation").size(LabelSize::Small))
v_flex() .child(beta_tag),
.gap_0p5()
.child(
Label::new("The agent wants to run this action:")
.color(Color::Muted),
)
.child(div().p_3().child(Label::new(&tool.ui_text))),
) )
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
.child({ .child({
let tool_id = tool.id.clone(); let tool_id = tool.id.clone();
Button::new("allow-tool-action", "Allow").on_click( Button::new("allow-tool-action", "Allow")
cx.listener(move |this, event, window, cx| { .label_size(LabelSize::Small)
.icon(IconName::Check)
.icon_position(IconPosition::Start)
.icon_size(IconSize::Small)
.icon_color(Color::Success)
.on_click(cx.listener(move |this, event, window, cx| {
this.handle_allow_tool( this.handle_allow_tool(
tool_id.clone(), tool_id.clone(),
event, event,
window, window,
cx, cx,
) )
}), }))
)
}) })
.child({ .child({
let tool_id = tool.id.clone(); let tool_id = tool.id.clone();
let tool_name = tool.name.clone(); let tool_name = tool.name.clone();
Button::new("deny-tool", "Deny").on_click(cx.listener( Button::new("deny-tool", "Deny")
move |this, event, window, cx| { .label_size(LabelSize::Small)
.icon(IconName::Close)
.icon_position(IconPosition::Start)
.icon_size(IconSize::Small)
.icon_color(Color::Error)
.on_click(cx.listener(move |this, event, window, cx| {
this.handle_deny_tool( this.handle_deny_tool(
tool_id.clone(), tool_id.clone(),
tool_name.clone(), tool_name.clone(),
@ -2015,14 +2045,22 @@ impl ActiveThread {
window, window,
cx, cx,
) )
}, }))
))
}), }),
),
) )
.child( .child(
Label::new("Note: A future release will introduce a way to remember your answers to these. In the meantime, you can avoid these prompts by adding \"assistant\": { \"always_allow_tool_actions\": true } to your settings.json.") div()
.color(Color::Muted) .id("action_container")
.size(LabelSize::Small), .rounded_b_lg()
.bg(cx.theme().colors().editor_background)
.overflow_y_scroll()
.max_h_40()
.p_2p5()
.child(
Label::new(&tool.ui_text)
.size(LabelSize::Small)
.buffer_font(cx),
), ),
) )
.into_any() .into_any()