forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'worktree-agent-af28e36e6272e15c7'

Browse files at this commit

a3a997b4babb458744e1da60409041635cd58f9bAhmet Kaan GümüşParent: 0983e9b191bda3
crates/app/src/tests/layout.rsmodified+43 -0
@@ -2967,6 +2967,49 @@ fn a_source_row_shows_its_name_before_anything_else() {
29672967 assert_eq!(crate::LibraryTab::Audio.empty(), "none");
29682968 }
29692969
2970+/// A room key pressed while the ring sits in the dock has to reach the room.
2971+/// Two ways it did not: the dock's own handler could stop a key it does not
2972+/// answer, and the body the dock mounts could leave the focused
2973+/// `FocusHandle` with no element -- gpui dispatches only along the rendered
2974+/// focus node's ancestors (`gpui-0.2.2` `window.rs:3982`, falling back to the
2975+/// *window* root, which is not the room's div), so an orphaned handle kills
2976+/// every key until the next click. Measured 2026-09-09: with KEYS open, a
2977+/// second `?` and `space` reached no listener at all.
2978+#[test]
2979+fn every_dock_body_mounts_the_ring_it_is_standing_in_for() {
2980+ let dock = src_text("ui/dock_stance.rs");
2981+ for (body, id) in [
2982+ ("sources", "\"dock-sources\""),
2983+ ("clip", "\"dock-clip\""),
2984+ ("keys", "\"dock-keys-rows\""),
2985+ ] {
2986+ let after = dock
2987+ .split(id)
2988+ .nth(1)
2989+ .unwrap_or_else(|| panic!("the dock's {body} body is gone"));
2990+ let head: String = after.lines().take(4).collect();
2991+ assert!(
2992+ head.contains(".track_focus(") && head.contains(".on_key_down("),
2993+ "the dock's {body} body mounts no focus handle: a ring left on it dies"
2994+ );
2995+ }
2996+ // ...and the shared handler answers exactly two keys, stopping the stroke
2997+ // only there; anything else bubbles to `ui::stance::render`'s handler.
2998+ let handler = dock
2999+ .split("fn cycle_on_key_down(")
3000+ .nth(1)
3001+ .expect("the dock's shared key handler is gone");
3002+ let body = handler.split("\n}\n").next().unwrap();
3003+ assert_eq!(
3004+ body.matches("cx.stop_propagation()").count(),
3005+ 3,
3006+ "the dock's key handler stops a stroke outside its tab/escape branches"
3007+ );
3008+ for branch in ["is_focus_cycle_key(key)", "is_focus_exit_key(key)"] {
3009+ assert!(body.contains(branch), "{branch} left the dock's key handler");
3010+ }
3011+}
3012+
29703013 /// Focus and selection rings are drawn, never inserted: a `when(focused,
29713014 /// border_1())` puts a pixel of box into the flow and every row in the dock
29723015 /// steps sideways the moment the surface takes focus (hunter: h-clip-tab.png
crates/app/src/ui/dock_stance.rsmodified+40 -5
@@ -195,14 +195,32 @@ fn dock_tab(
195195 .pb(px(6.))
196196 .when(active, |d| d.border_t_1().border_color(rgb(INK1())))
197197 .cursor_pointer()
198- .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
198+ .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
199199 // The keys list is body state, not a tab (user 2026-09-09:
200200 // "remove keys section from here since we also have it next to
201201 // ledger") -- picking either tab is also the way out of it, and
202202 // the pair itself (`dock_src_active`) is what the file keeps.
203203 this.keys_open = false;
204- this.dock_src_active = label_text == "SOURCES";
205- save(this.dock_src_active);
204+ let surface = match label_text == "SOURCES" {
205+ true => Surface::Dock,
206+ false => Surface::Inspector,
207+ };
208+ // Same dead-handle class as `keys_tab`'s: the tab being left
209+ // takes its `FocusHandle`'s element out of the tree with it, so a
210+ // ring that was on that handle has to move with the tab or the
211+ // keyboard goes silent. Only when the ring is actually in the
212+ // dock -- a tab picked while the bench (or nothing) has focus
213+ // does not steal it.
214+ let in_ring = window
215+ .focused(cx)
216+ .is_some_and(|f| f == this.focus_dock || f == this.focus_inspector);
217+ match in_ring {
218+ true => this.focus_surface(surface, window, cx),
219+ false => {
220+ this.dock_src_active = label_text == "SOURCES";
221+ save(this.dock_src_active);
222+ }
223+ }
206224 cx.notify();
207225 }))
208226 .tooltip(crate::ui::widgets::tip_hover(&format!("Show {}", label_text.to_lowercase()), "", None))
@@ -1441,7 +1459,20 @@ fn clip_tab(
14411459 /// An action the room would refuse right now greys to `ink4`, the same ink a
14421460 /// refused verb wears (DESIGN §8) -- never hidden: the list is the full truth
14431461 /// about the keyboard, including the strokes that would answer `No` today.
1444-fn keys_tab(player: &Player) -> impl IntoElement {
1462+fn keys_tab(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
1463+ // The surface this body is standing in for. `keys_tab` replaces whichever
1464+ // tab was mounted, and gpui dispatches a key only along the *rendered*
1465+ // focus node's ancestors: a `FocusHandle` whose element left the tree
1466+ // falls back to the window's own root node, which the room's handler
1467+ // (`ui::stance::render`'s div) is not -- so every key dies until the next
1468+ // click. Mounting the same handle here is what keeps `?` able to close
1469+ // the list it just opened (measured 2026-09-09: second `?` and `space`
1470+ // reached no listener at all).
1471+ let surface = match player.dock_src_active {
1472+ true => Surface::Dock,
1473+ false => Surface::Inspector,
1474+ };
1475+ let focus = player.focus_handle(surface).clone();
14451476 let row_label = label(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
14461477 let row_chord = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM);
14471478 let pair = move |text: String, chord: String, ink: u32| {
@@ -1477,6 +1508,10 @@ fn keys_tab(player: &Player) -> impl IntoElement {
14771508 };
14781509 div()
14791510 .id("dock-keys-rows")
1511+ .track_focus(&focus)
1512+ .on_key_down(cx.listener(move |this, event: &KeyDownEvent, window, cx| {
1513+ cycle_on_key_down(surface)(this, event, window, cx)
1514+ }))
14801515 .flex_1()
14811516 .min_h(px(0.))
14821517 .flex()
@@ -1551,7 +1586,7 @@ pub(crate) fn render(
15511586 .child(dock_tab("dock-tab-clip", "CLIP", !src_active && !keys, cx)),
15521587 )
15531588 .child(match (keys, src_active) {
1554- (true, _) => keys_tab(player).into_any_element(),
1589+ (true, _) => keys_tab(player, cx).into_any_element(),
15551590 (false, true) => sources_tab(player, window, cx).into_any_element(),
15561591 (false, false) => clip_tab(player, width, window_size, window, cx).into_any_element(),
15571592 })
crates/app/src/ui/theme.rsmodified+0 -14
@@ -104,7 +104,6 @@ palette! {
104104 SCRIM: u32,
105105 SCRIM_LIGHT: u32,
106106 STROKE_DIVIDER: u32,
107- STROKE_FOCUS: u32,
108107 STROKE_SELECTED: u32,
109108 FG_PRIMARY: u32,
110109 FG_SECONDARY: u32,
@@ -348,7 +347,6 @@ pub mod cool {
348347
349348 // -- strokes ----------------------------------------------------------------
350349 pub const STROKE_DIVIDER: u32 = 0x2a3442;
351- pub const STROKE_FOCUS: u32 = 0xffd166;
352350 pub const STROKE_SELECTED: u32 = 0x22d3ee;
353351
354352 // -- text -------------------------------------------------------------------
@@ -440,7 +438,6 @@ pub mod warm {
440438
441439 // -- strokes ----------------------------------------------------------------
442440 pub const STROKE_DIVIDER: u32 = 0x3a322e;
443- pub const STROKE_FOCUS: u32 = 0xffc38a;
444441 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
445442
446443 // -- text -------------------------------------------------------------------
@@ -525,7 +522,6 @@ pub mod forest {
525522
526523 // -- strokes ----------------------------------------------------------------
527524 pub const STROKE_DIVIDER: u32 = 0x25362c;
528- pub const STROKE_FOCUS: u32 = 0xffd166;
529525 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
530526
531527 // -- text -------------------------------------------------------------------
@@ -609,7 +605,6 @@ pub mod violet {
609605
610606 // -- strokes ----------------------------------------------------------------
611607 pub const STROKE_DIVIDER: u32 = 0x2e3150;
612- pub const STROKE_FOCUS: u32 = 0xfde68a;
613608 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
614609
615610 // -- text -------------------------------------------------------------------
@@ -688,7 +683,6 @@ pub mod rose {
688683
689684 // -- strokes ----------------------------------------------------------------
690685 pub const STROKE_DIVIDER: u32 = 0x332f33;
691- pub const STROKE_FOCUS: u32 = 0xfcd34d;
692686 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
693687
694688 // -- text -------------------------------------------------------------------
@@ -769,7 +763,6 @@ pub mod amber {
769763
770764 // -- strokes ----------------------------------------------------------------
771765 pub const STROKE_DIVIDER: u32 = 0x35352f;
772- pub const STROKE_FOCUS: u32 = 0x7dd3fc;
773766 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
774767
775768 // -- text -------------------------------------------------------------------
@@ -848,7 +841,6 @@ pub mod ocean {
848841
849842 // -- strokes ----------------------------------------------------------------
850843 pub const STROKE_DIVIDER: u32 = 0x1e2d42;
851- pub const STROKE_FOCUS: u32 = 0xffd166;
852844 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
853845
854846 // -- text -------------------------------------------------------------------
@@ -928,7 +920,6 @@ pub mod ice {
928920
929921 // -- strokes ----------------------------------------------------------------
930922 pub const STROKE_DIVIDER: u32 = 0x223140;
931- pub const STROKE_FOCUS: u32 = 0xfcd34d;
932923 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
933924
934925 // -- text -------------------------------------------------------------------
@@ -1006,7 +997,6 @@ pub mod orchid {
1006997
1007998 // -- strokes ----------------------------------------------------------------
1008999 pub const STROKE_DIVIDER: u32 = 0x33203f;
1009- pub const STROKE_FOCUS: u32 = 0x7dd3fc;
10101000 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
10111001
10121002 // -- text -------------------------------------------------------------------
@@ -1093,7 +1083,6 @@ pub mod nord {
10931083
10941084 // -- strokes ----------------------------------------------------------------
10951085 pub const STROKE_DIVIDER: u32 = 0x434c5e;
1096- pub const STROKE_FOCUS: u32 = 0xd08770;
10971086 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
10981087
10991088 // -- text -------------------------------------------------------------------
@@ -1183,7 +1172,6 @@ pub mod gruvbox {
11831172
11841173 // -- strokes ----------------------------------------------------------------
11851174 pub const STROKE_DIVIDER: u32 = 0x504945;
1186- pub const STROKE_FOCUS: u32 = 0x83a598;
11871175 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
11881176
11891177 // -- text -------------------------------------------------------------------
@@ -1264,7 +1252,6 @@ pub mod dracula {
12641252
12651253 // -- strokes ----------------------------------------------------------------
12661254 pub const STROKE_DIVIDER: u32 = 0x44475a;
1267- pub const STROKE_FOCUS: u32 = 0x8be9fd;
12681255 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
12691256
12701257 // -- text -------------------------------------------------------------------
@@ -1360,7 +1347,6 @@ pub mod darkroom {
13601347
13611348 // -- strokes --------------------------------------------------------------
13621349 pub const STROKE_DIVIDER: u32 = 0x22262b;
1363- pub const STROKE_FOCUS: u32 = INK1;
13641350 /// "Focus/selection ring = 1px ink1 (lamp-adjacent, not coloured)."
13651351 pub const STROKE_SELECTED: u32 = INK1;
13661352