Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

fix(web): put a pane's rows right under its bar on a desktop-sized page

RoversX7227315a83a8
diff --git a/thinkterm-web/src/app.rs b/thinkterm-web/src/app.rs
index d02b72d1..9271b821 100644
--- a/thinkterm-web/src/app.rs
+++ b/thinkterm-web/src/app.rs
@@ -2940,15 +2940,19 @@ impl<P: Platform, L: Link> App<P, L> {
crate::navbar::nav_css(cell_css, Self::desktop_cell_css(inner))
}
- /// The bar's height as the grid pays for it: whole rows. The bar's
- /// own height is a fraction of a row, and the pane gives up the
- /// rounded-up count; drawing the content a fraction below the bar
- /// left the difference as a blank strip under the last row, on top of
- /// the half-cell pad -- a row and a half of nothing at the bottom of
- /// every pane. The bar is drawn to the rounded height (`nav_views`), so
- /// bar and content meet.
+ /// The bar's height in device px. The pane gives up the rounded-up
+ /// count of rows for it either way. A page in the desktop's shape
+ /// draws the bar at its own height with the rows right under it
+ /// (`content_offset`), as the desktop does: drawn to the rows it pays
+ /// for, it left the rounding as a blank band under the capsules. A
+ /// phone draws it to those rows, so its rows stay flush with the
+ /// bottom of the screen (`pad`).
fn nav_dev(inner: &Inner<P, L>) -> f32 {
- Self::nav_rows(inner) as f32 * inner.glyphs.metrics.cell_size.height as f32
+ let rows = Self::nav_rows(inner);
+ if inner.mobile || rows == 0 {
+ return rows as f32 * inner.glyphs.metrics.cell_size.height as f32;
+ }
+ (Self::nav_css(inner) * inner.dpr) as f32
}
/// Where the grid starts in the canvas, in device px: the desktop's
@@ -3011,8 +3015,8 @@ impl<P: Platform, L: Link> App<P, L> {
fn nav_views(inner: &Inner<P, L>) -> Vec<crate::navbar::NavView> {
let mut views = Vec::new();
// No rows for the bars, no bars: a phone shows a lone pane bare.
- // A bar's height is its rows plus the padding above the pane, so
- // without this the padding alone drew a sliver of one.
+ // A bar reaches from above the pane down to its rows, so without
+ // this the padding alone drew a sliver of one.
if Self::nav_rows(inner) == 0 {
return views;
}
@@ -3028,8 +3032,8 @@ impl<P: Platform, L: Link> App<P, L> {
let pad = Self::pad(inner);
let pad_css = (pad.0 as f64 / dpr, pad.1 as f64 / dpr);
let width_css = inner.gpu.size().0 as f64 / dpr;
- let nav_rows_css = Self::nav_rows(inner) as f64 * cell_css.1;
- for (rect, place) in crate::navbar::rects(layout, cell_css, nav_rows_css, pad_css, width_css)
+ let rows_below = |p: &crate::layout::PanePlacement| Self::content_offset(inner, p) as f64 / dpr;
+ for (rect, place) in crate::navbar::rects(layout, cell_css, pad_css, width_css, rows_below)
.into_iter()
.zip(&layout.panes)
{
@@ -6058,13 +6062,22 @@ impl<P: Platform, L: Link> App<P, L> {
)
}
- /// How far below its frame's top a pane's content starts: the bar.
- /// A pane the server has at its whole frame (a layout nobody with a
- /// bar has claimed yet) loses its last rows under the frame's bottom
- /// rather than its first under the bar -- the prompt is at the top,
- /// and the next claim from here makes room.
- fn content_offset(inner: &Inner<P, L>, _place: &crate::layout::PanePlacement) -> f32 {
- Self::nav_dev(inner)
+ /// How far below its frame's top a pane's content starts: right under
+ /// the bar, which on a desktop-shaped page starts above the frame
+ /// (`navbar::rows_offset_css`), in whole device px so the text stays
+ /// sharp. A pane the server has at its whole frame (a layout nobody
+ /// with a bar has claimed yet) loses its last rows under the frame's
+ /// bottom rather than its first under the bar -- the prompt is at the
+ /// top, and the next claim from here makes room.
+ fn content_offset(inner: &Inner<P, L>, place: &crate::layout::PanePlacement) -> f32 {
+ let nav = Self::nav_dev(inner);
+ if inner.mobile || nav <= 0.0 {
+ return nav;
+ }
+ let dpr = inner.dpr.max(0.1);
+ let ch = inner.glyphs.metrics.cell_size.height as f64 / dpr;
+ let pad_top = Self::pad(inner).1 as f64 / dpr;
+ (crate::navbar::rows_offset_css(place.frame.top, ch, pad_top, nav as f64 / dpr) * dpr).round() as f32
}
/// The panes as this page would claim them: the desktop's rule for
diff --git a/thinkterm-web/src/navbar.rs b/thinkterm-web/src/navbar.rs
index 0fb10fad..960b22d5 100644
--- a/thinkterm-web/src/navbar.rs
+++ b/thinkterm-web/src/navbar.rs
@@ -47,6 +47,28 @@ pub fn content_offset_dev(place: &PanePlacement, nav_dev: f32, cell_h_dev: f32)
nav_dev.min(spare)
}
+/// Where a pane's bar starts, in CSS px from the canvas's top. A pane on
+/// the tab's top row starts at the window's edge, over the padding, like
+/// one at its left edge. Below a divider the bar starts right under the
+/// line, which sits in the middle of the gap row, as the desktop's does.
+pub fn bar_top(frame_top: usize, ch: f64, pad_top: f64) -> f64 {
+ if frame_top == 0 {
+ 0.0
+ } else {
+ pad_top + frame_top as f64 * ch - ch / 2.0 + 1.0
+ }
+}
+
+/// How far below its frame's top a pane's rows start under a bar
+/// `nav_css` tall, in CSS px: right under the bar, as the desktop draws
+/// them (`render/pane.rs`, `pane_nav_height` below the bar's top). The
+/// bar starts above the frame, so the rows start less than a bar below
+/// it, and the part of a row the pane's rows leave is under the last one,
+/// where the desktop leaves it too.
+pub fn rows_offset_css(frame_top: usize, ch: f64, pad_top: f64, nav_css: f64) -> f64 {
+ (bar_top(frame_top, ch, pad_top) + nav_css - (pad_top + frame_top as f64 * ch)).max(0.0)
+}
+
/// Where a bar goes, in CSS px from the canvas's top-left.
#[derive(Debug, Clone, PartialEq, serde::Serialize)]
pub struct NavRect {
@@ -62,13 +84,14 @@ pub struct NavRect {
/// desktop's: to the window's edge where the pane touches the tab's
/// edge (past the padding the grid sits in), half a cell into the
/// divider where it does not, so neighbours tile. `pad_css` is where the
-/// grid starts and `width_css` the canvas's width.
+/// grid starts, `width_css` the canvas's width, and `rows_below` how far
+/// below its frame's top a pane's rows start: the bar reaches down to them.
pub fn rects(
layout: &TabLayout,
cell_css: (f64, f64),
- nav_css: f64,
pad_css: (f64, f64),
width_css: f64,
+ rows_below: impl Fn(&PanePlacement) -> f64,
) -> Vec<NavRect> {
let (cw, ch) = cell_css;
layout
@@ -82,17 +105,13 @@ pub fn rects(
} else {
pad_css.0 + end as f64 * cw + cw / 2.0
};
- // A pane on the tab's top row starts at the window's edge,
- // over the padding, like one at its left edge.
- // Below a divider the bar starts right under the line, which
- // sits in the middle of the gap row, as the desktop's does.
- let top = if p.frame.top == 0 { 0.0 } else { pad_css.1 + p.frame.top as f64 * ch - ch / 2.0 + 1.0 };
+ let top = bar_top(p.frame.top, ch, pad_css.1);
NavRect {
pane_id: p.pane_id,
left,
top,
width: right - left,
- height: nav_css + (pad_css.1 + p.frame.top as f64 * ch - top),
+ height: pad_css.1 + p.frame.top as f64 * ch + rows_below(p) - top,
}
})
.collect()
@@ -212,17 +231,48 @@ mod tests {
zoomed: None,
hidden: vec![],
};
- let r = rects(&layout, (10.0, 20.0), 47.0, (0.0, 0.0), 800.0);
+ let r = rects(&layout, (10.0, 20.0), (0.0, 0.0), 800.0, |_| 47.0);
assert_eq!((r[0].left, r[0].width), (0.0, 405.0), "to the divider's middle");
assert_eq!((r[1].left, r[1].width), (405.0, 395.0), "from it to the tab's edge");
assert_eq!(r[0].height, 47.0);
// With the grid padded in a wider canvas, the outer bars still
// reach the window's edges; the inner edge moves with the grid.
- let r = rects(&layout, (10.0, 20.0), 47.0, (10.0, 10.0), 1000.0);
+ // The bar reaches down over the padding to the rows.
+ let r = rects(&layout, (10.0, 20.0), (10.0, 10.0), 1000.0, |_| 47.0);
assert_eq!((r[0].left, r[0].top, r[0].width, r[0].height), (0.0, 0.0, 415.0, 57.0));
assert_eq!((r[1].left, r[1].width), (415.0, 585.0));
}
+ #[test]
+ fn the_rows_start_right_under_the_bar_as_on_the_desktop() {
+ // A pane on the tab's top row: its bar covers the half-cell
+ // padding, so its rows start a bar below the window's edge, not a
+ // bar below the padding.
+ assert_eq!(rows_offset_css(0, 22.0, 11.0, 47.0), 36.0);
+ // Below a divider the bar starts a pixel under the line, half a
+ // cell above the frame.
+ assert_eq!(rows_offset_css(14, 22.0, 11.0, 47.0), 37.0);
+ // Either way the bar is its own height, whatever rows the pane
+ // gave up for it (three of 22px here).
+ let mut lower = place(2, 0, 80, 13, 10);
+ lower.frame.top = 14;
+ let layout = TabLayout {
+ tab_id: 1,
+ window_id: 0,
+ workspace: String::new(),
+ cols: 80,
+ rows: 27,
+ size: TerminalSize::default(),
+ panes: vec![place(1, 0, 80, 13, 10), lower],
+ dividers: vec![],
+ zoomed: None,
+ hidden: vec![],
+ };
+ let r = rects(&layout, (10.0, 22.0), (10.0, 11.0), 820.0, |p| rows_offset_css(p.frame.top, 22.0, 11.0, 47.0));
+ assert_eq!((r[0].top, r[0].height), (0.0, 47.0));
+ assert_eq!((r[1].top, r[1].height), (309.0, 47.0));
+ }
+
#[test]
fn titles_read_like_the_desktop_s() {
let dt = |s: &str| {
diff --git a/thinkterm-web/ui/src/tokens.css b/thinkterm-web/ui/src/tokens.css
index 8c74e816..957dd1c7 100644
--- a/thinkterm-web/ui/src/tokens.css
+++ b/thinkterm-web/ui/src/tokens.css
@@ -348,13 +348,12 @@ body[data-side=off]:not([data-mobile]) #side .list { top: var(--tabs); }
#agents .se-field:focus { border-color: var(--edge); }
#agents .se-body { min-height: 180px; flex: none; resize: vertical; font: 400 13px ui-monospace, "SF Mono", Menlo, monospace; line-height: 1.45; white-space: pre; overflow: auto; }
#agents .se-body.want { border-color: var(--danger); }
-.nav { position: absolute; pointer-events: auto; box-sizing: border-box; display: flex; align-items: flex-start; gap: 9px; padding: 0 5px; background: var(--bg); color: var(--text2); user-select: none; overflow: hidden; }
-/* The bar is the desktop's 47px, but the pane pays for it in whole rows
- (and a pane at the top in its padding too): the capsules sit where they
- would in a 47px bar at its top, and what the rounding adds is left
- under them, as the desktop leaves it -- not split above and below. */
-.nav > .caps, .nav > .acts { margin-top: 8.5px; height: 30px; align-items: center; }
-body[data-mobile] .nav > .caps, body[data-mobile] .nav > .acts { margin-top: 6px; height: 40px; }
+.nav { position: absolute; pointer-events: auto; box-sizing: border-box; display: flex; align-items: center; gap: 9px; padding: 0 5px; background: var(--bg); color: var(--text2); user-select: none; overflow: hidden; }
+/* A phone's bar is drawn down to the whole rows it pays for (and a pane at
+ the top over its padding too): the capsules sit at its top, and what the
+ rounding adds is left under them -- not split above and below. */
+body[data-mobile] .nav { align-items: flex-start; }
+body[data-mobile] .nav > .caps, body[data-mobile] .nav > .acts { margin-top: 6px; height: 40px; align-items: center; }
.nav.focused { color: var(--text); }
.nav .caps { display: flex; gap: 9px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.nav .cap { display: inline-flex; align-items: center; flex: 0 0 auto; width: 128px; height: 30px; box-sizing: border-box; padding: 0 9px; border-radius: 999px; border: 1px solid transparent; background: var(--wash); color: var(--text2); cursor: default; }
@@ -677,13 +676,13 @@ body[data-mobile] .nav > .caps, body[data-mobile] .nav > .acts { margin-top: 6px
#machines .more.open svg { transform: rotate(90deg); }
/* The desktop's empty page: its server glyph over the one line. */
#machines .empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 24px 34px 24px; color: var(--muted); font-size: 13px; line-height: 1.4; text-align: center; }
+#machines .empty svg { width: 28px; height: 28px; stroke-width: 1.6; }
#machines .empty.off .offt { color: var(--text); font-weight: 600; }
/* The `~/.ssh/config` group's caption folds it, as the desktop's does. */
#machines .label.fold { display: flex; align-items: center; gap: 4px; width: calc(100% - 4px); padding: 0; border: 0; background: transparent; text-align: left; cursor: default; font: 600 13px var(--ui); transition: var(--fade); }
#machines .label.fold:hover { color: var(--text); }
#machines .label.fold svg { width: 14px; height: 14px; flex: none; transition: transform .15s; }
#machines .label.fold.open svg { transform: rotate(90deg); }
-#machines .empty svg { width: 28px; height: 28px; stroke-width: 1.6; }
#machines .err { margin: -8px 2px 16px 2px; color: var(--danger); font-size: 12px; }
#machines .addbtn { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px 0 11px; }
#machines .addbtn svg { width: 14px; height: 14px; }