fix(settings): show the pause a keybinding is waiting on

Recording a shortcut commits after a 650ms pause, and the hint asked
people to time something they could not see: "pause to save · Esc", with
no countdown behind it.

A two-pixel bar under the hint now runs the same clock the commit does,
and restarts with every extra chord — so a key sequence reads as one
gesture with a visible deadline instead of a guess.
This commit is contained in:
l0ng-ai
2026-08-08 03:19:57 +08:00
parent 1f91719da9
commit f372971ccc
2 changed files with 35 additions and 9 deletions
+2 -2
View File
@@ -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<Entity<TerminalView>>,
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,
+33 -7
View File
@@ -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()