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