rules library: Improve empty state & fix quirks on Windows (#41064)

Just got a new Windows machine and realized that the rules library empty
state was completly busted. Ended up also adding some little UI tweaks
to make it better for both Windows and Linux.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-10-23 21:45:48 -03:00 committed by GitHub
parent fe730e9129
commit 5aa82887ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 54 additions and 63 deletions

View file

@ -366,7 +366,7 @@
}
},
{
"context": "PromptLibrary",
"context": "RulesLibrary",
"bindings": {
"new": "rules_library::NewRule",
"ctrl-n": "rules_library::NewRule",

View file

@ -423,7 +423,7 @@
}
},
{
"context": "PromptLibrary",
"context": "RulesLibrary",
"use_key_equivalents": true,
"bindings": {
"cmd-n": "rules_library::NewRule",

View file

@ -375,7 +375,7 @@
}
},
{
"context": "PromptLibrary",
"context": "RulesLibrary",
"use_key_equivalents": true,
"bindings": {
"ctrl-n": "rules_library::NewRule",

View file

@ -1102,7 +1102,9 @@ impl RulesLibrary {
.w_64()
.overflow_x_hidden()
.bg(cx.theme().colors().panel_background)
.child(
.map(|this| {
if cfg!(target_os = "macos") {
this.child(
h_flex()
.p(DynamicSpacing::Base04.rems(cx))
.h_9()
@ -1119,6 +1121,23 @@ impl RulesLibrary {
}),
),
)
} else {
this.child(
h_flex().p_1().w_full().child(
Button::new("new-rule", "New Rule")
.full_width()
.style(ButtonStyle::Outlined)
.icon(IconName::Plus)
.icon_size(IconSize::Small)
.icon_position(IconPosition::Start)
.icon_color(Color::Muted)
.on_click(|_, window, cx| {
window.dispatch_action(Box::new(NewRule), cx);
}),
),
)
}
})
.child(div().flex_grow().child(self.picker.clone()))
}
@ -1348,9 +1367,8 @@ impl Render for RulesLibrary {
client_side_decorations(
v_flex()
.bg(theme.colors().background)
.id("rules-library")
.key_context("PromptLibrary")
.key_context("RulesLibrary")
.on_action(cx.listener(|this, &NewRule, window, cx| this.new_rule(window, cx)))
.on_action(
cx.listener(|this, &DeleteRule, window, cx| {
@ -1368,62 +1386,35 @@ impl Render for RulesLibrary {
.font(ui_font)
.text_color(theme.colors().text)
.children(self.title_bar.clone())
.bg(theme.colors().background)
.child(
h_flex()
.flex_1()
.when(!cfg!(target_os = "macos"), |this| {
this.border_t_1().border_color(cx.theme().colors().border)
})
.child(self.render_rule_list(cx))
.map(|el| {
if self.store.read(cx).prompt_count() == 0 {
el.child(
v_flex()
.w_2_3()
.h_full()
.flex_1()
.items_center()
.justify_center()
.gap_4()
.border_l_1()
.border_color(cx.theme().colors().border)
.bg(cx.theme().colors().editor_background)
.child(
h_flex()
.gap_2()
.child(
Icon::new(IconName::Book)
.size(IconSize::Medium)
.color(Color::Muted),
)
.child(
Label::new("No rules yet")
.size(LabelSize::Large)
.color(Color::Muted),
),
)
.child(
h_flex()
.child(h_flex())
.child(
v_flex()
.gap_1()
.child(Label::new(
"Create your first rule:",
))
.child(
Button::new("create-rule", "New Rule")
.full_width()
.key_binding(
KeyBinding::for_action(
&NewRule, cx,
),
)
.style(ButtonStyle::Outlined)
.key_binding(KeyBinding::for_action(&NewRule, cx))
.on_click(|_, window, cx| {
window.dispatch_action(
NewRule.boxed_clone(),
cx,
)
window
.dispatch_action(NewRule.boxed_clone(), cx)
}),
),
)
.child(h_flex()),
),
)
} else {
el.child(self.render_active_rule(cx))
}