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.

fix(tui): add picker selections to the current tab (#508)

Dee21793ef8d846
diff --git a/tui/README.md b/tui/README.md
index e15c70d59..0b7ab6a87 100644
--- a/tui/README.md
+++ b/tui/README.md
@@ -73,8 +73,9 @@ flags are accepted (hn already works that way) and `-c` runs a command in your s
## Keys
-tmux's. The prefix is `C-b`; `C-b s` then Enter goes to any harness (its window, or a window of its own), `C-v` or `C-x` puts it beside or below; every default tmux binding does what it does in tmux, with a window
-being a swarm and a pane showing a harness. If you have a `~/.tmux.conf`, it is read: your prefix and
+tmux's. The prefix is `C-b`; `C-b s` then Enter adds a harness to the current window, `C-t` opens
+it in a new window, and `C-v` or `C-x` puts it beside or below. An already-open harness is focused.
+A window is a swarm and a pane shows a harness. If you have a `~/.tmux.conf`, it is read: your prefix and
binds (copy-mode-vi's and vim-tmux-navigator's too), `source-file`, `if-shell`, `base-index`,
`renumber-windows`, `mouse`, `mode-keys`, `status-left`/`status-right` and the window formats
(`#[…]` styles, `#{?…}`, `%H:%M`), `pane-border-format`, `synchronize-panes` and your colours come
@@ -178,8 +179,10 @@ never reaches a working pane. No reverse-video selection is used.
In the harness and command lists, fzf's keys: `C-j/C-k` `C-n/C-p` move, `Tab` marks, `C-/` toggles the preview,
-`S-↑/↓` scrolls it, `M-/` wraps long rows (`--wrap`), `C-a C-e C-w C-u` edit the query, `enter`
-opens, `C-t` in a new window, `C-v` beside, `C-x` below, `esc` leaves. fzf's search syntax works
+`S-↑/↓` scrolls it, `M-/` wraps long rows (`--wrap`), `C-a C-e C-w C-u` edit the query. In the harness
+list, `enter` adds a pane in the current window, `C-t` opens in a new window, `C-v` beside, `C-x`
+below; an already-open harness is focused. In the command list, `enter` runs the command. `esc`
+leaves. fzf's search syntax works
(`'exact ^prefix suffix$ !not a | b`), and its colours follow `FZF_DEFAULT_OPTS` (`--color=light`,
`16`, `bw`). One key differs on purpose: fzf 0.67 binds `ctrl-/` to toggle-wrap as well as `alt-/`,
but hn keeps `C-/` for the preview, as fzf's own README binds `ctrl-/` in its preview examples and
@@ -224,13 +227,14 @@ pane counts as done and unread (`✓`) until you go to that pane.
(`Run the unit tests`, from its tool calls), what its last turn came to (the daemon's recap, else
the first line of its final message), or why it failed (`The agent did not start within 60
seconds.`). Each row also has its pull request (`#4812`, `#4807 draft`, `#4790 merged`), its
- project when there are several, and how long it has been that way. Enter goes to it: its window,
- or a window of its own (`C-v` / `C-x` beside or below, `M-Enter` in place of this pane). Typing
+ project when there are several, and how long it has been that way. Enter adds it as a pane in
+ the current window, or focuses it if already open (`C-t` in a new window, `C-v` / `C-x` beside or
+ below, `M-Enter` in place of this pane). Typing
filters as fzf does, by name, project, branch, machine, pull request (`'4812`) or state
(`'waiting`, `'failed`, `'done`, `'working`, `'idle`). From the list, without opening it: `M-m`
marks it read (`M-M` every row shown), `M-s` sends it a message, `M-r` restarts it, `M-1…9` /
- `M-a` answer it; marked rows open a window each. The list stays ranked while it is open. The preview adds its
- final message whole, what it was last asked, its plan (its to-do list,
+ `M-a` answer it; Enter adds marked rows as panes, while `C-t` opens a window each. The list stays
+ ranked while it is open. The preview adds its final message whole, what it was last asked, its plan (its to-do list,
`✓` done, `▸` doing), the sub-agents it has running, and what it has used (`1.2M tokens · +340
−52 · 1 PR`).
- **A session per project**: in `C-b s` then `#` (the projects, each with its counts), `C-t` makes
diff --git a/tui/src/input.rs b/tui/src/input.rs
index 80b488735..708d1afe9 100644
--- a/tui/src/input.rs
+++ b/tui/src/input.rs
@@ -618,7 +618,7 @@ fn fill_rows(app: &App, kind: &PickerKind, picker: &mut Picker) {
}
picker.set_rows(rows);
picker.status = modal::open_status(app, *filter);
- picker.hints = vec![("enter", "go"), ("M-1..9", "answer"), ("M-m", "read"), ("C-v", "beside"), ("C-x", "below"), ("M-enter", "here"), ("M-a", "type an answer"), ("M-s", "message"), ("M-r", "restart"), ("tab", "mark"), ("C-/", "preview"), ("M-p", "pause")];
+ picker.hints = vec![("enter", "add pane"), ("C-t", "new window"), ("M-1..9", "answer"), ("M-m", "read"), ("C-v", "beside"), ("C-x", "below"), ("M-enter", "here"), ("M-a", "type an answer"), ("M-s", "message"), ("M-r", "restart"), ("tab", "mark"), ("C-/", "preview"), ("M-p", "pause")];
picker.empty = if app.fleet.agents.is_empty() { "no harnesses yet — C-b C makes one".into() } else { String::new() };
}
PickerKind::Palette => { picker.set_rows(modal::palette_rows(app)); picker.hints = vec![("enter", "run"), ("C-b :", "type one")] }
@@ -2511,14 +2511,15 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {
SPLIT.with(|s| s.set(None));
app.switch_session(sid);
}
- // A conversation Harness did not start: resumed as a harness (a new window, or where C-v,
- // C-x, M-enter say); one open in another terminal or app is not opened twice.
+ // A conversation Harness did not start: resumed as a harness in this window, or where
+ // C-t, C-v, C-x, M-enter say; one open in another terminal or app is not opened twice.
PickerKind::Open { .. } if id.as_deref().map(|i| i.starts_with("external:")).unwrap_or(false) => {
let found = id.as_deref().and_then(|i| i.strip_prefix("external:")).and_then(|r| r.split_once(':'))
.and_then(|(m, s)| app.said.iter().filter_map(|h| h.external.as_ref()).find(|x| x.machine == m && x.session_id == s).cloned());
let Some(x) = found else { return keep(app, kind, picker) };
if x.open { picker.say("It is open in another terminal or app — close it there first"); return keep(app, kind, picker) }
let placement = match choice {
+ Choice::Enter => Placement::Auto(None),
Choice::SplitRight => Placement::Split(Dir::Horizontal), Choice::SplitDown => Placement::Split(Dir::Vertical), Choice::Here => Placement::Replace,
_ => if app.tab().root.is_none() { Placement::Auto(None) } else { Placement::Tab },
};
@@ -2549,11 +2550,12 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {
(Choice::SplitDown, _) => Placement::Split(Dir::Vertical),
(Choice::Here, _) => Placement::Replace,
(_, Some(dir)) => Placement::Split(dir),
- // Enter, as tmux's chooser: to the harness's window, or a window of its own.
+ // Enter adds a pane in this window; an already-open harness is focused.
+ (Choice::Enter, None) => Placement::Auto(None),
_ => Placement::Tab,
};
- // fzf --multi: Enter acts on every marked row — a window each (C-v / C-x: the first
- // where asked, the rest beside it).
+ // fzf --multi: Enter adds every marked harness here; C-t opens a window each.
+ // C-v / C-x put the first where asked and add the rest beside it.
let mut targets: Vec<(String, String)> = picker.marked.iter().filter_map(|m| split_key(m)).collect();
if targets.is_empty() { targets.push((machine.clone(), agent.clone())) }
for (i, (machine, agent)) in targets.iter().enumerate() {
diff --git a/tui/src/preview.rs b/tui/src/preview.rs
index e174b9013..45ad49d58 100644
--- a/tui/src/preview.rs
+++ b/tui/src/preview.rs
@@ -80,7 +80,7 @@ fn harness(app: &App, machine_id: &str, agent_id: &str) -> Vec<Line<'static>> {
let name = app.session_list().into_iter().find(|(i, _)| *i == sid).map(|(_, n)| n).unwrap_or_default();
format!("in {name}:{n} — enter goes to it")
});
- out.push(dim(place.unwrap_or_else(|| "enter opens it in a window · C-v beside · C-x below · M-enter here".into())).into());
+ out.push(dim(place.unwrap_or_else(|| "enter adds a pane here · C-t new window · C-v beside · C-x below · M-enter here".into())).into());
return out;
}
// What it asks, or why it failed, first: at 80×24 the preview is a few rows.
@@ -148,7 +148,7 @@ fn harness(app: &App, machine_id: &str, agent_id: &str) -> Vec<Line<'static>> {
let name = app.session_list().into_iter().find(|(i, _)| *i == sid).map(|(_, n)| n).unwrap_or_default();
format!("in {name}:{n} — enter goes to it")
});
- out.push(dim(place.unwrap_or_else(|| "enter opens it in a window · C-v beside · C-x below · M-enter here".into())).into());
+ out.push(dim(place.unwrap_or_else(|| "enter adds a pane here · C-t new window · C-v beside · C-x below · M-enter here".into())).into());
out
}
@@ -265,7 +265,7 @@ fn external(app: &App, id: &str) -> Vec<Line<'static>> {
}
out.push(Line::raw(""));
out.push(if x.open { Line::styled("Open in another terminal or app — close it there to open it here", Style::default().fg(Color::Yellow)) }
- else { dim("enter resumes it in a window · C-v beside · C-x below · M-enter here — without permission prompts, as the desktop resumes it").into() });
+ else { dim("enter resumes it as a pane here · C-t new window · C-v beside · C-x below · M-enter here — without permission prompts, as the desktop resumes it").into() });
out
}
diff --git a/tui/tests/e2e.sh b/tui/tests/e2e.sh
index da790f633..c80733599 100755
--- a/tui/tests/e2e.sh
+++ b/tui/tests/e2e.sh
@@ -59,13 +59,24 @@ status_tabs() { screen | tail -n 1 | grep -q '^ 0:' && echo yes; }
wait_eq "status line starts with window tabs, without a session label" yes status_tabs
expect "status line quotes the local machine's app name" '"mock-local"'
wait_eq "desk=off: the first session is still tmux's 0" 0 hn display -p '#{session_name}'
+start_window=$(hn display -p '#{window_id}')
tmux_ send-keys -t t C-b s
expect "C-b s opens the fzf list" "Search harnesses"
tmux_ send-keys -t t 'Mock\ Claude'
expect "fuzzy filter narrows" "1/"
-# Enter, as tmux's chooser: the harness in a window of its own (not a split of this one).
+# Enter adds the harness beside the existing shell in the current window.
tmux_ send-keys -t t Enter
-expect "C-b s Enter: a window of its own, name before status" "1:Mock Claude*"
+expect "C-b s Enter streams the selected harness" "Mock Claude (mock)"
+wait_eq "C-b s Enter keeps the current window" "$start_window" hn display -p '#{window_id}'
+wait_eq "C-b s Enter adds a pane" "2" hn display -p '#{window_panes}'
+wait_eq "C-b s Enter does not add a window" "1" hn display -p '#{session_windows}'
+hn kill-pane
+tmux_ send-keys -t t C-b s
+expect "C-b s reopens the fzf list" "Search harnesses"
+tmux_ send-keys -t t 'Mock\ Claude'
+expect "fuzzy filter narrows for a new window" "1/"
+tmux_ send-keys -t t C-t
+expect "C-b s C-t: a window of its own, name before status" "1:Mock Claude*"
idle_tab() { hn display -p "$(hn show -gwv window-status-current-format)"; }
wait_eq "idle windows have no status dot" "1:Mock Claude*" idle_tab
wait_eq "the harness window's one pane" "1" hn display -p '#{window_panes}'