forge
Explore
Log in

Don't you dare go Hollow

wip(tooltips): shared tooltip helper + first sites — capped mid-work

Browse files at this commit

d55192d6f1064e2eb334f69baaa3d0e07fe3e08fAhmet Kaan GümüşParent: 388faa6
crates/app/src/tests/layout.rsmodified+113 -0
@@ -3447,3 +3447,116 @@ fn the_only_hue_in_the_export_section_is_the_av1_gpu_notice() {
34473447 );
34483448 }
34493449 }
3450+
3451+/// Every control the hitmap names wears a hover line (the user, 2026-09-09,
3452+/// over a screenshot of the time band: "each and every button needs hover
3453+/// over information ... I don't know some of them"). The hitmap already
3454+/// carries the pair a plate needs -- an id and a label -- so the sweep walks
3455+/// the same emitters: a builder chain that records a control and never calls
3456+/// `.tooltip` is a glyph the user cannot name.
3457+///
3458+/// A scan and not a render: this crate has no gpui window in its tests, so
3459+/// the function body is the finest grain available. One control may emit two
3460+/// hitmap ids (a row and the selection inside it), which is what
3461+/// `DOUBLE_NAMED` allows for, by name and with its reason.
3462+#[test]
3463+fn every_hitmap_control_wears_a_hover_line() {
3464+ // (file, fn, ids beyond the first that name the SAME control)
3465+ const DOUBLE_NAMED: &[(&str, &str, usize)] = &[(
3466+ "dock_stance.rs",
3467+ "subtitle_tab_rows",
3468+ // `subtitle.N.M.row` and `subtitle.N.M.select` are one row: the
3469+ // second id is the harness's aim point for picking it.
3470+ 1,
3471+ )];
3472+ let mut controls = 0;
3473+ let mut naked = Vec::new();
3474+ for path in source_files() {
3475+ let text = std::fs::read_to_string(&path).expect("a source file");
3476+ if !text.contains("hitmap::") {
3477+ continue;
3478+ }
3479+ let file = path
3480+ .file_name()
3481+ .and_then(|n| n.to_str())
3482+ .expect("a file name")
3483+ .to_string();
3484+ let mut at = 0;
3485+ while let Some(found) = text[at..].find("fn ") {
3486+ let start = at + found;
3487+ at = start + 3;
3488+ let name: String = text[at..]
3489+ .chars()
3490+ .take_while(|c| c.is_alphanumeric() || *c == '_')
3491+ .collect();
3492+ if name.is_empty() {
3493+ continue;
3494+ }
3495+ let Some(open) = text[at..].find('{').map(|i| at + i) else {
3496+ continue;
3497+ };
3498+ let mut depth = 0usize;
3499+ let mut end = text.len();
3500+ for (i, c) in text[open..].char_indices() {
3501+ match c {
3502+ '{' => depth += 1,
3503+ '}' => {
3504+ depth -= 1;
3505+ if depth == 0 {
3506+ end = open + i;
3507+ break;
3508+ }
3509+ }
3510+ _ => (),
3511+ }
3512+ }
3513+ let body = &text[start..end];
3514+ let emitters = ["hitmap::control(", "hitmap::dynamic(", "hitmap::action("]
3515+ .iter()
3516+ .map(|needle| body.matches(needle).count())
3517+ .sum::<usize>();
3518+ if emitters == 0 {
3519+ continue;
3520+ }
3521+ controls += emitters;
3522+ let allowed = DOUBLE_NAMED
3523+ .iter()
3524+ .find(|(f, n, _)| *f == file && *n == name)
3525+ .map_or(0, |(_, _, extra)| *extra);
3526+ let tips = body.matches(".tooltip(").count();
3527+ if tips + allowed < emitters {
3528+ naked.push(format!(
3529+ "{file}::{name} -- {emitters} hitmap controls, {tips} tooltips"
3530+ ));
3531+ }
3532+ }
3533+ }
3534+ assert!(
3535+ controls >= 40,
3536+ "the hover sweep found only {controls} controls -- it has gone blind"
3537+ );
3538+ assert!(
3539+ naked.is_empty(),
3540+ "controls with no hover line (attach `widgets::tip_hover`/`action_hover` \
3541+ in the shared constructor): {naked:#?}"
3542+ );
3543+}
3544+
3545+/// The one hover shape for the whole room: `<name> · <chord>`, and a control
3546+/// the state refuses says why instead of naming a stroke that will not fire
3547+/// (DESIGN §4/§8 -- a tooltip is not a sentence).
3548+#[test]
3549+fn a_hover_line_is_a_name_and_a_chord() {
3550+ use crate::ui::widgets::tip_line;
3551+ assert_eq!(
3552+ tip_line("One frame forward", "right", None),
3553+ "One frame forward · right"
3554+ );
3555+ assert_eq!(
3556+ tip_line("Split", "s", Some("nothing selected")),
3557+ "Split · nothing selected"
3558+ );
3559+ // `Keymap::chord`'s unbound badge is not a stroke.
3560+ assert_eq!(tip_line("Add files", "--", None), "Add files");
3561+ assert_eq!(tip_line("Source", "", None), "Source");
3562+}
crates/app/src/ui/bench_stance.rsmodified+16 -0
@@ -337,6 +337,7 @@ fn clip_box(
337337 move |_, _, _, cx| cx.new(|_| Tip(ghost.clone()))
338338 },
339339 )
340+ .tooltip(crate::ui::widgets::tip_hover("Clip", "drag to move", None))
340341 .children(hitmap::dynamic(
341342 move || {
342343 (
@@ -357,6 +358,12 @@ fn clip_box(
357358 .filter(|_| trims(span))
358359 .map(|edge| {
359360 let mut zone = div()
361+ // An id only so the strip can carry a hover plate --
362+ // gpui's `.tooltip` lives on a stateful div.
363+ .id((
364+ "bench-clip-trim",
365+ (lane.ord * 1000 + idx) * 2 + usize::from(edge == Edge::End),
366+ ))
360367 .absolute()
361368 .top_0()
362369 .h_full()
@@ -379,6 +386,7 @@ fn clip_box(
379386 this.open_menu(lane, idx, event.position, cx);
380387 }),
381388 )
389+ .tooltip(crate::ui::widgets::tip_hover("Trim clip edge", "drag", None))
382390 .children(hitmap::dynamic(
383391 move || {
384392 (
@@ -580,6 +588,10 @@ fn clip_box(
580588 d.children([Edge::Start, Edge::End].into_iter().map(|edge| {
581589 let is_in = edge == Edge::Start;
582590 let mut handle = div()
591+ .id((
592+ "bench-clip-fade",
593+ (lane.ord * 1000 + idx) * 2 + usize::from(!is_in),
594+ ))
583595 .absolute()
584596 .top_0()
585597 .w(px(FADE_HANDLE_W))
@@ -593,6 +605,7 @@ fn clip_box(
593605 this.start_fade_drag(lane, idx, is_in, event.position.x, cx);
594606 }),
595607 )
608+ .tooltip(crate::ui::widgets::tip_hover("Fade handle", "drag", None))
596609 .children(hitmap::dynamic(
597610 move || {
598611 (
@@ -713,6 +726,7 @@ fn sub_box(
713726 move |_, _, _, cx| cx.new(|_| Tip(ghost.clone()))
714727 },
715728 )
729+ .tooltip(crate::ui::widgets::tip_hover("Subtitle", "drag to move", None))
716730 .children(hitmap::dynamic(
717731 move || {
718732 (
@@ -893,6 +907,7 @@ fn lane_row(
893907 .on_drag(LaneDrag(lane), move |_, _, _, cx| {
894908 cx.new(|_| Tip(head_ghost.clone()))
895909 })
910+ .tooltip(crate::ui::widgets::tip_hover("Reorder lane", "drag", None))
896911 .children(hitmap::dynamic(
897912 move || {
898913 (
@@ -1189,6 +1204,7 @@ fn lane_row(
11891204 this.preview_ghost_pick(track, lane, event.event.position.x, cx);
11901205 }),
11911206 )
1207+ .tooltip(crate::ui::widgets::tip_hover("Lane bed", "drop media here", None))
11921208 .children(hitmap::dynamic(
11931209 move || {
11941210 (
crates/app/src/ui/cards.rsmodified+7 -0
@@ -121,6 +121,7 @@ fn dark_card_head(
121121 .into()
122122 })
123123 .child(if max { "▣ m" } else { "⤢ m" })
124+ .tooltip(crate::ui::widgets::overlay_tip_hover("Toggle card size", "", None))
124125 .children(hitmap::control("card.maximize", "Toggle card size", true))
125126 }))
126127 .child(
@@ -205,6 +206,11 @@ fn dark_step_glyph(
205206 .cursor_pointer()
206207 .hover(|s| s.bg(rgb(DARK_RAISED())))
207208 .on_click(on_click)
209+ .tooltip(crate::ui::widgets::overlay_tip_hover(
210+ if plus { "Step up" } else { "Step down" },
211+ "",
212+ None,
213+ ))
208214 .children(hitmap.flatten())
209215 .child(dark_row_value(if plus { "+" } else { "−" }))
210216 }
@@ -236,6 +242,7 @@ fn dark_ghost_button(
236242 .cursor_pointer()
237243 .hover(|s| s.bg(rgb(DARK_RAISED())))
238244 .on_click(on_click)
245+ .tooltip(crate::ui::widgets::overlay_tip_hover(&text, chord, None))
239246 .children(hitmap.flatten())
240247 .child(
241248 div()
crates/app/src/ui/dock_stance.rsmodified+13 -17
@@ -118,7 +118,6 @@ fn ghost_verb(
118118 verb_label: &'static str,
119119 action: ActionId,
120120 active: bool,
121- hint: &str,
122121 player: &Player,
123122 on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
124123 ) -> Option<impl IntoElement> {
@@ -127,11 +126,6 @@ fn ghost_verb(
127126 return None;
128127 }
129128 let key = player.keymap.chord(action);
130- let say: SharedString = match enabled.why() {
131- Some(why) => format!("{key} — {why}"),
132- None => format!("{key} — {hint}"),
133- }
134- .into();
135129 let on = enabled.yes();
136130 let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
137131 let chord_style = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
@@ -146,7 +140,10 @@ fn ghost_verb(
146140 .px(px(8.))
147141 .rounded(px(3.))
148142 .when(active, |d| d.bg(rgb(DARK_RAISED())))
149- .tooltip(move |_, cx| cx.new(|_| Tip(say.clone())).into())
143+ // One hover line for the whole room (`widgets::tip_line`): the
144+ // verb and its stroke, not the sentence this row used to carry
145+ // (DESIGN §8 -- a tooltip is not instructional prose).
146+ .tooltip(crate::ui::widgets::action_hover(player, action))
150147 .when(!on, |d| d.opacity(0.4).cursor_not_allowed())
151148 .when(on, |d| {
152149 d.cursor_pointer()
@@ -203,6 +200,7 @@ fn dock_tab(
203200 save(this.dock_src_active);
204201 cx.notify();
205202 }))
203+ .tooltip(crate::ui::widgets::tip_hover(&format!("Show {}", label_text.to_lowercase()), "", None))
206204 .children(hitmap::control(id, label_text, true))
207205 .child(
208206 div()
@@ -408,6 +406,7 @@ fn source_row(
408406 cx.new(|_| Tip(ghost.clone()))
409407 })
410408 })
409+ .tooltip(crate::ui::widgets::tip_hover("Source", "drag to a lane", None))
411410 .children(hitmap::dynamic(
412411 move || (format!("source.{i}.row"), "Source row".into()),
413412 usable,
@@ -734,6 +733,7 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context<Player>) -> (usize, Vec<A
734733 cx.notify();
735734 }))
736735 })
736+ .tooltip(crate::ui::widgets::tip_hover("Subtitle track", "drag to a lane", None))
737737 .children(hitmap::dynamic(
738738 move || {
739739 (
@@ -803,6 +803,7 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context<Player>) -> (usize, Vec<A
803803 cx.stop_propagation();
804804 this.remove_subtitle_track(track, cx);
805805 }))
806+ .tooltip(crate::ui::widgets::tip_hover("Remove subtitle track", "", None))
806807 .children(hitmap::dynamic(
807808 move || {
808809 (
@@ -839,6 +840,7 @@ fn subtitle_tab_rows(player: &Player, cx: &mut Context<Player>) -> (usize, Vec<A
839840 }
840841 cx.notify();
841842 }))
843+ .tooltip(crate::ui::widgets::tip_hover("Fold this source", "click", None))
842844 .children(hitmap::dynamic(
843845 move || {
844846 (
@@ -1022,6 +1024,7 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) -
10221024 this.dock_filter_edit = true;
10231025 cx.notify();
10241026 }))
1027+ .tooltip(crate::ui::widgets::tip_hover("Filter sources", "type to narrow", None))
10251028 .children(hitmap::control("dock.filter", "Filter sources", true))
10261029 .child(match player.dock_filter.is_empty() {
10271030 true => "⌕ filter".to_string(),
@@ -1052,6 +1055,7 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) -
10521055 this.library_tab = tab;
10531056 cx.notify();
10541057 }))
1058+ .tooltip(crate::ui::widgets::tip_hover(&format!("Show {} only", tab.label().to_lowercase()), "", None))
10551059 .children(hitmap::dynamic(
10561060 move || {
10571061 (
@@ -1132,7 +1136,6 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) -
11321136 "Add files",
11331137 ActionId::AddFiles,
11341138 false,
1135- "adds a file to this list — or drop one on the window",
11361139 player,
11371140 cx.listener(|this, _: &ClickEvent, _, cx| this.pick_and_import(cx)),
11381141 ))
@@ -1141,7 +1144,6 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) -
11411144 "Paste path",
11421145 ActionId::PasteFilePath,
11431146 false,
1144- "imports the file named on the clipboard",
11451147 player,
11461148 cx.listener(|this, _: &ClickEvent, _, cx| this.paste_file_path(cx)),
11471149 ))
@@ -1156,7 +1158,6 @@ fn sources_tab(player: &Player, window: &mut Window, cx: &mut Context<Player>) -
11561158 "Import subtitles",
11571159 ActionId::ImportSubtitles,
11581160 false,
1159- "reads an .srt/.ass file onto a subtitle lane",
11601161 player,
11611162 cx.listener(|this, _: &ClickEvent, window, cx| {
11621163 this.act(ActionId::ImportSubtitles, window, cx)
@@ -1217,6 +1218,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
12171218 .bg(rgb(DARK_RAISED()))
12181219 .cursor_pointer()
12191220 .hover(|s| s.text_color(rgb(INK1())))
1221+ .tooltip(crate::ui::widgets::tip_hover(label, "", None))
12201222 .children(hitmap::control(id, label, true))
12211223 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
12221224 this.nudge_transition(lane, idx, by, cx);
@@ -1239,6 +1241,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
12391241 .text_size(label_style.size)
12401242 .text_color(rgb(INK2()))
12411243 .cursor_pointer()
1244+ .tooltip(crate::ui::widgets::tip_hover("Transition duration", "click to type", None))
12421245 .children(hitmap::control(
12431246 "transition-duration-field",
12441247 "Transition duration, type-in",
@@ -1313,7 +1316,6 @@ fn clip_tab(
13131316 "Speed",
13141317 ActionId::Speed,
13151318 player.speed_open.is_some(),
1316- "how fast this clip and its group play",
13171319 player,
13181320 cx.listener(|this, _: &ClickEvent, _, cx| this.open_speed(cx)),
13191321 ))
@@ -1322,7 +1324,6 @@ fn clip_tab(
13221324 "Colour",
13231325 ActionId::Color,
13241326 player.color_open.is_some(),
1325- "exposure, contrast, saturation and temperature",
13261327 player,
13271328 cx.listener(|this, _: &ClickEvent, _, cx| this.open_color(cx)),
13281329 ))
@@ -1331,7 +1332,6 @@ fn clip_tab(
13311332 "Transform",
13321333 ActionId::Transform,
13331334 player.transform_open.is_some(),
1334- "position, scale, rotation and crop for this clip",
13351335 player,
13361336 cx.listener(|this, _: &ClickEvent, _, cx| this.open_transform(cx)),
13371337 ))
@@ -1340,7 +1340,6 @@ fn clip_tab(
13401340 "EQ",
13411341 ActionId::Equalizer,
13421342 player.eq_open.is_some(),
1343- "the bands this clip's sound is filtered through",
13441343 player,
13451344 cx.listener(|this, _: &ClickEvent, _, cx| this.open_eq(cx)),
13461345 ))
@@ -1357,7 +1356,6 @@ fn clip_tab(
13571356 "Silence",
13581357 ActionId::Silence,
13591358 player.silence_open.is_some(),
1360- "scans for quiet stretches to cut or speed up",
13611359 player,
13621360 cx.listener(|this, _: &ClickEvent, _, cx| this.open_silence(cx)),
13631361 ))
@@ -1366,7 +1364,6 @@ fn clip_tab(
13661364 "Mix",
13671365 ActionId::Mix,
13681366 player.mix_open,
1369- "track volumes and the limiter",
13701367 player,
13711368 cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)),
13721369 ))
@@ -1383,7 +1380,6 @@ fn clip_tab(
13831380 "Fit",
13841381 ActionId::Fit,
13851382 false,
1386- "how this picture is placed on the project canvas",
13871383 player,
13881384 cx.listener(|this, _: &ClickEvent, _, cx| this.cycle_fit(cx)),
13891385 )),
crates/app/src/ui/overlays.rsmodified+3 -0
@@ -368,6 +368,7 @@ impl Player {
368368 }
369369 cx.notify();
370370 }))
371+ .tooltip(crate::ui::widgets::tip_hover("Properties", "", None))
371372 .children(hitmap::control("menu.properties", "Properties", true))
372373 .child("Properties")
373374 // No stroke reaches this one, and a blank column would read
@@ -470,6 +471,7 @@ impl Player {
470471 .enumerate()
471472 .map(|(n, (choice, label, detail, picked))| {
472473 let hitmap_label = label.clone();
474+ let row_tip = label.clone();
473475 let hitmap_id = match theme_picker {
474476 true => format!("theme.{n}.row"),
475477 false => format!("picker.choice.{n}"),
@@ -547,6 +549,7 @@ impl Player {
547549 .on_click(
548550 cx.listener(move |this, _: &ClickEvent, _, cx| this.choose(choice, cx)),
549551 )
552+ .tooltip(crate::ui::widgets::overlay_tip_hover(&row_tip, "", None))
550553 .children(hitmap::dynamic(
551554 move || (hitmap_id, hitmap_label.to_string()),
552555 true,
crates/app/src/ui/preview.rsmodified+1 -0
@@ -49,6 +49,7 @@ impl Player {
4949 .cursor_pointer()
5050 .hover(|s| s.bg(rgb(DARK_RAISED())))
5151 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| this.close_preview(cx)))
52+ .tooltip(crate::ui::widgets::tip_hover("Stop preview", "esc", None))
5253 .children(hitmap::control("preview.stop", "Stop preview", true))
5354 .child(div().text_color(rgb(INK2())).child("Stop"))
5455 .child(
crates/app/src/ui/spine_stance.rsmodified+5 -10
@@ -91,11 +91,10 @@ fn glyph_sized(
9191 // action answers to, and the keys overlay ([`crate::ui::stance`]) is
9292 // still where the full truth lives.
9393 let full = player.keymap.display(action);
94- let say: SharedString = match enabled.why() {
95- Some(why) => format!("{full} — {why}"),
96- None => format!("{full} — {}", action.label()),
97- }
98- .into();
94+ // The room's one hover shape (`widgets::tip_line`): the name first, then
95+ // the strokes -- `display`'s every stroke here rather than the compact
96+ // badge, since the spine's glyph is already showing the compact one.
97+ let say = crate::ui::widgets::tip_line(action.label(), &full, enabled.why());
9998 let compact = player.keymap.chord(action);
10099 let on = enabled.yes();
101100 div()
@@ -158,11 +157,7 @@ fn trim_control(active: bool, player: &Player, cx: &mut Context<Player>) -> impl
158157 let half = |id: &'static str, txt: &'static str, action: ActionId, cx: &mut Context<Player>| {
159158 let enabled = player.enable(action, None);
160159 let full = player.keymap.display(action);
161- let say: SharedString = match enabled.why() {
162- Some(why) => format!("{full} — {why}"),
163- None => format!("{full} — {}", action.label()),
164- }
165- .into();
160+ let say = crate::ui::widgets::tip_line(action.label(), &full, enabled.why());
166161 let on = enabled.yes();
167162 div()
168163 .id(id)
crates/app/src/ui/stance.rsmodified+1 -0
@@ -442,6 +442,7 @@ fn ghost(
442442 .rounded(px(3.))
443443 .cursor_pointer()
444444 .hover(|s| s.bg(rgb(DARK_RAISED())).text_color(rgb(INK1())))
445+ .tooltip(crate::ui::widgets::action_hover(player, action))
445446 .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| this.act(action, window, cx)))
446447 .type_style(type_scale::label(
447448 type_scale::LABEL_ROW_PX,
crates/app/src/ui/timeband_stance.rsmodified+7 -0
@@ -165,6 +165,10 @@ fn ghost(
165165 this.act(action, window, cx);
166166 }))
167167 .children(hitmap::action(action, player.enable(action, None).yes()))
168+ // The glyphs nobody could name (`|◂`, `∞`, `‹|`): the hover line is built
169+ // where the ghost is, so a glyph added to this band tomorrow cannot
170+ // ship without one.
171+ .tooltip(crate::ui::widgets::action_hover(player, action))
168172 .font(glyph_style.font)
169173 .text_size(glyph_style.size)
170174 .text_color(rgb(if active { INK1() } else { INK2() }))
@@ -571,6 +575,7 @@ fn grip(id: &'static str, left: bool, top: bool) -> impl IntoElement {
571575 PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
572576 cx.stop_propagation();
573577 })
578+ .tooltip(crate::ui::widgets::tip_hover("Pan the timeline window", "drag", None))
574579 .children(hitmap::control(id, "Timeline viewport grip", true))
575580 }
576581
@@ -610,6 +615,7 @@ fn export_chip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
610615 }
611616 cx.notify();
612617 }))
618+ .tooltip(crate::ui::widgets::action_hover(player, if exporting { ActionId::CancelExport } else { ActionId::Export }))
613619 .children(hitmap::action(
614620 if exporting {
615621 ActionId::CancelExport
@@ -928,6 +934,7 @@ fn save_verb(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
928934 .on_click(cx.listener(|this, _: &ClickEvent, window, cx| {
929935 this.act(ActionId::Save, window, cx);
930936 }))
937+ .tooltip(crate::ui::widgets::action_hover(player, ActionId::Save))
931938 .children(hitmap::action(
932939 ActionId::Save,
933940 player.enable(ActionId::Save, None).yes(),
crates/app/src/ui/widgets.rsmodified+54 -1
@@ -122,6 +122,59 @@ pub(crate) fn dissolve_glyph() -> impl IntoElement {
122122 .size_full()
123123 }
124124
125+/// The hover line every control in the room wears (the user, 2026-09-09:
126+/// "each and every button gets hover over information" -- nobody could name
127+/// the band's own glyphs). One shape, built from the same pair the hitmap
128+/// already names the control by: `<name> · <chord>`, DESIGN §4's "every
129+/// command wears its chord" and §8's no-prose rule -- never a sentence. A
130+/// control the current state refuses says *why* in the chord's place: naming
131+/// a stroke that will not fire is the lie §4 forbids.
132+pub(crate) fn tip_line(name: &str, chord: &str, why: Option<&str>) -> SharedString {
133+ match why {
134+ Some(why) => format!("{name} · {why}"),
135+ // `Keymap::chord`'s own "unbound" badge: a glyph with no stroke says
136+ // its name and stops, rather than wearing `--` as if that were one.
137+ None if chord.is_empty() || chord == "--" => name.to_string(),
138+ None => format!("{name} · {chord}"),
139+ }
140+ .into()
141+}
142+
143+/// [`tip_line`] in the shape gpui's `.tooltip` takes. Every shared control
144+/// constructor attaches this rather than building its own plate, which is
145+/// what keeps the next control from shipping without a hover line.
146+pub(crate) fn tip_hover(
147+ name: &str,
148+ chord: &str,
149+ why: Option<&str>,
150+) -> impl Fn(&mut Window, &mut App) -> gpui::AnyView + use<> {
151+ let say = tip_line(name, chord, why);
152+ move |_, cx| cx.new(|_| Tip(say.clone())).into()
153+}
154+
155+/// [`tip_hover`] for a control drawn *on* a card or a menu, where an
156+/// ordinary [`Tip`] stands aside (`OVERLAID`) and would show nothing.
157+pub(crate) fn overlay_tip_hover(
158+ name: &str,
159+ chord: &str,
160+ why: Option<&str>,
161+) -> impl Fn(&mut Window, &mut App) -> gpui::AnyView + use<> {
162+ let say = tip_line(name, chord, why);
163+ move |_, cx| cx.new(|_| OverlayTip(say.clone())).into()
164+}
165+
166+/// [`tip_hover`] for a control that dispatches an action: the name and the
167+/// stroke are read live off the keymap and the enable state, so a rebind or
168+/// a refusal can never leave a stale plate under the pointer.
169+pub(crate) fn action_hover(
170+ player: &Player,
171+ action: ActionId,
172+) -> impl Fn(&mut Window, &mut App) -> gpui::AnyView + use<> {
173+ let enabled = player.enable(action, None);
174+ let chord = player.keymap.chord(action);
175+ tip_hover(action.label(), &chord, enabled.why())
176+}
177+
125178 /// A toolbar button: its glyph, its name, and its key on hover. `id` only buys
126179 /// `on_click` and the tooltip -- it is still not focusable, so the root's own
127180 /// key listener keeps working after a press, and the click lands on mouse-up
@@ -146,7 +199,7 @@ pub(crate) fn control(
146199 on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
147200 ) -> impl IntoElement {
148201 let label = label.into();
149- let tip: SharedString = format!("{label} — {shortcut}").into();
202+ let tip = tip_line(&label, &shortcut, None);
150203 div()
151204 .id(id)
152205 .flex_none()