Merge branch 'worktree-agent-af28e36e6272e15c7'
Browse files at this commit3 changed files +83 -19
- crates/app/src/tests/layout.rs +43 -0
- crates/app/src/ui/dock_stance.rs +40 -5
- crates/app/src/ui/theme.rs +0 -14
crates/app/src/tests/layout.rsmodified+43 -0
| @@ -2967,6 +2967,49 @@ fn a_source_row_shows_its_name_before_anything_else() { | ||
| 2967 | 2967 | assert_eq!(crate::LibraryTab::Audio.empty(), "none"); |
| 2968 | 2968 | } |
| 2969 | 2969 | |
| 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 | + | |
| 2970 | 3013 | /// Focus and selection rings are drawn, never inserted: a `when(focused, |
| 2971 | 3014 | /// border_1())` puts a pixel of box into the flow and every row in the dock |
| 2972 | 3015 | /// 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( | ||
| 195 | 195 | .pb(px(6.)) |
| 196 | 196 | .when(active, |d| d.border_t_1().border_color(rgb(INK1()))) |
| 197 | 197 | .cursor_pointer() |
| 198 | - .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 198 | + .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { | |
| 199 | 199 | // The keys list is body state, not a tab (user 2026-09-09: |
| 200 | 200 | // "remove keys section from here since we also have it next to |
| 201 | 201 | // ledger") -- picking either tab is also the way out of it, and |
| 202 | 202 | // the pair itself (`dock_src_active`) is what the file keeps. |
| 203 | 203 | 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 | + } | |
| 206 | 224 | cx.notify(); |
| 207 | 225 | })) |
| 208 | 226 | .tooltip(crate::ui::widgets::tip_hover(&format!("Show {}", label_text.to_lowercase()), "", None)) |
| @@ -1441,7 +1459,20 @@ fn clip_tab( | ||
| 1441 | 1459 | /// An action the room would refuse right now greys to `ink4`, the same ink a |
| 1442 | 1460 | /// refused verb wears (DESIGN §8) -- never hidden: the list is the full truth |
| 1443 | 1461 | /// 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(); | |
| 1445 | 1476 | let row_label = label(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); |
| 1446 | 1477 | let row_chord = mono(type_scale::CHORD_METADATA_MIN_PX, FontWeight::MEDIUM); |
| 1447 | 1478 | let pair = move |text: String, chord: String, ink: u32| { |
| @@ -1477,6 +1508,10 @@ fn keys_tab(player: &Player) -> impl IntoElement { | ||
| 1477 | 1508 | }; |
| 1478 | 1509 | div() |
| 1479 | 1510 | .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 | + })) | |
| 1480 | 1515 | .flex_1() |
| 1481 | 1516 | .min_h(px(0.)) |
| 1482 | 1517 | .flex() |
| @@ -1551,7 +1586,7 @@ pub(crate) fn render( | ||
| 1551 | 1586 | .child(dock_tab("dock-tab-clip", "CLIP", !src_active && !keys, cx)), |
| 1552 | 1587 | ) |
| 1553 | 1588 | .child(match (keys, src_active) { |
| 1554 | - (true, _) => keys_tab(player).into_any_element(), | |
| 1589 | + (true, _) => keys_tab(player, cx).into_any_element(), | |
| 1555 | 1590 | (false, true) => sources_tab(player, window, cx).into_any_element(), |
| 1556 | 1591 | (false, false) => clip_tab(player, width, window_size, window, cx).into_any_element(), |
| 1557 | 1592 | }) |
crates/app/src/ui/theme.rsmodified+0 -14
| @@ -104,7 +104,6 @@ palette! { | ||
| 104 | 104 | SCRIM: u32, |
| 105 | 105 | SCRIM_LIGHT: u32, |
| 106 | 106 | STROKE_DIVIDER: u32, |
| 107 | - STROKE_FOCUS: u32, | |
| 108 | 107 | STROKE_SELECTED: u32, |
| 109 | 108 | FG_PRIMARY: u32, |
| 110 | 109 | FG_SECONDARY: u32, |
| @@ -348,7 +347,6 @@ pub mod cool { | ||
| 348 | 347 | |
| 349 | 348 | // -- strokes ---------------------------------------------------------------- |
| 350 | 349 | pub const STROKE_DIVIDER: u32 = 0x2a3442; |
| 351 | - pub const STROKE_FOCUS: u32 = 0xffd166; | |
| 352 | 350 | pub const STROKE_SELECTED: u32 = 0x22d3ee; |
| 353 | 351 | |
| 354 | 352 | // -- text ------------------------------------------------------------------- |
| @@ -440,7 +438,6 @@ pub mod warm { | ||
| 440 | 438 | |
| 441 | 439 | // -- strokes ---------------------------------------------------------------- |
| 442 | 440 | pub const STROKE_DIVIDER: u32 = 0x3a322e; |
| 443 | - pub const STROKE_FOCUS: u32 = 0xffc38a; | |
| 444 | 441 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 445 | 442 | |
| 446 | 443 | // -- text ------------------------------------------------------------------- |
| @@ -525,7 +522,6 @@ pub mod forest { | ||
| 525 | 522 | |
| 526 | 523 | // -- strokes ---------------------------------------------------------------- |
| 527 | 524 | pub const STROKE_DIVIDER: u32 = 0x25362c; |
| 528 | - pub const STROKE_FOCUS: u32 = 0xffd166; | |
| 529 | 525 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 530 | 526 | |
| 531 | 527 | // -- text ------------------------------------------------------------------- |
| @@ -609,7 +605,6 @@ pub mod violet { | ||
| 609 | 605 | |
| 610 | 606 | // -- strokes ---------------------------------------------------------------- |
| 611 | 607 | pub const STROKE_DIVIDER: u32 = 0x2e3150; |
| 612 | - pub const STROKE_FOCUS: u32 = 0xfde68a; | |
| 613 | 608 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 614 | 609 | |
| 615 | 610 | // -- text ------------------------------------------------------------------- |
| @@ -688,7 +683,6 @@ pub mod rose { | ||
| 688 | 683 | |
| 689 | 684 | // -- strokes ---------------------------------------------------------------- |
| 690 | 685 | pub const STROKE_DIVIDER: u32 = 0x332f33; |
| 691 | - pub const STROKE_FOCUS: u32 = 0xfcd34d; | |
| 692 | 686 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 693 | 687 | |
| 694 | 688 | // -- text ------------------------------------------------------------------- |
| @@ -769,7 +763,6 @@ pub mod amber { | ||
| 769 | 763 | |
| 770 | 764 | // -- strokes ---------------------------------------------------------------- |
| 771 | 765 | pub const STROKE_DIVIDER: u32 = 0x35352f; |
| 772 | - pub const STROKE_FOCUS: u32 = 0x7dd3fc; | |
| 773 | 766 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 774 | 767 | |
| 775 | 768 | // -- text ------------------------------------------------------------------- |
| @@ -848,7 +841,6 @@ pub mod ocean { | ||
| 848 | 841 | |
| 849 | 842 | // -- strokes ---------------------------------------------------------------- |
| 850 | 843 | pub const STROKE_DIVIDER: u32 = 0x1e2d42; |
| 851 | - pub const STROKE_FOCUS: u32 = 0xffd166; | |
| 852 | 844 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 853 | 845 | |
| 854 | 846 | // -- text ------------------------------------------------------------------- |
| @@ -928,7 +920,6 @@ pub mod ice { | ||
| 928 | 920 | |
| 929 | 921 | // -- strokes ---------------------------------------------------------------- |
| 930 | 922 | pub const STROKE_DIVIDER: u32 = 0x223140; |
| 931 | - pub const STROKE_FOCUS: u32 = 0xfcd34d; | |
| 932 | 923 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 933 | 924 | |
| 934 | 925 | // -- text ------------------------------------------------------------------- |
| @@ -1006,7 +997,6 @@ pub mod orchid { | ||
| 1006 | 997 | |
| 1007 | 998 | // -- strokes ---------------------------------------------------------------- |
| 1008 | 999 | pub const STROKE_DIVIDER: u32 = 0x33203f; |
| 1009 | - pub const STROKE_FOCUS: u32 = 0x7dd3fc; | |
| 1010 | 1000 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1011 | 1001 | |
| 1012 | 1002 | // -- text ------------------------------------------------------------------- |
| @@ -1093,7 +1083,6 @@ pub mod nord { | ||
| 1093 | 1083 | |
| 1094 | 1084 | // -- strokes ---------------------------------------------------------------- |
| 1095 | 1085 | pub const STROKE_DIVIDER: u32 = 0x434c5e; |
| 1096 | - pub const STROKE_FOCUS: u32 = 0xd08770; | |
| 1097 | 1086 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1098 | 1087 | |
| 1099 | 1088 | // -- text ------------------------------------------------------------------- |
| @@ -1183,7 +1172,6 @@ pub mod gruvbox { | ||
| 1183 | 1172 | |
| 1184 | 1173 | // -- strokes ---------------------------------------------------------------- |
| 1185 | 1174 | pub const STROKE_DIVIDER: u32 = 0x504945; |
| 1186 | - pub const STROKE_FOCUS: u32 = 0x83a598; | |
| 1187 | 1175 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1188 | 1176 | |
| 1189 | 1177 | // -- text ------------------------------------------------------------------- |
| @@ -1264,7 +1252,6 @@ pub mod dracula { | ||
| 1264 | 1252 | |
| 1265 | 1253 | // -- strokes ---------------------------------------------------------------- |
| 1266 | 1254 | pub const STROKE_DIVIDER: u32 = 0x44475a; |
| 1267 | - pub const STROKE_FOCUS: u32 = 0x8be9fd; | |
| 1268 | 1255 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1269 | 1256 | |
| 1270 | 1257 | // -- text ------------------------------------------------------------------- |
| @@ -1360,7 +1347,6 @@ pub mod darkroom { | ||
| 1360 | 1347 | |
| 1361 | 1348 | // -- strokes -------------------------------------------------------------- |
| 1362 | 1349 | pub const STROKE_DIVIDER: u32 = 0x22262b; |
| 1363 | - pub const STROKE_FOCUS: u32 = INK1; | |
| 1364 | 1350 | /// "Focus/selection ring = 1px ink1 (lamp-adjacent, not coloured)." |
| 1365 | 1351 | pub const STROKE_SELECTED: u32 = INK1; |
| 1366 | 1352 |