assistant: Add debug inspector (#16105)

I went with inline approach directly within the panel.
First, enable workflow debugging in the hamburger menu (this works
retroactively as well):


![image](https://github.com/user-attachments/assets/d2ab8edf-bb7b-49a4-8f70-9a6fe94dc7dd)

This enables debug buttons in the header of each step:

![image](https://github.com/user-attachments/assets/3b5d479f-7473-4c41-a2e7-8c10bb71f0ff)
Enabling one pretty-prints the workflow step internals:

![image](https://github.com/user-attachments/assets/e651e826-1270-49ff-8bb6-046c07c006bf)


Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-08-12 17:05:54 +02:00 committed by GitHub
parent b6b081596a
commit 98f314ba21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 354 additions and 19 deletions

View file

@ -16,7 +16,7 @@ enum ContextMenuItem {
Header(SharedString),
Label(SharedString),
Entry {
toggled: Option<bool>,
toggle: Option<(IconPosition, bool)>,
label: SharedString,
icon: Option<IconName>,
handler: Rc<dyn Fn(Option<&FocusHandle>, &mut WindowContext)>,
@ -97,7 +97,7 @@ impl ContextMenu {
handler: impl Fn(&mut WindowContext) + 'static,
) -> Self {
self.items.push(ContextMenuItem::Entry {
toggled: None,
toggle: None,
label: label.into(),
handler: Rc::new(move |_, cx| handler(cx)),
icon: None,
@ -110,11 +110,12 @@ impl ContextMenu {
mut self,
label: impl Into<SharedString>,
toggled: bool,
position: IconPosition,
action: Option<Box<dyn Action>>,
handler: impl Fn(&mut WindowContext) + 'static,
) -> Self {
self.items.push(ContextMenuItem::Entry {
toggled: Some(toggled),
toggle: Some((position, toggled)),
label: label.into(),
handler: Rc::new(move |_, cx| handler(cx)),
icon: None,
@ -155,7 +156,7 @@ impl ContextMenu {
pub fn action(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> Self {
self.items.push(ContextMenuItem::Entry {
toggled: None,
toggle: None,
label: label.into(),
action: Some(action.boxed_clone()),
@ -172,7 +173,7 @@ impl ContextMenu {
pub fn link(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> Self {
self.items.push(ContextMenuItem::Entry {
toggled: None,
toggle: None,
label: label.into(),
action: Some(action.boxed_clone()),
@ -354,7 +355,7 @@ impl Render for ContextMenu {
.child(Label::new(label.clone()))
.into_any_element(),
ContextMenuItem::Entry {
toggled,
toggle,
label,
handler,
icon,
@ -376,8 +377,8 @@ impl Render for ContextMenu {
ListItem::new(ix)
.inset(true)
.selected(Some(ix) == self.selected_index)
.when_some(*toggled, |list_item, toggled| {
list_item.start_slot(if toggled {
.when_some(*toggle, |list_item, (position, toggled)| {
let contents = if toggled {
v_flex().flex_none().child(
Icon::new(IconName::Check).color(Color::Accent),
)
@ -385,7 +386,13 @@ impl Render for ContextMenu {
v_flex()
.flex_none()
.size(IconSize::default().rems())
})
};
match position {
IconPosition::Start => {
list_item.start_slot(contents)
}
IconPosition::End => list_item.end_slot(contents),
}
})
.child(
h_flex()