refactor: replace signed out view with explore banner
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run

This commit is contained in:
2026-11-24 09:46:11 +07:00
parent bac641002d
commit 3f9e4e1c12
8 changed files with 548 additions and 237 deletions
+241 -1
View File
@@ -10,7 +10,7 @@ use gpui::{
size,
};
use ui::common::v_flex;
use ui::layout::panel::{Panel, PanelSlot, PanelStack, PanelView};
use ui::layout::panel::{Panel, PanelSlot, PanelStack, PanelView, SplitSide};
use ui::tabs::Tabs;
use ui::theme::Theme;
@@ -580,3 +580,243 @@ fn main_tabs_switch_and_close_the_main_stack(cx: &mut TestAppContext) {
"the shown panel stays"
);
}
/// A split inserted at a width opens with it.
#[gpui::test]
fn a_split_inserted_at_a_width_opens_there(cx: &mut TestAppContext) {
let (mut cx, stack) = stack_window(cx, main_only);
cx.update(|_, cx| {
stack.update(cx, |stack, cx| {
stack.insert_split_at(
"side",
px(300.),
SplitSide::Trailing,
Arc::new(tag(cx, "panel-test-split")),
cx,
)
})
});
cx.run_until_parked();
let split = cx
.debug_bounds("panel-test-split")
.expect("split panel laid out");
assert!((split.size.width - px(300.0)).abs() <= px(2.0));
cx.update(|_, cx| {
let stack = stack.read(cx);
let side = SharedString::from("side");
assert!(stack.is_open(PanelSlot::Split, &side));
assert!(stack.is_active(PanelSlot::Split, &side));
});
}
/// A split already on screen keeps its divider and side when another opens at a width.
#[gpui::test]
fn a_width_and_side_apply_to_a_split_new_to_the_screen_only(cx: &mut TestAppContext) {
let (mut cx, stack) = stack_window(cx, main_and_split);
let before = cx
.debug_bounds("panel-test-main")
.expect("main panel laid out");
cx.update(|_, cx| {
stack.update(cx, |stack, cx| {
stack.insert_split_at(
"side",
px(300.),
SplitSide::Leading,
Arc::new(tag(cx, "panel-test-side")),
cx,
)
})
});
cx.run_until_parked();
let after = cx
.debug_bounds("panel-test-main")
.expect("main panel laid out");
assert_eq!(after, before);
cx.update(|_, cx| {
let stack = stack.read(cx);
let split = SharedString::from("split");
assert!(stack.is_open(PanelSlot::Split, &split));
assert!(!stack.is_active(PanelSlot::Split, &split));
});
let side = cx
.debug_bounds("panel-test-side")
.expect("the new split panel laid out");
assert!(
side.left() >= after.right(),
"it still opens after the main panel"
);
}
/// A split opened at a width keeps it across window resizes until the divider is dragged.
#[gpui::test]
fn a_width_split_follows_resizes_until_dragged(cx: &mut TestAppContext) {
let (mut cx, _stack) = stack_window(cx, |stack, cx| {
main_only(stack, cx);
stack.insert_split_at(
"side",
px(300.),
SplitSide::Trailing,
Arc::new(tag(cx, "panel-test-split")),
cx,
);
});
cx.simulate_resize(size(px(WINDOW_WIDTH + 400.0), px(WINDOW_HEIGHT)));
cx.run_until_parked();
let split = cx
.debug_bounds("panel-test-split")
.expect("split panel laid out after the resize");
assert!(
(split.size.width - px(300.0)).abs() <= px(2.0),
"the split keeps its width: {:?}",
split.size.width
);
let handle = cx.debug_bounds("resize-handle").expect("divider laid out");
let seam = point(handle.center().x, px(400.0));
cx.simulate_event(MouseDownEvent {
position: seam,
button: MouseButton::Left,
modifiers: Modifiers::default(),
click_count: 1,
first_mouse: false,
});
cx.simulate_event(MouseMoveEvent {
position: point(seam.x + px(100.0), seam.y),
pressed_button: Some(MouseButton::Left),
modifiers: Modifiers::default(),
});
cx.simulate_event(MouseUpEvent {
position: point(seam.x + px(100.0), seam.y),
button: MouseButton::Left,
modifiers: Modifiers::default(),
click_count: 1,
});
cx.run_until_parked();
let dragged = cx
.debug_bounds("panel-test-main")
.expect("main panel laid out after the drag")
.size
.width;
cx.simulate_resize(size(px(WINDOW_WIDTH), px(WINDOW_HEIGHT)));
cx.run_until_parked();
let resized = cx
.debug_bounds("panel-test-main")
.expect("main panel laid out after the resize")
.size
.width;
assert_eq!(resized, dragged, "a dragged divider keeps its pane's width");
}
/// A leading split opens before the main panel and keeps its width, dragged or not, across window resizes.
#[gpui::test]
fn a_leading_split_opens_before_the_main_panel_at_its_width(cx: &mut TestAppContext) {
let (mut cx, _stack) = stack_window(cx, |stack, cx| {
main_only(stack, cx);
stack.insert_split_at(
"side",
px(300.),
SplitSide::Leading,
Arc::new(tag(cx, "panel-test-split")),
cx,
);
});
let split = cx
.debug_bounds("panel-test-split")
.expect("split panel laid out");
let main = cx
.debug_bounds("panel-test-main")
.expect("main panel laid out");
assert!(split.right() <= main.left(), "the split comes first");
assert!((split.size.width - px(300.0)).abs() <= px(2.0));
cx.simulate_resize(size(px(WINDOW_WIDTH + 400.0), px(WINDOW_HEIGHT)));
cx.run_until_parked();
let split = cx
.debug_bounds("panel-test-split")
.expect("split panel laid out after the resize");
assert!(
(split.size.width - px(300.0)).abs() <= px(2.0),
"the split keeps its width: {:?}",
split.size.width
);
// Drag the divider 100px right, then put the window back: the split keeps the dragged width.
let handle = cx.debug_bounds("resize-handle").expect("divider laid out");
let seam = point(handle.center().x, px(400.0));
cx.simulate_event(MouseDownEvent {
position: seam,
button: MouseButton::Left,
modifiers: Modifiers::default(),
click_count: 1,
first_mouse: false,
});
cx.simulate_event(MouseMoveEvent {
position: point(seam.x + px(100.0), seam.y),
pressed_button: Some(MouseButton::Left),
modifiers: Modifiers::default(),
});
cx.simulate_event(MouseUpEvent {
position: point(seam.x + px(100.0), seam.y),
button: MouseButton::Left,
modifiers: Modifiers::default(),
click_count: 1,
});
cx.run_until_parked();
cx.simulate_resize(size(px(WINDOW_WIDTH), px(WINDOW_HEIGHT)));
cx.run_until_parked();
let split = cx
.debug_bounds("panel-test-split")
.expect("split panel laid out after the resize");
assert!(
(split.size.width - px(400.0)).abs() <= px(2.0),
"the split keeps its dragged width: {:?}",
split.size.width
);
}
/// Once no split is on screen, the next one opens after the main panel again.
#[gpui::test]
fn a_split_after_a_leading_one_opens_after_the_main_panel(cx: &mut TestAppContext) {
let (mut cx, stack) = stack_window(cx, |stack, cx| {
main_only(stack, cx);
stack.insert_split_at(
"side",
px(300.),
SplitSide::Leading,
Arc::new(tag(cx, "panel-test-side")),
cx,
);
});
let side = SharedString::from("side");
cx.update(|_, cx| {
stack.update(cx, |stack, cx| {
stack.close(PanelSlot::Split, &side, cx);
stack.insert(
PanelSlot::Split,
"split",
Arc::new(tag(cx, "panel-test-split")),
cx,
);
})
});
cx.run_until_parked();
let main = cx
.debug_bounds("panel-test-main")
.expect("main panel laid out");
let split = cx
.debug_bounds("panel-test-split")
.expect("split panel laid out");
assert!(
main.right() <= split.left(),
"the split opens after the main panel again"
);
}