diff --git a/src/ui/app.rs b/src/ui/app.rs index bf5c4880..cbc79fac 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -67,7 +67,7 @@ const MAX_CLOSED_TABS: usize = 20; const RESIZE_STEP: f32 = 0.05; -const RECORD_COMMIT_DELAY_MS: u64 = 650; +pub(crate) const RECORD_COMMIT_DELAY_MS: u64 = 650; pub(crate) const TITLE_BAR_HEIGHT: f32 = 40.; @@ -380,7 +380,7 @@ pub struct Tty7App { pub(crate) maximized: Option>, pub(crate) mod_hint_badges: bool, pub(crate) mod_hint_gen: u64, - record_gen: u64, + pub(crate) record_gen: u64, pub(crate) home_focus: gpui::FocusHandle, pub(crate) shells: ShellInventory, pub(crate) shells_host: HostId, diff --git a/src/ui/settings.rs b/src/ui/settings.rs index 3a893306..56393b46 100644 --- a/src/ui/settings.rs +++ b/src/ui/settings.rs @@ -1,7 +1,7 @@ use gpui::{ - AnyElement, App, Context, Div, Entity, FontWeight, Image, ImageFormat, KeyDownEvent, - MouseButton, SharedString, Stateful, Subscription, Window, div, img, prelude::*, px, relative, - rgb, + Animation, AnimationExt as _, AnyElement, App, Context, Div, Entity, FontWeight, Image, + ImageFormat, KeyDownEvent, MouseButton, SharedString, Stateful, Subscription, Window, div, img, + prelude::*, px, relative, rgb, }; use gpui_component::InteractiveElementExt as _; use gpui_component::button::{Button, ButtonVariants as _}; @@ -4454,6 +4454,7 @@ impl Tty7App { .active_settings() .and_then(|s| s.recording.as_ref()) .map(|r| (r.action.clone(), r.chords.clone())); + let record_gen = self.record_gen; let note = self .active_settings() .and_then(|s| s.rebinding_note.clone()); @@ -4558,11 +4559,36 @@ impl Tty7App { .child(t(L10nKey::SettingsPressKeys)), ) } else { + // The binding commits on a pause, and the pause was + // invisible: the hint asked people to time something they + // could not see. The bar runs the same clock the commit + // does, and restarts with every extra chord. row.child(keycaps(&chords.join(" "))).child( - div() - .text_xs() - .text_color(muted) - .child(t(L10nKey::SettingsPauseToSaveEsc)), + v_flex() + .gap(px(3.)) + .child( + div() + .text_xs() + .text_color(muted) + .child(t(L10nKey::SettingsPauseToSaveEsc)), + ) + .child( + div() + .h(px(2.)) + .w_full() + .overflow_hidden() + .rounded_full() + .bg(border) + .child( + div().h_full().rounded_full().bg(accent).with_animation( + ("kb-record-countdown", record_gen as usize), + Animation::new(std::time::Duration::from_millis( + crate::ui::app::RECORD_COMMIT_DELAY_MS, + )), + |bar, delta| bar.w(relative(delta)), + ), + ), + ), ) }; row.into_any_element()