From ede1e2cbd1694e4bb7a6d647f2e09882e10d306a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 01:24:02 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ui):=20the=20bench=20floor?= =?UTF-8?q?=20counts=20its=20own=20border=20and=20the=20ledger's?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BENCH_CHROME_H undercounted the section head's real line box by 1px (gpui's phi line-height, not the label's bare 10px font size) and never counted the bench div's own top border. BENCH_MIN_H also never reserved a row for the ledger's fixed-position top border, which sits below the bench regardless of bench_h -- a bench exactly as tall as its content still shared its last pixel row with that border and lost it. Both are now named terms (BENCH_CHROME_H = 21, LEDGER_SEAM_CLEARANCE = 1), raising the floor from 94 to 96, and a new test locks BENCH_CHROME_H to what stance::bench actually draws plus the ledger's clearance. --- crates/app/src/layout.rs | 61 ++++++++++++++++++++++++---------- crates/app/src/tests/layout.rs | 59 +++++++++++++++++++++++++++++++- crates/app/src/ui/stance.rs | 17 +++++++--- 3 files changed, 113 insertions(+), 24 deletions(-) diff --git a/crates/app/src/layout.rs b/crates/app/src/layout.rs index 6123ecd..86be643 100644 --- a/crates/app/src/layout.rs +++ b/crates/app/src/layout.rs @@ -432,31 +432,56 @@ pub(crate) const SIDE_MAX_FRAC: f32 = 1. / 3.; /// timeline is asking on purpose, and the picture still keeps most of a third. pub(crate) const TIMELINE_MAX_SHARE: f32 = 0.7; +/// The room the ledger's own top border (`ui::stance::ledger`'s +/// `.border_t_1()`) needs kept clear below the bench's own last content +/// pixel. The ledger sits at a *fixed* distance from the window's own foot +/// (`ui::stance::LEDGER_H`), not from wherever the bench's content happens +/// to end, so if the bench's last lane row reaches exactly as far as the +/// ledger's own top row, the ledger's border -- later in the same flex +/// column, so it paints over whatever is already there -- wins the shared +/// pixel rather than sitting cleanly below it. Driven, at [`BENCH_MIN_H`]'s +/// own third clip: `bench=95` (the stack's exact content need, no spare row) +/// still lost A1's status dot's last row to the rule; `bench=96` (one row of +/// clearance) drew it whole. The 95-vs-96 tension is this term, not a +/// rounding accident -- a bench exactly as tall as its content still shares +/// its last row with the ledger's border. +const LEDGER_SEAM_CLEARANCE: f32 = 1.; + /// The least the darkroom's bench may be dragged to: derived, not measured, /// from the same stack `ui::stance::bench` and `ui::bench_stance::render` /// actually build, top to bottom -- -/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head and its -/// padding) + [`crate::ui::bench_stance::RULER_H`] (the pinned ruler) + -/// [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s flex -/// column puts between the ruler and the lane column) + two lane rows at -/// [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor of -/// two lanes -- V1, A1, `bench_stance::render`'s own no-session fallback) -/// + one more `ROW_GAP` between those two rows (`bench-lanes`'s own flex -/// gap). Below this the `bench-lanes` column asks for more height than -/// `bench-content`'s flex_1 gives it, and since that column scrolls rather -/// than clips visibly, the shortfall comes off the bottom row's own pixels -/// unscrolled -- A1's clip-bar border and status dot, first. `LANE_MIN_H` -/// itself is now derived from what a lane head actually draws (its own -/// doc comment), not a number copied from nowhere: an earlier floor of -/// `82.` used a `LANE_MIN_H` of `18.` that fit only the lane label and let -/// every lane's status dot overflow into the row beneath it, invisible -/// everywhere but the last lane, which has no next row to spill into and -/// clipped straight into the ledger instead. +/// [`crate::ui::stance::BENCH_CHROME_H`] (the "bench" section head's real +/// line box, plus the bench div's own top border and top padding -- see its +/// own doc comment) + [`crate::ui::bench_stance::RULER_H`] (the pinned +/// ruler) + [`crate::ui::bench_stance::ROW_GAP`] (the gap `bench-content`'s +/// flex column puts between the ruler and the lane column) + two lane rows +/// at [`crate::ui::bench_stance::LANE_MIN_H`] each (the darkroom's own floor +/// of two lanes -- V1, A1, `bench_stance::render`'s own no-session +/// fallback) + one more `ROW_GAP` between those two rows (`bench-lanes`'s +/// own flex gap) + [`LEDGER_SEAM_CLEARANCE`] (the row the ledger's own +/// border needs kept clear, see its own doc comment). Below this the +/// `bench-lanes` column asks for more height than `bench-content`'s flex_1 +/// gives it, and since that column scrolls rather than clips visibly, the +/// shortfall comes off the bottom row's own pixels unscrolled -- A1's +/// clip-bar border and status dot, first. `LANE_MIN_H` itself is derived +/// from what a lane head actually draws (its own doc comment), not a number +/// copied from nowhere: an earlier floor of `82.` used a `LANE_MIN_H` of +/// `18.` that fit only the lane label and let every lane's status dot +/// overflow into the row beneath it, invisible everywhere but the last +/// lane, which has no next row to spill into and clipped straight into the +/// ledger instead. +/// +/// A third driven pass at the next floor (`94.`, `BENCH_CHROME_H` still +/// undercounted at `20.`) clipped A1's dot again, by one row -- two 1px +/// causes stacked, not one 2px guess: `BENCH_CHROME_H`'s own undercount +/// (`20.` vs its real `21.`) and this term, `LEDGER_SEAM_CLEARANCE`, which +/// the formula never carried at all. `21 + 22 + 2 + 48 + 2 + 1` = `96.`. pub(crate) const BENCH_MIN_H: f32 = crate::ui::stance::BENCH_CHROME_H + crate::ui::bench_stance::RULER_H + crate::ui::bench_stance::ROW_GAP + 2. * crate::ui::bench_stance::LANE_MIN_H - + crate::ui::bench_stance::ROW_GAP; + + crate::ui::bench_stance::ROW_GAP + + LEDGER_SEAM_CLEARANCE; /// What a hand has done to the three seams: the size it dragged each panel to, /// or `None` where nobody has touched one and the window's own share still diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 4df7022..4b2b2d8 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -1808,7 +1808,11 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { let box_h = BENCH_MIN_H - BENCH_CHROME_H; let avail = box_h - RULER_H - ROW_GAP; let h = row_h(2, avail); - assert_eq!(h, LANE_MIN_H, "the floor should give both lanes exactly their own minimum -- no more, no less"); + // Not an exact `LANE_MIN_H` any more: `BENCH_MIN_H` now carries one spare + // row (`layout::LEDGER_SEAM_CLEARANCE`) so the last lane's own last pixel + // never shares a row with the ledger's border, which lands here as + // `avail` being a touch over the two-rows-plus-gap tight fit. + assert!(h >= LANE_MIN_H, "the floor should give both lanes at least their own minimum ({h} < {LANE_MIN_H})"); let content = 2. * h + ROW_GAP; assert!( content <= avail + 1e-4, @@ -1817,6 +1821,59 @@ fn both_default_lanes_fit_the_bench_at_its_floor() { ); } +/// `BENCH_CHROME_H` on its own: the previous test's `box_h = BENCH_MIN_H - +/// BENCH_CHROME_H` line trusts `BENCH_CHROME_H` to already be correct, so it +/// cannot catch `BENCH_CHROME_H` itself drifting -- which is exactly how the +/// third clip (this session's) survived it: the constant undercounted the +/// section head's real line box by 1px and this test's predecessor never +/// looked. Recomputes what `ui::stance::bench` actually draws above +/// `bench_stance::render`'s content -- the div's own `.border_t_1()` (1px) +/// + its `py(4.)` top padding + the section head's real line box at gpui's +/// golden-ratio line-height, not the label's bare font size (the same trap +/// `a_lane_row_fits_what_its_own_head_draws` already checks for the lane +/// heads) -- and then checks the *whole* stack -- chrome, ruler, both gaps, +/// both lanes, and the clear row the ledger's own fixed-position border +/// needs (`LEDGER_SEAM_CLEARANCE`, not exported, so this recomputes it as +/// `BENCH_MIN_H` minus every other named term) -- fits inside `BENCH_MIN_H` +/// with nothing left over uncounted. This binary carries no `TestAppContext` +/// to mount `ui::stance::bench` and `ui::stance::ledger` for real and read +/// painted bounds back, so it stays geometry-only, same as its neighbours. +#[test] +fn the_whole_bench_stack_fits_its_own_floor_with_the_ledger_seam_clear() { + use crate::BENCH_MIN_H; + use crate::ui::bench_stance::{LANE_MIN_H, ROW_GAP, RULER_H}; + use crate::ui::stance::BENCH_CHROME_H; + use crate::ui::type_scale::SECTION_HEAD_PX; + + const BENCH_BORDER_T: f32 = 1.; + const BENCH_PY_TOP: f32 = 4.; + let section_head_line_h = (SECTION_HEAD_PX * 1.618_034).round(); + let real_chrome = BENCH_BORDER_T + BENCH_PY_TOP + section_head_line_h; + assert_eq!( + BENCH_CHROME_H, real_chrome, + "BENCH_CHROME_H ({BENCH_CHROME_H}) does not match what `stance::bench` \ + actually draws above the content ({real_chrome}px: {BENCH_BORDER_T}px \ + border + {BENCH_PY_TOP}px padding + {section_head_line_h}px label line \ + box) -- bench_stance::render gets handed the wrong box_h and lays its \ + rows out past its own real space" + ); + + // The ledger's own fixed-position border needs one more clear row below + // the last lane, on top of chrome + ruler + both gaps + both lanes -- + // recomputed here rather than importing the private + // `layout::LEDGER_SEAM_CLEARANCE`, so this test fails if that term is + // ever silently dropped from `BENCH_MIN_H`'s own sum. + let content_need = real_chrome + RULER_H + ROW_GAP + 2. * LANE_MIN_H + ROW_GAP; + let ledger_seam_clearance = BENCH_MIN_H - content_need; + assert!( + ledger_seam_clearance >= 1. - 1e-4, + "BENCH_MIN_H ({BENCH_MIN_H}) leaves only {ledger_seam_clearance}px \ + between the last lane row and the ledger's own top border -- driven \ + at exactly the content's need (0px clearance) the border still won \ + the shared pixel and clipped the last lane's status dot" + ); +} + /// The previous test asserted lane ROWS fit the bench column -- not that a /// lane's own CONTENT fits its row, which is how the defect it fixed /// survived it: at the old `LANE_MIN_H` of `18.` both lanes fit the bench diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index af198b8..0c6883a 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -36,11 +36,18 @@ pub(crate) const LEDGER_H: f32 = 28.; /// role [`BENCH_H`] plays for the bench. pub(crate) const DOCK_W: f32 = 280.; /// What [`bench`] spends above `bench_stance::render`'s own content: the -/// section head (`type_scale::head`, 10px Archivo) plus its `py(4.)` top and -/// bottom padding. Named and `pub(crate)` rather than the `- 20.` it used to -/// be inlined as, so `layout::BENCH_MIN_H` can add it into its own -/// derivation instead of guessing it back out. -pub(crate) const BENCH_CHROME_H: f32 = 20.; +/// `bench` div's own `.border_t_1()` (1px) + its `py(4.)` top padding + +/// the section head's real line box -- `type_scale::head()` sizes text at +/// `SECTION_HEAD_PX` (10) but never calls `.line_height()`, so gpui's +/// default `TextStyle::line_height` (the golden ratio, `gpui::phi()` == +/// `1.618034`, not 1x the font size) is what it actually draws: +/// `round(10. * 1.618034)` = `round(16.18034)` = `16`. A driven pass found +/// this constant undercounting that line box as a bare `10`, one of the two +/// causes of `layout::BENCH_MIN_H`'s third clip (see its own doc comment for +/// the other). `1 + 4 + 16` = `21`. Named and `pub(crate)` rather than the +/// `- 20.` it used to be inlined as, so `layout::BENCH_MIN_H` can add it +/// into its own derivation instead of guessing it back out. +pub(crate) const BENCH_CHROME_H: f32 = 21.; /// The lowest a menu's top edge may sit and still land inside the /// bench/ledger/dock footprint below the screen (DESIGN §5, §9, §11 check 6):