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.

hn: a command's window says what it is opening, not the New Harness form

bubu-dudu20073aa3f0b3
diff --git a/tui/src/app.rs b/tui/src/app.rs
index cadad6924..90713bc0f 100644
--- a/tui/src/app.rs
+++ b/tui/src/app.rs
@@ -305,6 +305,9 @@ pub struct Tab {
pub named: bool,
/// The recent-harness home page over this window's shell; scripts still see a real pane.
pub home: bool,
+ /// What this empty window is opening (`Updates`, `hn-os`): a command's window shows that
+ /// while its terminal starts, not the New Harness form the user did not ask for.
+ pub opening: Option<String>,
pub root: Option<Node>,
pub focus: Option<u64>,
pub zoomed: bool,
@@ -356,7 +359,7 @@ impl Tab {
pub fn home() -> Tab { Tab::with_wid("New Tab", NO_WID) }
/// A window with the id it had (a session another client kept, the desk's).
pub fn with_wid(name: &str, wid: u64) -> Tab {
- Tab { id: Uuid::new_v4().simple().to_string(), wid: std::cell::Cell::new(wid), size: None, name: name.to_string(), named: false, home: false, root: None, focus: None, zoomed: false, last: Vec::new(), order: Vec::new(), points: HashMap::new(), alerts: 0, last_output: Instant::now(), activity: crate::format::now_secs(), layout_at: None, on_desk: false, sync: false, first_named: false, layout: json!({}), desk_layout: json!({}), desk_panes: Vec::new(), desk_preset: None, shared_geometry: None }
+ Tab { id: Uuid::new_v4().simple().to_string(), wid: std::cell::Cell::new(wid), size: None, name: name.to_string(), named: false, home: false, opening: None, root: None, focus: None, zoomed: false, last: Vec::new(), order: Vec::new(), points: HashMap::new(), alerts: 0, last_output: Instant::now(), activity: crate::format::now_secs(), layout_at: None, on_desk: false, sync: false, first_named: false, layout: json!({}), desk_layout: json!({}), desk_panes: Vec::new(), desk_preset: None, shared_geometry: None }
}
fn fit_layout(&mut self, size: (u16, u16), status: layout::Status) -> bool {
let Some(root) = self.root.as_mut() else { return false };
diff --git a/tui/src/input.rs b/tui/src/input.rs
index cbfb5b98f..e9c54ab27 100644
--- a/tui/src/input.rs
+++ b/tui/src/input.rs
@@ -1409,6 +1409,15 @@ pub fn new_shell_with_picker(app: &mut App, focused: Option<(String, String)>, p
let buffered = std::sync::Arc::new(std::sync::Mutex::new(Vec::new()));
app.starting_shell = Some(buffered.clone());
let tab = match &placement { Placement::Fill(id) => id.clone(), Placement::At(at) => at.tab.clone(), _ => app.tab().id.clone() };
+ // A command's own window (Super+u's Updates, Super+w's Wi-Fi) says what is opening while its
+ // terminal starts: the daemon takes about a second, and the empty window's New Harness form
+ // flashed there first, as if the shortcut had opened that instead.
+ if let Some(command) = &command {
+ if let Some(window) = app.tabs.iter_mut().find(|t| t.id == tab && t.root.is_none() && !t.home) {
+ let program = command.split_whitespace().next().unwrap_or("").rsplit('/').next().unwrap_or("").to_string();
+ window.opening = Some(if window.name.is_empty() || window.name == "New Tab" { program } else { window.name.clone() });
+ }
+ }
app.shell_inputs.insert(tab, buffered.clone());
// Completion state belongs to this request, including concurrent -d/-P callers.
let print_new = app.print_new.take();
diff --git a/tui/src/ui.rs b/tui/src/ui.rs
index b75fd06f4..28dbbd630 100644
--- a/tui/src/ui.rs
+++ b/tui/src/ui.rs
@@ -218,7 +218,9 @@ pub fn draw(frame: &mut Frame, app: &mut App) {
// (The settings panel is not one: it floats over the panes, as the New Harness form does.)
let full_screen = matches!(&app.modal, Some(Modal::Picker { kind, .. }) if theme::fzf_opts().height.is_none() && !crate::settings::is_panel(kind));
if !full_screen {
- if app.tab().home || app.tab().root.is_none() { cursor = empty_window(buf, app, body); themed_home(buf, body); }
+ let opening = app.tab().opening.clone().filter(|_| !app.tab().home && app.tab().root.is_none() && app.shell_inputs.contains_key(&app.tab().id));
+ if let Some(what) = opening { opening_window(buf, body, &what); themed_home(buf, body); }
+ else if app.tab().home || app.tab().root.is_none() { cursor = empty_window(buf, app, body); themed_home(buf, body); }
else { cursor = window(buf, app, body) }
}
// Panes in clock mode: the time over each (its cursor hidden).
@@ -640,6 +642,13 @@ fn empty_window(buf: &mut Buffer, app: &mut App, area: Rect) -> Option<Position>
else { crate::new_harness::draw_welcome(buf, app, area) }
}
+/// A command's window while its terminal starts: a quiet line, nothing to choose.
+fn opening_window(buf: &mut Buffer, area: Rect, what: &str) {
+ let line = Line::styled(if what.is_empty() { "Opening…".to_string() } else { format!("Opening {what}…") }, fg(theme::MUTED));
+ let x = area.x + area.width.saturating_sub(line.width() as u16) / 2;
+ buf.set_line(x, area.y + area.height / 2, &line, area.width.saturating_sub(x - area.x));
+}
+
fn os_welcome(buf: &mut Buffer, app: &App, area: Rect) {
let mut lines = Vec::new();
if area.height >= 24 {
@@ -3003,6 +3012,23 @@ mod theme_render_tests {
(0..42).map(|y| (0..150).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")
}
+ /// A command's window (Super+u's Updates) says what is opening while its terminal starts,
+ /// not the New Harness form; with nothing on its way, an empty window is the form again.
+ #[test]
+ fn a_command_window_says_what_it_opens_while_its_terminal_starts() {
+ let mut app = app();
+ app.tab_mut().name = "Updates".into();
+ app.tab_mut().opening = Some("Updates".into());
+ let id = app.tab().id.clone();
+ app.shell_inputs.insert(id.clone(), Default::default());
+ let s = screen(&mut app);
+ assert!(s.contains("Opening Updates…"), "{s}");
+ assert!(!s.contains("What task should"), "no New Harness form while the command starts:\n{s}");
+ // The terminal never came (the request failed): back to what an empty window shows.
+ app.shell_inputs.remove(&id);
+ assert!(!screen(&mut app).contains("Opening Updates…"));
+ }
+
/// `theme` opens the settings panel over the window (not fzf's full-screen list), and a key
/// into a section shows that section's options — which a fleet refresh leaves open.
#[test]