From 2e70caac8e655a04493ab584c74397d6be64490a Mon Sep 17 00:00:00 2001 From: Valentin Millet Date: Fri, 27 Nov 2026 17:09:12 +0100 Subject: [PATCH] HTTP: the environment picker ends at the margin of Save The strip's end used a 10 px inset and left out the item spacing between New request and the picker, which then ran 8 px past its room. --- crates/ui/src/app/rail_toggle_tests.rs | 42 +++++++++++++++++++++++++- crates/ui/src/http/tabs.rs | 17 ++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/crates/ui/src/app/rail_toggle_tests.rs b/crates/ui/src/app/rail_toggle_tests.rs index d88c9059..7f55e9b0 100644 --- a/crates/ui/src/app/rail_toggle_tests.rs +++ b/crates/ui/src/app/rail_toggle_tests.rs @@ -1,4 +1,5 @@ -//! The button that puts the sidebar away stands at one place, whichever area or page is shown. +//! The ends of the bars: the button that puts the sidebar away stands at one place, whichever area +//! or page is shown, and the HTTP strip ends where the request under it ends. use egui_kittest::Harness; use egui_kittest::kittest::Queryable; @@ -74,3 +75,42 @@ fn the_sidebar_toggle_stands_at_one_place_in_every_area_at_both_densities() { } } } + +#[test] +fn the_environment_picker_ends_at_the_margin_of_the_request_line() { + let directory = tempfile::tempdir().unwrap(); + let mut harness = open_library(directory.path()); + let backend = harness.state().backend(); + let local = crate::http::tests::collection(backend, "Local"); + crate::http::tests::request( + backend, + (&local, None), + "Login", + (RequestKind::Http, HttpMethod::Post), + ); + click(&mut harness, "area-option-http"); + harness + .get_by(|node| { + node.author_id() == Some("http-node-name") + && node.label().as_deref() == Some("POST Login") + }) + .click(); + let margin = harness.ctx.content_rect().right() - crate::theme::tokens::BAR_INSET; + for density in [ + crate::theme::Density::Comfortable, + crate::theme::Density::Compact, + ] { + let ctx = harness.ctx.clone(); + let app = harness.state_mut(); + app.state.settings.density = density; + app.state.apply_look(&ctx); + settle(&mut harness); + let picker = toggle(&harness, "http-environment-picker").right(); + let save = toggle(&harness, "http-save").right(); + // « Save » ends where the measured widths of the line leave it: a point or two short. + assert!( + (picker - margin).abs() < 0.5 && save <= margin && margin - save < 3.0, + "{density:?}: the picker ends at {picker}, Save at {save}, the margin at {margin}" + ); + } +} diff --git a/crates/ui/src/http/tabs.rs b/crates/ui/src/http/tabs.rs index 5d9fa217..845778d1 100644 --- a/crates/ui/src/http/tabs.rs +++ b/crates/ui/src/http/tabs.rs @@ -34,6 +34,8 @@ const DIMMED: f32 = 0.55; /// Held this close to an end of the strip, a dragged tab scrolls it, by this much a frame. const EDGE: f32 = 32.0; const EDGE_STEP: f32 = 8.0; +/// Between « New request » and the environment picker. +const END_GAP: f32 = gap::BLOCKS; /// What only the strip's drawing sees: the tab being dragged. #[derive(Default)] @@ -79,7 +81,10 @@ pub(super) fn show(ui: &mut Ui, state: &AppState, view: &mut TabsView, actions: egui::UiBuilder::new() .max_rect(Rect::from_min_max( pos2(toggle_rect.right() + 8.0, bar.top()), - pos2(bar.right() - end_width - 20.0, bar.bottom()), + pos2( + bar.right() - end_width - BAR_INSET - gap::INSET, + bar.bottom(), + ), )) .layout(egui::Layout::left_to_right(egui::Align::Min)), ); @@ -123,16 +128,18 @@ pub(super) fn show(ui: &mut Ui, state: &AppState, view: &mut TabsView, actions: list.widget_info(|| WidgetInfo::labeled(Role::TabList, true, &label)); widgets::address(&strip, &list, "http-tabs"); let end = Rect::from_min_max( - pos2(bar.right() - end_width - 10.0, bar.top()), - pos2(bar.right() - 10.0, bar.bottom()), + pos2(bar.right() - end_width - BAR_INSET, bar.top()), + pos2(bar.right() - BAR_INSET, bar.bottom()), ); let mut end_ui = ui.new_child( egui::UiBuilder::new() .max_rect(end) .layout(egui::Layout::left_to_right(egui::Align::Center)), ); + // `end_width` counts this gap alone: an item spacing on top pushed the picker past the edge. + end_ui.spacing_mut().item_spacing.x = 0.0; new_request(&mut end_ui, actions, language); - end_ui.add_space(gap::CONTROLS); + end_ui.add_space(END_GAP); super::environment_picker::show(&mut end_ui, state, actions); } @@ -364,7 +371,7 @@ fn close_glyph(ui: &Ui, close: &Response) { /// What the end of the strip takes: « New request » and the environment beside it. fn end_width(ui: &Ui, state: &AppState) -> f32 { - new_request_width(ui, state.language) + super::environment_picker::width(ui, state) + 8.0 + new_request_width(ui, state.language) + END_GAP + super::environment_picker::width(ui, state) } fn new_request_width(ui: &Ui, language: i18n::Language) -> f32 {