fix: show configured prefix on welcome screen (#4747)

refs #4745
This commit is contained in:
JJ Liebig
2026-09-29 15:44:30 +02:00
committed by GitHub
parent 1ab85d31ac
commit dbdb8dc8f5
4 changed files with 41 additions and 8 deletions
+19 -5
View File
@@ -56,7 +56,7 @@ pub(crate) fn render_client_overlay(
}
}
match o {
ClientShellOverlay::Onboarding => render_onboarding_overlay(b, p),
ClientShellOverlay::Onboarding => render_onboarding_overlay(b, k, p),
ClientShellOverlay::ProductAnnouncement(v) => render_product_announcement_overlay(b, v, p),
ClientShellOverlay::ReleaseNotes(v) => {
render_release_notes_overlay(b, v, &s.update_install_command, p)
@@ -262,7 +262,11 @@ fn panel(
Some(Rect::new(a.x + 1, a.y + 1, a.width - 2, a.height - 2))
}
fn popup(a: Rect, w: u16, h: u16) -> Option<Rect> {
let w = w.min(a.width.saturating_sub(4));
popup_with_width_cap(a, w, h, 4)
}
fn popup_with_width_cap(a: Rect, w: u16, h: u16, width_cap: u16) -> Option<Rect> {
let w = w.min(a.width.saturating_sub(width_cap));
let h = h.min(a.height.saturating_sub(2));
if w < 4 || h < 4 {
return None;
@@ -533,8 +537,18 @@ fn render_product_announcement_overlay(
})
}
fn render_onboarding_overlay(b: &mut Buffer, p: &Palette) -> Option<OverlayRender> {
let outer = popup(b.area, 64, 16)?;
fn render_onboarding_overlay(
b: &mut Buffer,
k: &LiveKeybindConfig,
p: &Palette,
) -> Option<OverlayRender> {
let prefix = k.primary_prefix_label();
let hint_width = display_width(" ")
+ display_width(&prefix)
+ display_width(crate::ui::ONBOARDING_PREFIX_SUFFIX)
+ display_width(crate::ui::ONBOARDING_HELP_LABEL)
+ display_width(crate::ui::ONBOARDING_HELP_SUFFIX);
let outer = popup_with_width_cap(b.area, (hint_width + 5).max(64), 16, 3)?;
let inner = panel(b, outer, p.accent, p.panel_bg)?;
if inner.height < 11 {
return Some(OverlayRender {
@@ -584,7 +598,7 @@ fn render_onboarding_overlay(b: &mut Buffer, p: &Palette) -> Option<OverlayRende
let mut key_x = content.x;
for (value, style) in [
(" ", base),
(crate::ui::ONBOARDING_PREFIX_LABEL, accent),
(prefix.as_str(), accent),
(crate::ui::ONBOARDING_PREFIX_SUFFIX, text),
(crate::ui::ONBOARDING_HELP_LABEL, accent),
(crate::ui::ONBOARDING_HELP_SUFFIX, text),
@@ -349,6 +349,26 @@ fn startup_onboarding_is_client_rendered_and_modal() {
assert!(popup_paste.requests.is_empty());
}
#[test]
fn startup_onboarding_shows_configured_prefix() {
let mut config = Config::default();
config.keys.prefix = crate::config::BindingConfig::one("ctrl+shift+b");
let config = ClientShellConfig::from_config(&config).with_startup_onboarding(true);
let mut state = ClientShellState::new(config);
state.set_snapshot(Box::new(snapshot()));
state.set_pane_surface(surface());
let frame = state.compose(70, 20).expect("onboarding frame");
let text = frame
.cells
.iter()
.map(|cell| cell.symbol.as_str())
.collect::<String>();
assert!(text.contains("ctrl+shift+b enters prefix mode"));
assert!(text.contains("shows keybinds and settings"));
assert!(!text.contains("ctrl+b enters prefix mode"));
}
#[test]
fn onboarding_completion_persists_and_opens_endpoint_integrations() {
let path = std::env::temp_dir().join(format!(
+2 -2
View File
@@ -12,8 +12,8 @@ mod widgets;
pub(crate) use self::onboarding::{
onboarding_welcome_continue_rect, ONBOARDING_DESCRIPTION, ONBOARDING_HELP_LABEL,
ONBOARDING_HELP_SUFFIX, ONBOARDING_NEXT, ONBOARDING_PREFIX_LABEL, ONBOARDING_PREFIX_SUFFIX,
ONBOARDING_SUBTITLE, ONBOARDING_TITLE,
ONBOARDING_HELP_SUFFIX, ONBOARDING_NEXT, ONBOARDING_PREFIX_SUFFIX, ONBOARDING_SUBTITLE,
ONBOARDING_TITLE,
};
#[cfg(all(test, unix))]
pub(crate) use self::panes::popup_pane_rects;
-1
View File
@@ -7,7 +7,6 @@ pub(crate) const ONBOARDING_DESCRIPTION: [&str; 3] = [
" click the sidebar to switch workspaces, drag pane",
" borders to resize, right-click for context menus.",
];
pub(crate) const ONBOARDING_PREFIX_LABEL: &str = "ctrl+b";
pub(crate) const ONBOARDING_PREFIX_SUFFIX: &str = " enters prefix mode · ";
pub(crate) const ONBOARDING_HELP_LABEL: &str = "?";
pub(crate) const ONBOARDING_HELP_SUFFIX: &str = " shows keybinds and settings";