diff --git a/src/client/shell/overlays.rs b/src/client/shell/overlays.rs index 7116713b6..f26cc6e4e 100644 --- a/src/client/shell/overlays.rs +++ b/src/client/shell/overlays.rs @@ -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 { - 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 { + 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 { - let outer = popup(b.area, 64, 16)?; +fn render_onboarding_overlay( + b: &mut Buffer, + k: &LiveKeybindConfig, + p: &Palette, +) -> Option { + 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(); + 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!( diff --git a/src/ui.rs b/src/ui.rs index 141e09d33..8fb7c7d30 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -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; diff --git a/src/ui/onboarding.rs b/src/ui/onboarding.rs index 94c9b2a07..148574d69 100644 --- a/src/ui/onboarding.rs +++ b/src/ui/onboarding.rs @@ -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";