Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

tui 0.1.14: tab options, New Harness keys, pane spacing and blurred status bar (#877)

lingrd80f391abbec8
diff --git a/tui/Cargo.lock b/tui/Cargo.lock
index 42c73fbcf..4d5857193 100644
--- a/tui/Cargo.lock
+++ b/tui/Cargo.lock
@@ -653,7 +653,7 @@ dependencies = [
[[package]]
name = "harness-tui"
-version = "0.1.13"
+version = "0.1.14"
dependencies = [
"alacritty_terminal",
"crossterm",
diff --git a/tui/Cargo.toml b/tui/Cargo.toml
index 44d0fb75a..639a08717 100644
--- a/tui/Cargo.toml
+++ b/tui/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "harness-tui"
-version = "0.1.13"
+version = "0.1.14"
edition = "2024"
[dependencies]
diff --git a/tui/src/app.rs b/tui/src/app.rs
index 5feaf6712..2196812da 100644
--- a/tui/src/app.rs
+++ b/tui/src/app.rs
@@ -3753,8 +3753,9 @@ impl App {
// swaps the theme's own colours — its background the terminal's foreground, its text the
// terminal's background — so the bar is the theme's text colour with the theme's
// background as its lettering (an ivory bar with dark text on a dark terminal), not a
- // transparent one, and not tmux's stock green.
- if !own && !self.options.pane_look() && !self.options.tmux_look() {
+ // transparent one, and not tmux's stock green. (Whichever focus style: blurred panes keep
+ // the same bar as border ones.)
+ if !own && !self.options.tmux_look() {
let (bg, fg, _) = crate::theme::palette();
s = s.bg(fg).fg(bg);
}
@@ -5224,18 +5225,49 @@ impl App {
}
"border_style" => ("@hn-border", format!("border style: {value}")),
"dim" => ("@hn-dim", format!("dim other panes: {value}")),
+ // ── status bar tabs ──
+ // The two tab options decide the window-status-* format and current-tab style; set the
+ // remembered choice now, then reconcile those derived options the way `[look]` would
+ // at boot, so a live change and a restart agree.
+ "window_active" | "window_name" => {
+ let opt = if knob == "window_active" { "@hn-window-active" } else { "@hn-window-name" };
+ let _ = self.options.set(opt, Some(value), &global, "", 0);
+ self.sync_window_status();
+ (opt, if knob == "window_active" { format!("current tab: {value}") } else { format!("tab name: {value}") })
+ }
_ => return format!("unknown: {value}"),
};
let _ = self.options.set(name, Some(value), &global, "", 0);
self.sync_accent();
// (The bar and the frames change the panes' room: every program is told its size.)
- if matches!(knob, "status_bar" | "border_style") { self.redraw_all = true; self.fit_panes() }
+ if matches!(knob, "status_bar" | "border_style" | "window_active" | "window_name") { self.redraw_all = true }
+ if matches!(knob, "status_bar" | "border_style") { self.fit_panes() }
let i = self.active;
self.view_layout_changed(i);
self.persist_look();
message
}
+ /// Recompute the status bar's `window-status-*` overrides from `@hn-window-name` and
+ /// `@hn-window-active` (which together decide them), the same pair `[look]` emits at boot.
+ fn sync_window_status(&mut self) {
+ let name = self.options.get("@hn-window-name", "", None).unwrap_or_else(|| "tmux".into());
+ let active = self.options.get("@hn-window-active", "", None).unwrap_or_else(|| "star".into());
+ let overrides = crate::options::window_status_overrides(&name, &active);
+ let global = crate::options::SetFlags { global: true, ..Default::default() };
+ let unset = crate::options::SetFlags { global: true, unset: true, ..Default::default() };
+ let mut present = std::collections::HashSet::new();
+ for (opt, val) in overrides {
+ let _ = self.options.set(&opt, Some(&val), &global, "", 0);
+ present.insert(opt);
+ }
+ for opt in ["window-status-format", "window-status-current-format", "window-status-current-style"] {
+ if !present.contains(opt) {
+ let _ = self.options.set(opt, None, &unset, "", 0);
+ }
+ }
+ }
+
/// Write the current look (as the options hold it) to tui.toml's `[look]`, best-effort.
pub fn persist_look(&mut self) {
let mut look = crate::config::Look::default();
@@ -5252,6 +5284,8 @@ impl App {
look.border_style = self.options.get("@hn-border", "", None);
look.status_bar_width = self.options.get("@hn-status-bar-width", "", None);
look.dim = self.options.get("@hn-dim", "", None);
+ look.window_active = self.options.get("@hn-window-active", "", None);
+ look.window_name = self.options.get("@hn-window-name", "", None);
if let Err(e) = crate::config::write_look(&look) { self.say(format!("could not write tui.toml: {e}"), crate::theme::DANGER) }
}
diff --git a/tui/src/bar.rs b/tui/src/bar.rs
index 1842487a3..0c9ff458c 100644
--- a/tui/src/bar.rs
+++ b/tui/src/bar.rs
@@ -836,26 +836,44 @@ mod tests {
let frame = |id: u64| { let r = app.rects.iter().find(|(p, _)| *p == id).map(|(_, r)| *r).unwrap(); crate::pane_frame::boxed_in(r, app.window_area(app.tab()), app.box_inner(app.tab()), app.pane_status(app.tab())).surface };
let (left, top_right, below) = (frame(1), frame(2), frame(3));
let mid = left.y + left.height / 2;
- // The left box's right edge, then at once the right box's left edge: `││`.
+ // Each box is its own frame: the left box's right edge and the right box's left edge touch
+ // (`││`), no blank column between, never two boxes on one line.
assert_eq!(buf[(left.right() - 1, mid)].symbol(), "│", "{s}");
assert_eq!(top_right.x, left.right(), "the boxes touch:\n{s}");
assert_eq!(buf[(top_right.x, top_right.y + 1)].symbol(), "│", "{s}");
- assert_eq!(buf[(left.right() - 1, left.y)].symbol(), "┐", "each box its own corners, not a joint:\n{s}");
+ // Each frame is its own, with its own corners — never joined.
+ assert_eq!(buf[(left.right() - 1, left.y)].symbol(), "┐", "the left box's own corner:\n{s}");
assert_eq!(buf[(left.x, left.y)].symbol(), "┌");
- assert_eq!(buf[(top_right.x, top_right.y)].symbol(), "┌", "the right box is its own, not a joint:\n{s}");
+ assert_eq!(buf[(top_right.x, top_right.y)].symbol(), "┌", "the right box's own corner:\n{s}");
let (status_bg, attention) = (theme::paint(app.status_style().bg.unwrap_or(Color::Reset)), theme::paint(theme::ATTENTION));
+ // Each box keeps its own colour on its own (unshared) lines.
assert_eq!(buf[(left.right() - 1, mid)].fg, status_bg, "the focused pane's frame");
- assert_eq!(buf[(top_right.x, top_right.y + 1)].fg, attention, "the waiting pane's frame");
- assert_ne!(buf[(below.x, below.y + 1)].fg, status_bg, "a quiet frame");
- assert_ne!(buf[(below.x, below.y + 1)].fg, attention, "a quiet frame");
+ assert_eq!(buf[(top_right.right() - 1, top_right.y + top_right.height / 2)].fg, attention, "the waiting pane's frame");
+ assert_ne!(buf[(below.right() - 1, below.y + below.height / 2)].fg, status_bg, "a quiet frame");
+ assert_ne!(buf[(below.right() - 1, below.y + below.height / 2)].fg, attention, "a quiet frame");
// The program is inside its frame.
assert_eq!(app.content_of(app.tab(), app.rects.iter().find(|(p, _)| *p == 1).unwrap().1), Rect::new(left.x + 1, left.y + 1, left.width - 2, left.height - 2));
}
+ /// The status bar is the same whichever focus style: blurred panes do not recolour it.
+ #[test]
+ fn the_status_bar_keeps_its_colours_when_panes_are_blurred() {
+ let _colours = crate::term_out::colours_lock();
+ let mut app = app((120, 36), "bottom");
+ let global = crate::options::SetFlags { global: true, ..Default::default() };
+ let mut styles = Vec::new();
+ for focus in ["line", "surface"] {
+ let _ = app.options.set("@hn-focus", Some(focus), &global, "", 0);
+ styles.push((app.status_style(), app.style_of("window-status-current-style", app.active, None)));
+ }
+ assert_eq!(styles[0], styles[1]);
+ }
+
/// Two boxes next to each other touch (`││`); two blurred surfaces have one cell between
- /// them — across and down, pane titles off and on top, the status line at the bottom or the
- /// bar at a side: never each pane's space added to the other's. At the window's edges and the
- /// status line a pane has none (beside the bar, its blank edge is the one cell).
+ /// them across, and down too — unless a pane title fills that row, then the surfaces meet as
+ /// the boxes do (the title is the divider). Pane titles off and on top, the status line at the
+ /// bottom or the bar at a side: never each pane's space added to the other's. At the window's
+ /// edges and the status line a pane has none (beside the bar, its blank edge is the one cell).
#[test]
fn panes_side_by_side_touch_or_are_a_cell_apart_and_meet_the_edges() {
for focus in ["line", "surface"] { for (side, titles) in [("bottom", "off"), ("bottom", "top"), ("left", "off"), ("left", "top"), ("right", "top")] {
@@ -872,17 +890,19 @@ mod tests {
let r = app.rects.iter().find(|(p, _)| p == id).unwrap().1;
if boxes { crate::pane_frame::boxed_in(r, canvas, inner, status).surface } else { crate::pane_frame::frame(r, canvas, inner, status).surface }
}).collect();
- let gap = if boxes { 0 } else { 1 };
+ // Boxes and blurred surfaces alike touch both ways (0), as the bottom ones touch the
+ // status line.
+ let (gap_across, gap_down): (i32, i32) = (0, 0);
let at = format!("{focus}, {side}, titles {titles}:\n{s}");
// Across: the left edge (the bar's blank column when it is on the left), between, the right edge.
assert_eq!(f[0].x, canvas.x, "left edge {at}");
if side == "left" { assert_eq!(canvas.x, app.bar_width(), "the bar's blank edge is the gap {at}"); }
- assert_eq!(f[1].x - f[0].right(), gap, "between, across {at}");
+ assert_eq!(f[1].x as i32 - f[0].right() as i32, gap_across, "between, across {at}");
assert_eq!(f[1].right(), canvas.right(), "right edge {at}");
if side == "right" { assert_eq!(app.size.0 - app.bar_width(), canvas.right(), "the bar's blank edge is the gap {at}"); }
// Down: the top edge, between the two stacked panes, the bottom edge (the status line).
assert_eq!(f[0].y, canvas.y, "top edge {at}");
- assert_eq!(f[2].y - f[1].bottom(), gap, "between, down {at}");
+ assert_eq!(f[2].y as i32 - f[1].bottom() as i32, gap_down, "between, down {at}");
assert_eq!((f[0].bottom(), f[2].bottom()), (canvas.bottom(), canvas.bottom()), "bottom edge {at}");
} }
}
diff --git a/tui/src/config.rs b/tui/src/config.rs
index 224a01f27..b57eea650 100644
--- a/tui/src/config.rs
+++ b/tui/src/config.rs
@@ -142,6 +142,12 @@ pub struct Look {
pub status_bar_width: Option<String>,
/// `on`: the panes you are not in, a little quieter (`off` unless chosen).
pub dim: Option<String>,
+ /// How the current tab (the window) is marked in the status bar: `star` (default: `*` beside
+ /// its name) | `filled` (the tab is inverted — filled — with no `*`).
+ pub window_active: Option<String>,
+ /// How a tab's name is shown in the status bar: `tmux` (default: the window's short name) |
+ /// `pane` (the window's full name).
+ pub window_name: Option<String>,
}
pub struct Config {
@@ -209,6 +215,16 @@ impl Look {
if let Some(b) = &self.border_style { out.push(("@hn-border".into(), b.clone())) }
if let Some(w) = &self.status_bar_width { out.push(("@hn-status-bar-width".into(), w.clone())) }
if let Some(d) = &self.dim { out.push(("@hn-dim".into(), d.clone())) }
+ // ── status bar tabs ──
+ // Two options shape the window list in the status bar: how the current tab is marked and
+ // how a tab's name is shown. `@hn-window-active`/`@hn-window-name` carry the choice for the
+ // Appearance list; the format/style overrides below are what actually draws it.
+ if let Some(a) = &self.window_active { out.push(("@hn-window-active".into(), a.clone())) }
+ if let Some(n) = &self.window_name { out.push(("@hn-window-name".into(), n.clone())) }
+ // The window-status-* overrides these two options need (empty for the tmux + star defaults).
+ let name = self.window_name.as_deref().unwrap_or("tmux");
+ let active = self.window_active.as_deref().unwrap_or("star");
+ for (o, v) in crate::options::window_status_overrides(name, active) { out.push((o, v)) }
out
}
}
@@ -378,6 +394,8 @@ fn look_of(look: &toml::Table, problems: &mut Vec<String>) -> Look {
field(look, "border_style", &mut l.border_style);
field(look, "status_bar_width", &mut l.status_bar_width);
field(look, "dim", &mut l.dim);
+ field(look, "window_active", &mut l.window_active);
+ field(look, "window_name", &mut l.window_name);
// (An older file's `tabs` is left alone: the tabs over the panes are gone, the bar lists the windows.)
l
}
@@ -414,6 +432,8 @@ fn format_look(look: &Look) -> String {
push(&look.border_style, "border_style", &mut s);
push(&look.status_bar_width, "status_bar_width", &mut s);
push(&look.dim, "dim", &mut s);
+ push(&look.window_active, "window_active", &mut s);
+ push(&look.window_name, "window_name", &mut s);
s
}
@@ -563,6 +583,46 @@ mod tests {
assert_eq!(get(&top, "status-position").as_deref(), Some("top"));
}
+ #[test]
+ fn window_status_options_emit_format_and_style_overrides() {
+ let get = |a: &[(String, String)], n: &str| a.iter().find(|(k, _)| k == n).map(|(_, v)| v.clone());
+ // The defaults (tmux + star) put just the two @hn markers; no format/style overrides, so
+ // the tmux defaults draw the bar.
+ let star = Look { window_active: Some("star".into()), window_name: Some("tmux".into()), ..Default::default() }.assignments();
+ assert_eq!(get(&star, "@hn-window-active").as_deref(), Some("star"));
+ assert_eq!(get(&star, "@hn-window-name").as_deref(), Some("tmux"));
+ assert!(get(&star, "window-status-format").is_none(), "default keeps tmux's format");
+ assert!(get(&star, "window-status-current-format").is_none());
+ assert!(get(&star, "window-status-current-style").is_none());
+ // `pane` names the window with its active pane's title; `filled` drops the `*` and the tab
+ // takes the status line's own colours swapped (a solid block, as the preview draws it).
+ let filled = Look { window_active: Some("filled".into()), window_name: Some("pane".into()), ..Default::default() }.assignments();
+ let normal = get(&filled, "window-status-format").unwrap();
+ let current = get(&filled, "window-status-current-format").unwrap();
+ assert!(normal.contains("#{pane_title}"), "pane uses the active pane's title: {normal}");
+ assert!(current.contains("#{pane_title}"));
+ assert!(!current.contains("#{window_active,*"), "filled leaves no `*`: {current}");
+ let style = get(&filled, "window-status-current-style").unwrap();
+ assert!(style.contains("bold"), "{style}");
+ // The filled tab swaps the status line's colours: its background the theme foreground's,
+ // its lettering the theme's background.
+ let (bg, fg, _) = crate::theme::palette();
+ let fg = crate::tmuxconf::colour_name(fg);
+ let bg = crate::tmuxconf::colour_name(bg);
+ assert!(style.contains(&format!("fg={fg}")) && style.contains(&format!("bg={bg}")), "{style}");
+ }
+
+ #[test]
+ fn window_status_options_round_trip_through_tui_toml() {
+ let look = Look { window_active: Some("filled".into()), window_name: Some("pane".into()), ..Default::default() };
+ let text = format_look(&look);
+ assert!(text.contains("window_active = \"filled\"") && text.contains("window_name = \"pane\""), "{text}");
+ let value: toml::Value = text.parse().unwrap();
+ let mut problems = Vec::new();
+ assert_eq!(look_of(value.get("look").and_then(|v| v.as_table()).unwrap(), &mut problems), look);
+ assert!(problems.is_empty());
+ }
+
// ── keys ──
/// The prefix goes into tui.toml as the panel sets it: the top's `prefix` replaced (or added,
diff --git a/tui/src/format.rs b/tui/src/format.rs
index 390ce30dd..3458cb035 100644
--- a/tui/src/format.rs
+++ b/tui/src/format.rs
@@ -1818,6 +1818,23 @@ mod tests {
assert_eq!(super::expand(&app, "#{window_name}/#{window_active}/#{pane_id}", 1, Some(2), false), "Project 1/1/%1");
}
+ /// What the status line renders when the current window is `filled` and the tab name is `pane`.
+ #[test]
+ fn window_status_overrides_reach_the_status_line() {
+ let mut app = status_fixture(2, 2);
+ let global = crate::options::SetFlags { global: true, ..Default::default() };
+ let overrides = crate::options::window_status_overrides("pane", "filled");
+ for (o, v) in &overrides { let _ = app.options.set(o, Some(v), &global, "", 0); }
+ let fmt = app.options.get("status-format[0]", &app.tabs[0].id, None).unwrap();
+ let out = super::expand(&app, &fmt, 0, Some(1), true);
+ // The current window is marked filled: no `*`, its cell takes the swapped status-line
+ // colours (the theme's background on the theme's foreground), and in `pane` mode it is
+ // named for its active pane — not the window's auto-renamed name.
+ assert!(!out.contains('*'), "no star marker: {out}");
+ assert!(out.contains("list=focus") && out.contains("bg="), "the current window is filled: {out}");
+ assert!(out.contains("Review project 0") && !out.contains("0:Project 0"), "the pane's title, not the window's: {out}");
+ }
+
#[test]
fn loop_alternatives_keep_nested_commas_and_only_expand_the_selected_branch() {
let mut app = status_fixture(2, 2);
diff --git a/tui/src/modal.rs b/tui/src/modal.rs
index b774a96da..cdf3a013c 100644
--- a/tui/src/modal.rs
+++ b/tui/src/modal.rs
@@ -685,6 +685,9 @@ pub fn theme_sections(app: &App) -> Vec<Row> {
// ── status bar ──
sec("section:bar", "Status bar", "status_bar", status_bar_of(app)),
sec("section:boxes", "Borders", "every pane its own box", if border_style_of(app) == "box" { "on" } else { "off" }),
+ // ── status bar tabs ──
+ sec("section:tab", "Tab", "how the current tab is marked", tab_active_of(app)),
+ sec("section:tabname", "Tab name", "how a tab's name is shown", tab_name_of(app)),
// (Keys are Keybinds', a panel of their own in Commands.)
]
}
@@ -697,6 +700,12 @@ fn status_bar_of(app: &App) -> &'static str { match app.options.status_bar() { "
/// How panes are set apart: `box` unless `@hn-border line`.
fn border_style_of(app: &App) -> &'static str { app.options.border_style() }
+/// How the current tab is marked: `star` (default) | `filled` (`@hn-window-active`).
+fn tab_active_of(app: &App) -> &'static str { if app.options.get("@hn-window-active", "", None).as_deref() == Some("filled") { "filled" } else { "star" } }
+
+/// A tab's name source: `tmux` (default) | `pane` (`@hn-window-name`).
+fn tab_name_of(app: &App) -> &'static str { if app.options.get("@hn-window-name", "", None).as_deref() == Some("pane") { "pane" } else { "tmux" } }
+
/// The look/theme picker, level two: the options of one section. Enter on one applies it (and the
/// ▼ moves to it); Left/Esc returns to the section list.
pub fn theme_options(app: &App, section: &str) -> Vec<Row> {
@@ -738,6 +747,12 @@ pub fn theme_options(app: &App, section: &str) -> Vec<Row> {
"boxes" => { let cur = border_style_of(app);
[("box", "on", "every pane its own box"), ("line", "off", "tmux's lines between panes")]
.iter().map(|(v, label, hint)| opt(format!("border_style:{v}"), label, cur == *v, hint)).collect() }
+ "tab" => { let cur = tab_active_of(app);
+ [("star", "star", "the current tab is marked *"), ("filled", "filled", "the current tab is filled (inverted)")]
+ .iter().map(|(v, label, hint)| opt(format!("window_active:{v}"), label, cur == *v, hint)).collect() }
+ "tabname" => { let cur = tab_name_of(app);
+ [("tmux", "tmux", "the window's short name"), ("pane", "pane", "the window's full name")]
+ .iter().map(|(v, label, hint)| opt(format!("window_name:{v}"), label, cur == *v, hint)).collect() }
_ => vec![],
}
}
@@ -827,7 +842,7 @@ mod theme_row_tests {
let ids: Vec<&str> = rows.iter().map(|r| r.id.as_str()).collect();
assert_eq!(ids, vec!["section:theme", "section:status", "section:focus",
// ── status bar ──
- "section:bar", "section:boxes"]);
+ "section:bar", "section:boxes", "section:tab", "section:tabname"]);
// Each section shows its current value and opens onto a non-empty option list.
assert!(rows.iter().all(|r| !r.right.is_empty()), "each section shows a value");
for r in &rows {
@@ -872,6 +887,28 @@ mod theme_row_tests {
assert!(theme_options(&app, "split").is_empty());
}
+ #[test]
+ fn the_tab_and_tab_name_sections_list_their_choices() {
+ let a0 = app();
+ let tab_rows = theme_options(&a0, "tab");
+ let tab_ids: Vec<&str> = tab_rows.iter().map(|r| r.id.as_str()).collect();
+ assert_eq!(tab_ids, vec!["window_active:star", "window_active:filled"]);
+ let name_rows = theme_options(&a0, "tabname");
+ let name_ids: Vec<&str> = name_rows.iter().map(|r| r.id.as_str()).collect();
+ assert_eq!(name_ids, vec!["window_name:tmux", "window_name:pane"]);
+ // The mark follows the option in use.
+ let mut a1 = app();
+ let global = crate::options::SetFlags { global: true, ..Default::default() };
+ let _ = a1.options.set("@hn-window-active", Some("filled"), &global, "", 0);
+ let filled = theme_options(&a1, "tab");
+ let idx = filled.iter().position(|r| r.id == "window_active:filled").unwrap();
+ assert!(filled[idx].lead.iter().any(|s| s.content.as_ref() == "✓ "));
+ let _ = a1.options.set("@hn-window-name", Some("pane"), &global, "", 0);
+ let pane = theme_options(&a1, "tabname");
+ let idx = pane.iter().position(|r| r.id == "window_name:pane").unwrap();
+ assert!(pane[idx].lead.iter().any(|s| s.content.as_ref() == "✓ "));
+ }
+
// ── keys ──
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
diff --git a/tui/src/new_harness.rs b/tui/src/new_harness.rs
index ebd2085c7..2064f226e 100644
--- a/tui/src/new_harness.rs
+++ b/tui/src/new_harness.rs
@@ -219,10 +219,11 @@ impl Form {
}
fn hint(&self) -> String {
let page = matches!(self.surface, Surface::Window(_));
- if self.starting { return if page { "Launch continues if you change windows" } else { "Esc close · launch continues" }.into() }
- if self.attempt.is_some() { return if page { "Enter check status" } else { "Enter check status · Esc close" }.into() }
+ // The key hints read as every panel's do: `↑↓ move enter run esc back`.
+ if self.starting { return if page { "Launch continues if you change windows" } else { "esc close launch continues" }.into() }
+ if self.attempt.is_some() { return if page { "enter check status" } else { "enter check status esc close" }.into() }
if self.focus == Field::Task {
- return "Enter start · Tab fields · Alt-Enter newline".into();
+ return if page { "tab move enter start esc close" } else { "tab move enter start alt-enter newline esc close" }.into();
}
if self.focus == Field::Project {
if let Project::Folder(path) = &self.draft.project {
@@ -230,11 +231,11 @@ impl Form {
}
}
if self.focus == Field::Create {
- if page { "Enter start · Tab fields" } else { "↑/↓ fields · Enter start · Esc close" }.into()
+ if page { "tab move enter start esc close" } else { "↑↓ move enter start esc close" }.into()
} else if page && matches!(self.focus, Field::Terminal | Field::Recent(_) | Field::Browse) {
- "Enter open · Tab fields · Esc task".into()
+ "tab move enter open esc close window".into()
} else {
- "↑/↓ fields · Enter choose · Esc back".into()
+ "↑↓ move enter choose esc back".into()
}
}
fn describe(&self, field: Field) -> (String, String) {
@@ -787,6 +788,18 @@ fn dismiss(app: &mut App, mut form: Box<Form>) {
} else { form.surface = Surface::Dismissed; }
store_form(app, form);
}
+
+/// Esc on the empty home window's form: keep the draft and close the window, returning to the
+/// one the new-window came from. A mid-launch form (starting / attempting) is never closed here —
+/// dismiss() keeps its window so the launch can continue when looked at again.
+fn close_home_window(app: &mut App, mut form: Box<Form>) {
+ form.surface = Surface::Dismissed;
+ form.child = None;
+ form.child_active = false;
+ form.trail.clear();
+ store_form(app, form);
+ app.close_tab(app.active);
+}
fn take_active(app: &mut App) -> Option<Box<Form>> {
if matches!(app.modal, Some(Modal::NewHarness(_))) {
let Some(Modal::NewHarness(form)) = app.modal.take() else { unreachable!() };
@@ -1331,6 +1344,10 @@ pub fn key(app: &mut App, mut form: Box<Form>, key: KeyEvent) {
if key.code == KeyCode::Esc || (ctrl && matches!(key.code, KeyCode::Char('c' | 'g'))) {
if back(app, &mut form) {
store_form(app, form);
+ } else if matches!(form.surface, Surface::Window(_)) && !form.starting && form.attempt.is_none() && app.tabs.len() > 1 {
+ // The empty home window's form is not a modal you cancel with focus, it is the window
+ // itself: Esc closes the window and returns to the one it came from (tmux's last-window).
+ close_home_window(app, form);
} else {
dismiss(app, form);
}
@@ -1359,8 +1376,8 @@ pub fn key(app: &mut App, mut form: Box<Form>, key: KeyEvent) {
let mut launch = false;
if !form.child_active && form.focus == Field::Task {
match key.code {
- KeyCode::Tab | KeyCode::BackTab => {
- form.move_by(if key.code == KeyCode::BackTab { -1 } else { 1 });
+ KeyCode::Up | KeyCode::Down | KeyCode::Tab | KeyCode::BackTab => {
+ form.move_by(match key.code { KeyCode::Up | KeyCode::BackTab => -1, _ => 1 });
reveal(app, &mut form);
}
KeyCode::Enter if !key.modifiers.intersects(KeyModifiers::ALT | KeyModifiers::SHIFT) => launch = true,
@@ -1971,6 +1988,61 @@ mod tests {
}
}
+ /// Up/Down move between the fields from the Task field (where the crop of the form lands),
+ /// so a user is not stuck using Tab alone — the task editor keeps Ctrl-P/Ctrl-N for its own
+ /// vertical cursor.
+ #[tokio::test]
+ async fn arrows_move_between_fields_from_the_task_field() {
+ let mut app = app();
+ open(&mut app, None, Some("/home/dev/project".into()));
+ let Some(Modal::NewHarness(form)) = app.modal.take() else { panic!() };
+ assert_eq!(form.focus, Field::Task);
+ // Down leaves the Task field for the next one.
+ key(&mut app, form, KeyEvent::new(KeyCode::Down, KeyModifiers::NONE));
+ let Some(Modal::NewHarness(form)) = &app.modal else { panic!() };
+ assert_eq!(form.focus, Field::Agent);
+ // Up brings it back.
+ let Some(Modal::NewHarness(form)) = app.modal.take() else { panic!() };
+ key(&mut app, form, KeyEvent::new(KeyCode::Up, KeyModifiers::NONE));
+ let Some(Modal::NewHarness(form)) = &app.modal else { panic!() };
+ assert_eq!(form.focus, Field::Task);
+ }
+
+ #[tokio::test]
+ async fn esc_closes_an_empty_home_window_form_and_returns_to_its_last_window() {
+ let mut app = app();
+ // A window new-window came from, then the empty home window it made.
+ let from = app.tab().id.clone();
+ app.new_tab();
+ app.tab_mut().home = true;
+ ensure_welcome(&mut app, None, Some("/home/dev/project".into()));
+ let home = app.tab().id.clone();
+ assert!(app.home_visible(), "the home window shows the form");
+ assert!(app.welcome.forms.contains_key(&home));
+ let Some(form) = app.welcome.forms.remove(&home) else { panic!() };
+ key(&mut app, form, KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
+ // The draft is kept for when `new` reopens it; the empty window is gone.
+ assert!(app.new_harness_draft.is_some(), "the draft survives closing the window");
+ assert!(!app.tabs.iter().any(|t| t.id == home), "the empty home window is closed");
+ assert_eq!(app.tabs.len(), 1);
+ assert_eq!(app.tab().id, from, "returns to the window it came from");
+ }
+
+ #[tokio::test]
+ async fn esc_keeps_the_only_home_window_open() {
+ let mut app = app();
+ app.tab_mut().home = true;
+ ensure_welcome(&mut app, None, Some("/home/dev/project".into()));
+ let home = app.tab().id.clone();
+ assert_eq!(app.tabs.len(), 1);
+ let Some(form) = app.welcome.forms.remove(&home) else { panic!() };
+ key(&mut app, form, KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
+ // The only window cannot close: the form stays and focus goes to the task.
+ assert!(app.welcome.forms.contains_key(&home));
+ assert!(app.new_harness_draft.is_none());
+ assert_eq!(app.welcome.forms[&home].focus, Field::Task);
+ }
+
#[tokio::test]
async fn draft_survives_picker_escape_and_late_refresh() {
let mut app = app();
diff --git a/tui/src/options/mod.rs b/tui/src/options/mod.rs
index 0de30d410..2a8e4b5ab 100644
--- a/tui/src/options/mod.rs
+++ b/tui/src/options/mod.rs
@@ -111,7 +111,7 @@ pub fn defaults() -> &'static BTreeMap<String, String> {
// Keep tmux's familiar current/previous markers beside the name, then any other
// flags, then the harness state. The selected tab needs no filled badge.
for name in ["window-status-format", "window-status-current-format"] {
- m.insert(name.into(), "#I:#{window_short_name}#{?window_active,*,#{?window_last_flag,-,}}#{s/[*-]//:window_flags}#{?#{==:#{window_agent_state},idle},,#{?window_agent_icon, #{window_agent_icon},}}".into());
+ m.insert(name.into(), status_window_format("tmux", true));
}
// Unread activity and bells already carry #/! markers. Keep a continuous status
// background and emphasize text instead of introducing inverted tab badges.
@@ -142,6 +142,38 @@ pub fn defaults() -> &'static BTreeMap<String, String> {
})
}
+/// The status bar's per-window text. [name] is the tab name source (`tmux` = the window's short
+/// name, `pane` = the window's full name); [star] is whether the window you are on is marked `*`
+/// (`false` for a filled tab, which needs no `*` beside its name).
+pub fn status_window_format(name: &str, star: bool) -> String {
+ // `tmux` keeps hn's window name, `pane` the active pane's own title (a harness's task, not the
+ // window's auto-renamed name) — the two can differ, which is the point of the option.
+ let name_part = if name == "pane" { "#{pane_title}" } else { "#{window_short_name}" };
+ let mark = if star { "#{?window_active,*,#{?window_last_flag,-,}}" } else { "#{?window_last_flag,-,}" };
+ format!("#I:{name_part}{mark}#{{s/[*-]//:window_flags}}#{{?#{{==:#{{window_agent_state}},idle}},,#{{?window_agent_icon, #{{window_agent_icon}},}}")
+}
+
+/// The status bar's `window-status-*` overrides for a tab name source [name] (`tmux`|`pane`) and a
+/// current-tab [active] (`star`|`filled`). Empty when they match the defaults (tmux + star), so a
+/// caller can leave the tmux defaults in place. Shared by boot (from `[look]`) and a live pick.
+pub fn window_status_overrides(name: &str, active: &str) -> Vec<(String, String)> {
+ let default_win = status_window_format("tmux", true);
+ let mut out = Vec::new();
+ let normal = status_window_format(name, true);
+ let current = status_window_format(name, active == "star");
+ if normal != default_win { out.push(("window-status-format".into(), normal)) }
+ if current != default_win { out.push(("window-status-current-format".into(), current)) }
+ if active == "filled" {
+ // The current tab filled: the status line's own colours swapped — its background becomes a
+ // solid block (the theme's background) with the theme's foreground as the lettering — so it
+ // reads exactly like the Appearance preview, not tmux's stock green.
+ let (bg, fg, _) = crate::theme::palette();
+ let pair = |fg, bg| format!("fg={},bg={}", crate::tmuxconf::colour_name(fg), crate::tmuxconf::colour_name(bg));
+ out.push(("window-status-current-style".into(), format!("{},bold", pair(fg, bg))));
+ }
+ out
+}
+
/// tmux 3.5a's own defaults, as `tmux show -g` prints them (mode-keys and status-keys following
/// $VISUAL or $EDITOR in hn's).
pub fn tmux_defaults() -> &'static BTreeMap<String, String> {
@@ -157,7 +189,8 @@ pub fn tmux_defaults() -> &'static BTreeMap<String, String> {
})
}
-/// Explicit user styles win; default surfaces follow the terminal's current theme.
+/// Explicit user styles win; default surfaces follow the terminal's current theme. Only the
+/// panes' own colours: the status bar is the same whichever focus style (blurred or border).
fn pane_default(name: &str) -> Option<String> {
let p = crate::theme::pane_palette();
let pair = |fg, bg| format!("fg={},bg={}", crate::tmuxconf::colour_name(fg), crate::tmuxconf::colour_name(bg));
@@ -166,14 +199,11 @@ fn pane_default(name: &str) -> Option<String> {
"window-active-style" => pair(p.foreground, p.surface),
"pane-border-style" => pair(p.border, p.inactive_surface),
"pane-active-border-style" => pair(p.active_border, p.surface),
- "status-style" | "window-status-style" => pair(p.status_foreground, p.status),
- "window-status-current-style" => format!("{},bold", pair(p.status_foreground, p.status)),
- "window-status-separator" => " ".into(),
_ => return None,
})
}
-const PANE_LOOK: [&str; 8] = ["window-style", "window-active-style", "pane-border-style", "pane-active-border-style", "status-style", "window-status-current-style", "window-status-style", "window-status-separator"];
+const PANE_LOOK: [&str; 4] = ["window-style", "window-active-style", "pane-border-style", "pane-active-border-style"];
/// hn's look, where its defaults differ from tmux's: what `set -g @hn-look tmux` puts back.
pub const LOOK: [&str; 14] = ["pane-border-status", "pane-border-format", "status-left", "status-right", "status-left-length", "status-right-length", "window-status-format", "window-status-current-format", "set-titles", "set-titles-string", "allow-set-title", "window-status-activity-style", "window-status-bell-style", "status-format[1]"];
@@ -682,7 +712,8 @@ mod tests {
s.set("@hn-look", Some(look), &g, "", 0).unwrap();
assert_eq!(s.pane_look(), look == "panes");
assert_eq!(s.get("window-style", "", None).as_deref(), Some("bg=blue"));
- if look != "panes" { assert_eq!(s.get("status-style", "", None), defaults().get("status-style").cloned()); }
+ // The status bar is the same whichever focus style — blurred panes do not recolour it.
+ if look != "tmux" { for n in ["status-style", "window-status-style", "window-status-current-style", "window-status-separator"] { assert_eq!(s.get(n, "", None), defaults().get(n).cloned(), "{look}: {n}"); } }
}
s.set("window-style", None, &SetFlags { unset: true, ..gw }, "", 0).unwrap();
assert!(s.get("window-style", "", None).unwrap().starts_with("fg=#"));
diff --git a/tui/src/pane_frame.rs b/tui/src/pane_frame.rs
index df8a6e1d5..4ebe4bc6c 100644
--- a/tui/src/pane_frame.rs
+++ b/tui/src/pane_frame.rs
@@ -8,40 +8,36 @@ use crate::layout::Status;
pub struct Frame { pub surface: Rect, pub content: Rect, pub title: Option<Rect> }
/// A pane as a blurred surface: the surface filled, its edge cell padding, the title in its top
-/// (or bottom) row. The cell tmux keeps between panes — its divider, or a lower pane's title row
-/// — is left empty, so two surfaces of one colour never run together: one cell between them, never
-/// each pane's own padding added to its neighbour's.
-pub fn frame(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame { cells(tile, canvas, inner, status, false) }
+/// (or bottom) row. The same cells as a box ([boxed]): a pane takes the cell tmux keeps between
+/// panes as its edge — a box draws its line there, a blurred surface lets that edge cell be the
+/// gap — so two panes, side by side or stacked, sit flush with no blank cell between them.
+pub fn frame(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame { cells(tile, canvas, inner, status) }
// ── box panes ──
/// A pane as a box (`@hn-border box`): its own single-line frame on the pane's outer cells
-/// (`surface`), the program inside it. Boxes side by side, or stacked, touch — `││`, never a
-/// blank between — each with a frame of its own (never two panes on one line): a box takes the
-/// cell tmux keeps after it (its divider) for its right or bottom line, and a lower pane's title
-/// row is its frame's top line. The title goes into the frame's top (or bottom) line (`title`).
+/// (`surface`), the program inside it. A box draws its right or bottom line on the cell tmux
+/// keeps between panes (its divider), so boxes side by side, or stacked, touch (`││`) with no
+/// blank cell between — as the bottom boxes touch the status line — each with a frame of its own,
+/// never two boxes on one line. The title goes into the frame's top (or bottom) line (`title`).
/// The layout's cells stay tmux's, so splits, resizes and layouts are unchanged.
#[cfg(test)]
pub fn boxed(tile: Rect, canvas: Rect, status: Status) -> Frame { boxed_in(tile, canvas, canvas, status) }
/// [boxed], every frame kept inside [inner] (`App::box_inner`: the window).
-pub fn boxed_in(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame { cells(tile, canvas, inner, status, true) }
+pub fn boxed_in(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame { cells(tile, canvas, inner, status) }
-/// A pane's surface, content and title: [touch] for boxes (the divider after a pane is its
-/// line), else a surface a cell apart from the next.
-fn cells(tile: Rect, canvas: Rect, inner: Rect, status: Status, touch: bool) -> Frame {
+/// A pane's surface, content and title, a box's or a blurred surface's alike: the divider after
+/// a pane is its edge (a box's line, a blurred surface's padding), so the two touch.
+fn cells(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame {
let mut outer = tile;
- if touch {
- // The divider column after a pane, and (titles off) the divider row below it.
- if tile.right() < canvas.right() { outer.width += 1 }
- if status == Status::Off && tile.bottom() < canvas.bottom() { outer.height += 1 }
- } else {
- match status {
- Status::Top if tile.y != canvas.y => { outer.y += 1; outer.height = outer.height.saturating_sub(1) }
- Status::Bottom if tile.bottom() != canvas.bottom() => outer.height = outer.height.saturating_sub(1),
- _ => {}
- }
- }
+ // A pane takes the divider column after it, so two side by side sit flush, never a blank
+ // column between.
+ if tile.right() < canvas.right() { outer.width += 1 }
+ // And the divider row after it, stacked, so the two touch as they do side by side. (With a
+ // title that row is already in a tile — the lower pane's title row, its top edge, or the
+ // upper pane's, its bottom edge.)
+ if status == Status::Off && tile.bottom() < canvas.bottom() { outer.height += 1 }
outer = outer.intersection(inner);
// Too small for a frame with something in it: the program has every cell.
if outer.width < 3 || outer.height < 3 || tile.width < 3 || tile.height < 3 { let cells = if outer.height == 0 { tile } else { outer.intersection(tile) }; return Frame { surface: cells, content: cells, title: None } }
@@ -55,12 +51,14 @@ mod tests {
use super::*;
#[test]
- fn blurred_surfaces_are_a_cell_apart() {
+ fn blurred_surfaces_touch_and_the_gap_is_each_edge_cell() {
let canvas = Rect::new(0, 0, 120, 40);
for status in [Status::Off, Status::Top, Status::Bottom] {
let (left, right) = (frame(Rect::new(0, 0, 59, 40), canvas, canvas, status), frame(Rect::new(60, 0, 60, 40), canvas, canvas, status));
- assert_eq!(right.surface.x - left.surface.right(), 1, "{status:?}: one cell between two surfaces");
- assert_eq!(right.content.x - left.content.right(), 3, "{status:?}: each surface's edge cell, then the gap");
+ assert_eq!(right.surface.x, left.surface.right(), "{status:?}: the surfaces touch, no blank column between");
+ // Each surface's edge cell is the gap (= box panes' `border`), so the contents are two
+ // cells apart, never three.
+ assert_eq!(right.content.x - left.content.right(), 2, "{status:?}: each surface's edge cell is the gap");
}
}
@@ -79,16 +77,19 @@ mod tests {
let mut tiles = Vec::new();
n.rects(canvas, &mut tiles);
let boxes: Vec<Frame> = tiles.iter().map(|(_, t)| boxed(*t, canvas, status)).collect();
- for (i, b) in boxes.iter().enumerate() {
+ for b in boxes.iter() {
assert_eq!(b.surface.intersection(canvas), b.surface, "{status:?}: inside the window");
assert_eq!(b.content, Rect::new(b.surface.x + 1, b.surface.y + 1, b.surface.width - 2, b.surface.height - 2));
match status { Status::Off => assert!(b.title.is_none()), Status::Top => assert_eq!(b.title.unwrap().y, b.surface.y), Status::Bottom => assert_eq!(b.title.unwrap().y, b.surface.bottom() - 1) }
- for other in &boxes[i + 1..] { assert_eq!(b.surface.intersection(other.surface).area(), 0, "{status:?}: frames never share a cell") }
}
- // Side by side and stacked, the frames touch; the window's edges are the outer
- // frames' edges.
- assert_eq!(boxes[1].surface.x, boxes[0].surface.right(), "{status:?}");
- assert_eq!(boxes[2].surface.y, boxes[1].surface.bottom(), "{status:?}");
+ // Each frame its own (never two boxes on one line), touching both ways — no blank cell
+ // between, as the bottom boxes touch the status line.
+ assert_eq!(boxes[1].surface.x, boxes[0].surface.right(), "{status:?}: side by side touch");
+ assert_eq!(boxes[2].surface.y, boxes[1].surface.bottom(), "{status:?}: stacked touch");
+ assert_eq!(boxes[1].content.x - boxes[0].content.right(), 2, "{status:?}: side-by-side contents");
+ assert_eq!(boxes[2].content.y - boxes[1].content.bottom(), 2, "{status:?}: stacked contents");
+ for (i, b) in boxes.iter().enumerate() { for other in &boxes[i + 1..] { assert_eq!(b.surface.intersection(other.surface).area(), 0, "{status:?}: frames never share a cell") } }
+ // The window's edges are the outer frames' edges.
assert_eq!((boxes[0].surface.x, boxes[0].surface.y, boxes[0].surface.bottom()), (canvas.x, canvas.y, canvas.bottom()));
assert_eq!((boxes[1].surface.right(), boxes[2].surface.bottom()), (canvas.right(), canvas.bottom()));
}
@@ -96,4 +97,43 @@ mod tests {
let tiny = boxed(Rect::new(30, 5, 2, 5), canvas, Status::Off);
assert_eq!(tiny.content, Rect::new(30, 5, 2, 5));
}
+
+ #[test]
+ fn side_by_side_surfaces_touch_and_the_gap_is_two_edge_cells() {
+ use crate::layout::{Dir, Node};
+ let canvas = Rect::new(0, 0, 120, 40);
+ for status in [Status::Off, Status::Top, Status::Bottom] {
+ let mut n = Node::new(1, canvas.width, canvas.height);
+ n.status = status;
+ n.split(1, 2, Dir::Horizontal);
+ let mut tiles = Vec::new();
+ n.rects(canvas, &mut tiles);
+ let f: Vec<Frame> = tiles.iter().map(|(_, t)| frame(*t, canvas, canvas, status)).collect();
+ assert_eq!(f[1].surface.x, f[0].surface.right(), "{status:?}: side-by-side surfaces touch");
+ // Each surface's edge cell is the gap (as a box's border is), so their contents are
+ // two cells apart — the same as two stacked panes with a title.
+ assert_eq!(f[1].content.x - f[0].content.right(), 2, "{status:?}: contents two cells apart");
+ }
+ }
+
+ #[test]
+ fn stacked_surfaces_have_no_blank_row_between_them() {
+ use crate::layout::{Dir, Node};
+ let canvas = Rect::new(0, 0, 100, 40);
+ for status in [Status::Off, Status::Top, Status::Bottom] {
+ let mut n = Node::new(1, canvas.width, canvas.height);
+ n.status = status;
+ n.split(1, 2, Dir::Vertical);
+ let mut tiles = Vec::new();
+ n.rects(canvas, &mut tiles);
+ let fs: Vec<Frame> = tiles.iter().map(|(_, t)| frame(*t, canvas, canvas, status)).collect();
+ // A stacked pane is flush against the one above, titles or not — the same as boxes,
+ // its contents two rows from the upper one's, as side by side they are two columns.
+ assert_eq!(fs[1].surface.y, fs[0].surface.bottom(), "{status:?}: stacked surfaces touch");
+ assert_eq!(fs[1].content.y - fs[0].content.bottom(), 2, "{status:?}: contents two rows apart");
+ assert_eq!((fs[0].surface, fs[1].surface), (boxed(tiles[0].1, canvas, status).surface, boxed(tiles[1].1, canvas, status).surface), "{status:?}: a box's cells");
+ if status == Status::Top { assert_eq!(fs[1].title.unwrap().y, fs[1].surface.y, "{status:?}: lower title on the boundary") }
+ if status == Status::Bottom { assert_eq!(fs[1].title.unwrap().y, fs[1].surface.bottom() - 1, "{status:?}: lower title on the boundary") }
+ }
+ }
}
diff --git a/tui/src/settings.rs b/tui/src/settings.rs
index c628309c8..b34e0e066 100644
--- a/tui/src/settings.rs
+++ b/tui/src/settings.rs
@@ -711,6 +711,10 @@ pub struct Look {
pub boxes: bool,
/// The panes you are not in, a little quieter (`@hn-dim`).
pub dim: bool,
+ /// How the current tab is marked: `star` (`*`) | `filled` (a filled block, no `*`).
+ pub window_active: String,
+ /// How a tab's name is shown: `tmux` (short) | `pane` (full).
+ pub window_name: String,
}
impl Look {
@@ -731,6 +735,8 @@ impl Look {
bar: match o.status_bar() { "bottom" if app.status_top => "top".into(), b => b.into() },
boxes: o.border_style() == "box",
dim: o.dim_others(),
+ window_active: get("@hn-window-active", "star"),
+ window_name: get("@hn-window-name", "tmux"),
}
}
@@ -749,6 +755,9 @@ impl Look {
"status_bar" => self.bar = value.into(),
"border_style" => self.boxes = value == "box",
"dim" => self.dim = value == "on",
+ // ── status bar tabs ──
+ "window_active" => self.window_active = value.into(),
+ "window_name" => self.window_name = value.into(),
_ => {}
}
self
@@ -948,9 +957,13 @@ pub fn preview(buf: &mut Buffer, r: Rect, look: &Look, c: &Chrome) {
let sstyle = Style::default().fg(pal.background).bg(pal.foreground);
for x in screen.x..screen.right() { buf.set_string(x, status_row, " ", sstyle) }
let mut x = screen.x + 1;
+ let filled = look.window_active == "filled";
for (i, n) in names.iter().take(panes.len()).enumerate() {
- let s = if i == 0 { sstyle.fg(accent).add_modifier(Modifier::BOLD) } else { sstyle };
- x += put(buf, x, status_row, screen.right().saturating_sub(x), &format!("{}:{}{} ", i, n, if i == 0 { "*" } else { "" }), s);
+ let (s, star) = if i == 0 {
+ if filled { (Style::default().fg(pal.foreground).bg(pal.background).add_modifier(Modifier::BOLD), "") }
+ else { (sstyle.fg(accent).add_modifier(Modifier::BOLD), "*") }
+ } else { (sstyle, "") };
+ x += put(buf, x, status_row, screen.right().saturating_sub(x), &format!("{}:{}{} ", i, n, star), s);
}
put(buf, screen.right().saturating_sub(7), status_row, 6, "studio", sstyle);
}
@@ -1221,4 +1234,18 @@ mod tests {
let line = draw(&look.clone().with(Some("border_style:line")));
assert_ne!(line[(panes[1].x, panes[1].y)].symbol(), "┌", "tmux's shared lines");
}
+
+ #[test]
+ fn a_filled_current_tab_drops_the_star() {
+ let app = app((150, 42));
+ let r = Rect::new(0, 0, 64, 20);
+ let show = |look: &Look| { let mut buf = Buffer::empty(r); preview(&mut buf, r, look, &chrome()); buf };
+ let row = |buf: &Buffer, y: u16| (0..r.width).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>();
+ let star = show(&Look::of(&app));
+ assert!(row(&star, 19).contains("0:claude*"), "{}", text(&star));
+ let filled = show(&Look::of(&app).with(Some("window_active:filled")));
+ // `with` read the knob, and the filled tab has no `*` beside its name.
+ assert_eq!(Look::of(&app).with(Some("window_active:filled")).window_active, "filled");
+ assert!(row(&filled, 19).contains("0:claude") && !row(&filled, 19).contains("0:claude*"), "{}", text(&filled));
+ }
}
diff --git a/tui/src/ui.rs b/tui/src/ui.rs
index 4fc1eff8d..decb8001f 100644
--- a/tui/src/ui.rs
+++ b/tui/src/ui.rs
@@ -139,6 +139,41 @@ mod repaint_tests {
}
}
+#[cfg(test)]
+mod border_style_tests {
+ use super::*;
+
+ fn app() -> App {
+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();
+ App::new(19789, sink, (100, 30))
+ }
+
+ /// The selected pane's border/status colour is the theme's when nothing is set, and the pane's
+ /// own when the style is set anyhow — in tmux.conf, by a set-option, or the config's `[look]`,
+ /// all of which reach the options store. (Setting it only in a tmux.conf that `app.look` reads
+ /// must not be the only way the user's colour wins.)
+ #[test]
+ fn a_border_style_set_anywhere_wins_over_the_theme() {
+ let mut a = app();
+ let (_, fg, _) = crate::theme::palette();
+ // Nothing set: the active pane's border is the theme's readable foreground, not tmux's green.
+ assert_eq!(border_style(&a, true).fg, Some(fg), "default active border is the theme's foreground");
+
+ // Give the window a focused pane, and set pane-active-border-style through the options
+ // store (a live set-option, or the config's `[look]`) — not only via a tmux.conf.
+ a.tabs[a.active].focus = Some(1);
+ let tid = a.tab().id.clone();
+ let global = crate::options::SetFlags { global: true, ..Default::default() };
+ let _ = a.options.set("pane-active-border-style", Some("fg=red"), &global, &tid, 1);
+ assert_eq!(border_style(&a, true).fg, Some(Color::Red), "a set pane-active-border-style is respected, not overridden by the theme");
+ assert_eq!(box_style(&a, 1).fg, Some(Color::Red), "a box pane's focused frame takes the set pane-active-border-style");
+
+ // The non-active border, set the same way, is respected too.
+ let _ = a.options.set("pane-border-style", Some("fg=blue"), &global, &tid, 1);
+ assert_eq!(border_style(&a, false).fg, Some(Color::Blue), "a set pane-border-style is respected for the quiet panes");
+ }
+}
+
/// screen_write_box_border_set: a box's corners, sides and its rule's joins, for tmux's box
/// lines (single, double, heavy, simple, rounded, padded, none).
fn box_set(lines: &str) -> (&'static str, &'static str, &'static str, &'static str, &'static str, &'static str, &'static str, &'static str) {
@@ -505,10 +540,17 @@ fn borders(buf: &mut Buffer, app: &App, body: Rect) {
/// hn leaves a stock border — tmux's green active border — alone only when you set one yourself;
/// otherwise it takes the theme's readable foreground (the active pane dimmed), so the selected
/// pane reads as the theme rather than tmux's green.
+/// Whether the user set a pane *-border-style for the current window — in tmux.conf, by a
+/// set-option, or in the config's `[look]` (any of which reaches the options store) — so its
+/// colour is theirs, not the theme's.
+fn border_owned(app: &App, active: bool) -> bool {
+ let name = if active { "pane-active-border-style" } else { "pane-border-style" };
+ app.options.has_window_override(name, &app.tab().id, app.focused().unwrap_or(0))
+}
+
fn border_style(app: &App, active: bool) -> Style {
let mut s = app.style_of(if active { "pane-active-border-style" } else { "pane-border-style" }, app.active, app.focused());
- let own = if active { app.look.active_border.is_some() } else { app.look.border.is_some() };
- if !own && !app.options.tmux_look() {
+ if !border_owned(app, active) && !app.options.tmux_look() {
let (_, fg, _) = crate::theme::palette();
s = s.fg(fg);
if !active { s = s.add_modifier(Modifier::DIM) }
@@ -545,8 +587,8 @@ fn boxes(buf: &mut Buffer, app: &App) {
let hz = box_set(&lines).4;
let inner = app.box_inner(tab);
let frames: Vec<(u64, crate::pane_frame::Frame)> = app.rects.iter().map(|(id, r)| (*id, crate::pane_frame::boxed_in(*r, canvas, inner, status))).filter(|(_, f)| f.content != f.surface).collect();
- // Each box its own line, in its own colour — boxes side by side touch (`││`), never sharing a
- // line or joining at a corner.
+ // Each box its own line, in its own colour, never sharing a cell with another (see
+ // `pane_frame::boxed`: `│ │` side by side, touching stacked).
for (id, f) in &frames {
let (r, style) = (f.surface, box_style(app, *id));
let edge: std::collections::HashSet<(u16, u16)> = (r.x..r.right()).flat_map(|x| [(x, r.y), (x, r.bottom() - 1)]).chain((r.y..r.bottom()).flat_map(|y| [(r.x, y), (r.right() - 1, y)])).collect();
@@ -579,8 +621,7 @@ fn boxes(buf: &mut Buffer, app: &App) {
/// tmux's own under `@hn-look tmux`, which draws no boxes). The marked pane's frame is bold.
fn box_style(app: &App, id: u64) -> Style {
let active = Some(id) == app.focused();
- let own = if active { app.look.active_border.is_some() } else { app.look.border.is_some() };
- let style = if own { border_style(app, active) }
+ let style = if border_owned(app, active) { border_style(app, active) }
// The focused frame is the status bar's own background colour, so the active pane's box
// always sits in the same colour as the bar — not the accent, and not the pane text.
else if active { Style::default().fg(theme::paint(app.status_style().bg.unwrap_or(Color::Reset))).add_modifier(if theme::no_color() { Modifier::BOLD } else { Modifier::empty() }) }
diff --git a/tui/tests/e2e.sh b/tui/tests/e2e.sh
index 6c663d1b6..3a3426441 100755
--- a/tui/tests/e2e.sh
+++ b/tui/tests/e2e.sh
@@ -176,8 +176,8 @@ tmux_ send-keys -t t C-u
expect "C-u clears the filter, not the mode" "mock-remote"
screen | grep -q "Search harnesses" && fail "C-u left the machines list"
tmux_ send-keys -t t Escape
+# (No Esc after it: Esc on the new window's empty New Harness form closes the window.)
tmux_ send-keys -t t C-b c
-tmux_ send-keys -t t Escape
expect "C-b c: a new window" "1:"
wait_eq "the dial hears the new window" 2 dial "d.said.app_swarms?.swarms?.length"
first=$(dial "d.said.app_swarms.swarms[0].id")
diff --git a/tui/tests/new-harness.py b/tui/tests/new-harness.py
index 1977eec6a..41920881b 100644
--- a/tui/tests/new-harness.py
+++ b/tui/tests/new-harness.py
@@ -218,7 +218,7 @@ try:
assert not re.search(field_at('Options|Machine'), form_screen()), 'settings are direct fields; machine belongs in Project'
choose_field('Approvals', 'read only'); shows('Read only')
task_text = 'Fix café login.\n\nKeep 界 and 🦀 intact.\nAdd a regression test.'
- field('Task'); shows('Enter start')
+ field('Task'); shows('enter start')
assert field_position('Task') == anchor, 'the task editor keeps the form visible and fixed'
raw('\x1b[200~Fix café login.\r\n\r\nKeep 界 and 🦀 intact.\x1b[201~')
shows('Keep 界 and 🦀 intact.')
@@ -314,7 +314,7 @@ try:
shows('autonomous-harness @ local'); shows('[x]')
tmux('resize-window', '-t', 'test', '-x', '150', '-y', '42'); settle_ui()
snapshot('new-harness-flat')
- field('Task'); shows('Enter start')
+ field('Task'); shows('enter start')
raw('\x1b[200~Improve the New Harness keyboard flow.\nKeep the launch settings visible.\x1b[201~')
shows('Keep the launch settings visible.'); snapshot('new-harness-task')
keys('Escape'); new_form(); shows('Improve the New Harness keyboard flow.')