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.

feat(tui): Codex and OpenCode icons from their assets, older button on the folder (#2577)

lingrd5190d62a8f3b
diff --git a/tui/Cargo.lock b/tui/Cargo.lock
index cad103016..d3c678d09 100644
--- a/tui/Cargo.lock
+++ b/tui/Cargo.lock
@@ -661,7 +661,7 @@ dependencies = [
[[package]]
name = "harness-tui"
-version = "0.1.45"
+version = "0.1.46"
dependencies = [
"alacritty_terminal",
"base64",
diff --git a/tui/Cargo.toml b/tui/Cargo.toml
index a55f51abf..149125f4a 100644
--- a/tui/Cargo.toml
+++ b/tui/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "harness-tui"
-version = "0.1.45"
+version = "0.1.46"
edition = "2024"
[dependencies]
diff --git a/tui/README.md b/tui/README.md
index de32b1ea6..8ffebd154 100644
--- a/tui/README.md
+++ b/tui/README.md
@@ -455,8 +455,9 @@ pane counts as done and unread (`✓`) until you go to that pane.
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; Enter adds marked rows as panes, while `C-t` opens a window each. The list stays
ranked while it is open. The list reads newest first, each machine with its folders under it.
- A harness untouched for over 7 days, with nothing going on and not on screen, folds under its
- folder's `▸ N older` (Enter shows them; a search always finds them). The keys line shows the main
+ A harness untouched for over 7 days, with nothing going on and not on screen, folds away behind
+ the `▸ N older` on its folder's heading (Enter or a click shows or hides them; a search always
+ finds them). The keys line shows the main
keys; `?` lists them all. 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`).
diff --git a/tui/src/format.rs b/tui/src/format.rs
index 9dbb90aea..5f6a860ed 100644
--- a/tui/src/format.rs
+++ b/tui/src/format.rs
@@ -1080,17 +1080,13 @@ fn quota_remaining<'a>(readings: impl Iterator<Item = (&'a str, &'a crate::fleet
}).collect::<Vec<_>>().join(" ")
}
-/// A subscription's provider as its engine's icon, in the engine's colour and on its tile (`✳`
-/// Claude, `☁` Codex/OpenAI…); a provider with no engine of its own, its name.
+/// A subscription's provider as its engine's icon, in the engine's colour (`✳` Claude, `☁`
+/// Codex/OpenAI…); a provider with no engine of its own, its name.
fn quota_icon(provider: &str) -> String {
let engine = match provider.to_ascii_lowercase().as_str() { "anthropic" | "claude" => "claude", "openai" | "chatgpt" | "codex" => "codex", _ => return quota_provider(provider) };
let (mark, colour) = crate::theme::engine_mark(engine);
if crate::theme::no_color() { return mark.to_string() }
- let fg = crate::tmuxconf::colour_name(crate::theme::paint(colour));
- match crate::theme::engine_tile(engine) {
- Some(tile) => format!("#[fg={fg},bg={}]{mark}#[fg=default,bg=default]", crate::tmuxconf::colour_name(tile)),
- None => format!("#[fg={fg}]{mark}#[fg=default]"),
- }
+ format!("#[fg={}]{mark}#[fg=default]", crate::tmuxconf::colour_name(crate::theme::paint(colour)))
}
fn quota_provider(provider: &str) -> String {
diff --git a/tui/src/input.rs b/tui/src/input.rs
index f5678f5d3..a5efb071a 100644
--- a/tui/src/input.rs
+++ b/tui/src/input.rs
@@ -3082,10 +3082,13 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {
if let Some(msg) = crate::settings::set_key(app, knob, value) { picker.say(msg) }
return keep(app, kind, picker);
}
- // `▸ N older`: Enter unfolds them where it stands; no other key means anything on it.
+ // A folder's `▸ N older`: Enter or a click shows them, and hides them again; no other key
+ // means anything on it.
PickerKind::Open { .. } if id.as_deref().is_some_and(|i| i.starts_with(modal::OLDER_ROW)) => {
if choice == Choice::Enter {
- if let Some(key) = id.as_deref().and_then(|i| i.strip_prefix(modal::OLDER_ROW)) { picker.unfolded.insert(key.to_string()); }
+ if let Some(key) = id.as_deref().and_then(|i| i.strip_prefix(modal::OLDER_ROW)) {
+ if !picker.unfolded.remove(key) { picker.unfolded.insert(key.to_string()); }
+ }
picker.refilter();
}
keep(app, kind, picker)
diff --git a/tui/src/modal.rs b/tui/src/modal.rs
index d8d4d8833..02a6c426f 100644
--- a/tui/src/modal.rs
+++ b/tui/src/modal.rs
@@ -346,33 +346,38 @@ pub fn agent_rows(app: &App, filter: Filter, machine: Option<&str>, project: Opt
with_older_rows(grouped_in_order(rows))
}
-/// [rows] with a `▸ N older` row closing each folder that has rows folded away (Enter unfolds them).
+/// [rows] with the heading of each folder that has rows folded away as a row of its own, its name
+/// and `▸ N older` on one line: the button that shows them, opening its folder (see
+/// settings::list_layout, which draws no other heading for it).
fn with_older_rows(rows: Vec<Row>) -> Vec<Row> {
let mut out: Vec<Row> = Vec::with_capacity(rows.len());
- let mut run: Option<(String, Option<String>, Option<String>, usize)> = None;
- let close = |out: &mut Vec<Row>, run: &mut Option<(String, Option<String>, Option<String>, usize)>| {
- if let Some((key, section, group, n)) = run.take() {
- let label = format!("▸ {n} older");
- let mut row = Row::new(format!("{OLDER_ROW}{key}"), label.clone());
- row.label_dim = label.chars().count();
- row.section = section;
- row.group = group;
- out.push(row);
- }
+ let mut start = 0;
+ let close = |out: &mut Vec<Row>, start: usize| {
+ let folded = || out[start..].iter().filter_map(|r| r.older.as_ref());
+ let Some(key) = folded().next().cloned() else { return };
+ let n = folded().count();
+ let first = &out[start];
+ let title = first.group.clone().unwrap_or_default();
+ let mut row = Row::new(format!("{OLDER_ROW}{key}"), title.clone()).right(format!("▸ {n} older"));
+ row.label_dim = title.chars().count();
+ row.section = first.section.clone();
+ row.group = first.group.clone();
+ out.insert(start, row);
};
for row in rows {
- if run.as_ref().is_some_and(|(_, s, g, _)| *s != row.section || *g != row.group) { close(&mut out, &mut run) }
- if let Some(key) = &row.older {
- match &mut run { Some((_, _, _, n)) => *n += 1, None => run = Some((key.clone(), row.section.clone(), row.group.clone(), 1)) }
+ if out.last().is_some_and(|l| l.section != row.section || l.group != row.group) {
+ close(&mut out, start);
+ start = out.len();
}
out.push(row);
}
- close(&mut out, &mut run);
+ close(&mut out, start);
out
}
/// [rows] with each section's rows together and each group's within it, in the order of each one's
-/// first row (the one active last's first), each group's rows in their own order.
+/// first row (the one active last's first), each group's rows in their own order, under the heading
+/// row it has if it has folded ones.
pub fn grouped_in_order(mut rows: Vec<Row>) -> Vec<Row> {
let mut sections: Vec<Option<String>> = Vec::new();
let mut groups: Vec<(Option<String>, Option<String>)> = Vec::new();
@@ -380,7 +385,7 @@ pub fn grouped_in_order(mut rows: Vec<Row>) -> Vec<Row> {
if !sections.contains(&r.section) { sections.push(r.section.clone()) }
if !groups.iter().any(|(s, g)| *s == r.section && *g == r.group) { groups.push((r.section.clone(), r.group.clone())) }
}
- rows.sort_by_key(|r| (sections.iter().position(|s| *s == r.section), groups.iter().position(|(s, g)| *s == r.section && *g == r.group)));
+ rows.sort_by_key(|r| (sections.iter().position(|s| *s == r.section), groups.iter().position(|(s, g)| *s == r.section && *g == r.group), !r.id.starts_with(OLDER_ROW)));
rows
}
@@ -1004,7 +1009,7 @@ mod agent_row_tests {
p
}
- fn visible_labels(p: &Picker) -> Vec<String> { p.visible.iter().map(|(i, _)| p.rows[*i].label.clone()).collect() }
+ fn visible_labels(p: &Picker) -> Vec<String> { p.visible.iter().map(|(i, _)| { let r = &p.rows[*i]; if r.id.starts_with(OLDER_ROW) { r.right.clone() } else { r.label.clone() } }).collect() }
/// A harness untouched for over a week folds under its folder's `▸ N older`; Enter's unfolding
/// brings it back, a search finds it with no such row, and one active or on screen never folds.
@@ -1016,6 +1021,11 @@ mod agent_row_tests {
make_old(&mut app, "local", "a2");
assert_eq!(agent_rows(&app, Filter::All, None, None).iter().filter(|r| r.id.starts_with(OLDER_ROW)).count(), 2, "one for webapp, one for api");
let mut p = opened(agent_rows(&app, Filter::All, None, None));
+ // The folder's heading is the button: first in its folder, its name and its count.
+ let at = p.rows.iter().position(|r| r.right == "▸ 1 older" && r.group.as_deref() == Some("webapp")).unwrap();
+ assert_eq!(p.rows[at].label, "webapp");
+ assert_eq!(p.rows[at + 1].group.as_deref(), Some("webapp"));
+ assert!(at == 0 || p.rows[at - 1].section != p.rows[at].section || p.rows[at - 1].group != p.rows[at].group);
let names = visible_labels(&p);
assert!(names.contains(&"▸ 1 older".to_string()), "{names:?}");
assert!(!names.contains(&"fix login".to_string()) && !names.contains(&"rate limit".to_string()), "{names:?}");
diff --git a/tui/src/picker.rs b/tui/src/picker.rs
index 4c6332946..96559f363 100644
--- a/tui/src/picker.rs
+++ b/tui/src/picker.rs
@@ -392,11 +392,11 @@ impl Picker {
// the machines answer the new one (no row blinking out on every key).
let found_now = !self.said_query.is_empty() && !query.trim().is_empty()
&& (self.said_query == query || query.starts_with(&self.said_query) || self.said_query.starts_with(query));
- // Old harnesses fold under their folder's `▸ N older` while browsing; a search goes through
+ // Old harnesses fold behind their folder's `▸ N older` while browsing; a search goes through
// all of them, with no such row in its results.
let browsing = query.trim().is_empty();
let folded = |r: &Row| browsing && r.older.as_ref().is_some_and(|k| !self.unfolded.contains(k));
- let spent = |r: &Row| r.id.strip_prefix(crate::modal::OLDER_ROW).is_some_and(|k| !browsing || self.unfolded.contains(k));
+ let spent = |r: &Row| !browsing && r.id.starts_with(crate::modal::OLDER_ROW);
let offered = |r: &Row| !folded(r) && !spent(r) && (!r.id.starts_with("external:") || self.catalog_ids.contains(&r.id) || (found_now && self.said.contains(&r.id)));
if query.trim().is_empty() {
self.visible = self.rows.iter().enumerate().filter(|(_, r)| !self.excluded.contains(&r.id) && offered(r)).map(|(i, _)| (i, Vec::new())).collect();
diff --git a/tui/src/preview.rs b/tui/src/preview.rs
index 1c16ea9f4..6e64f9c48 100644
--- a/tui/src/preview.rs
+++ b/tui/src/preview.rs
@@ -38,7 +38,7 @@ pub fn shell_lines(app: &App, kind: &PickerKind, id: &str) -> Vec<Line<'static>>
fn lines_with_actions(app: &App, kind: &PickerKind, id: &str, actions: bool) -> Vec<Line<'static>> {
match kind {
- PickerKind::Open { .. } if id.starts_with(crate::modal::OLDER_ROW) => vec![Line::raw("Harnesses not touched in the last 7 days."), Line::raw("Press enter to show them. Search always finds them.")],
+ PickerKind::Open { .. } if id.starts_with(crate::modal::OLDER_ROW) => vec![Line::raw("Harnesses in this folder not touched in the last 7 days."), Line::raw("Enter or a click shows or hides them. Search always finds them.")],
PickerKind::Open { .. } if id.starts_with("session:") => session(app, id),
PickerKind::Open { .. } if id.starts_with("external:") => external(app, id, actions),
PickerKind::Open { .. } | PickerKind::Inbox | PickerKind::Route { .. } => {
diff --git a/tui/src/settings.rs b/tui/src/settings.rs
index eb98215c3..9d49e110f 100644
--- a/tui/src/settings.rs
+++ b/tui/src/settings.rs
@@ -824,8 +824,11 @@ fn list_layout(picker: &Picker, bottom_up: bool) -> (Vec<Option<usize>>, Vec<(us
if !lines.is_empty() { lines.push(None) }
if let Some(s) = section { titles.push((lines.len(), s.to_string(), TitleKind::Section)); lines.push(None) }
}
- titles.push((lines.len(), title.to_string(), if section.is_some() { TitleKind::Under } else { TitleKind::Plain }));
- lines.push(None);
+ // (A folder with old harnesses folded away: its heading is that row, `▸ N older` on it.)
+ if !row.id.starts_with(crate::modal::OLDER_ROW) {
+ titles.push((lines.len(), title.to_string(), if section.is_some() { TitleKind::Under } else { TitleKind::Plain }));
+ lines.push(None);
+ }
}
(last, last_section) = (group, section);
lines.push(Some(vi));
@@ -887,15 +890,16 @@ impl PanelList<'_> {
if picker.marked.contains(&row.id) { put(buf, r.x + 1, y, 1, "•", if here { c.selected } else { c.accent }); }
let mut at = r.x + 2;
for span in &row.lead {
- // (A mark keeps its colour on the cursor's row, and its tile if it has one.)
- let s = if here { let s = style.patch(Style::default().fg(span.style.fg.unwrap_or(Color::Reset))); match span.style.bg { Some(tile) => s.bg(tile), None => s } } else { c.base.patch(span.style) };
+ let s = if here { style.patch(Style::default().fg(span.style.fg.unwrap_or(Color::Reset))) } else { c.base.patch(span.style) };
at += put(buf, at, y, r.right().saturating_sub(at), &span.content, s);
}
// The right column as the row has it for this width (its short form in a narrow list:
// a harness's age, not its project and machine), and never more than a third of the
// row — so it can not run off the panel or over the name. (Half, in a list that asks: the
// Models view's size, speed and word, side by side as the desktop's rows have them.)
- let right_text = row.right_at(r.width as usize);
+ // (A folder's `▸ N older`, opened: what the same key does now.)
+ let opened = row.id.strip_prefix(crate::modal::OLDER_ROW).is_some_and(|k| picker.unfolded.contains(k));
+ let right_text = if opened { "▾ hide older" } else { row.right_at(r.width as usize) };
let right_w = (right_text.width() as u16).min(if picker.right_half { r.width / 2 } else { r.width / 3 });
// (The last column is the scroll mark's, with a blank before it.)
let end = r.right().saturating_sub(if right_w > 0 { right_w + 3 } else { 2 });
@@ -1828,6 +1832,28 @@ mod tests {
assert_eq!(rows, [" ›•alpha", " beta", " alpine"]);
}
+ /// A folder with old harnesses folded away has its heading as a row: nothing titled over it, and
+ /// it says `▾ hide older` once opened.
+ #[test]
+ fn a_folders_older_button_is_its_heading() {
+ use crate::picker::Row;
+ let mut p = Picker::new("harnesses", "");
+ let mut button = Row::new(format!("{}k", modal::OLDER_ROW), "webapp").group("webapp").right("▸ 2 older");
+ button.section = Some("studio".into());
+ let mut live = Row::new("a", "alpha").group("webapp");
+ live.section = Some("studio".into());
+ let mut old = Row::new("b", "beta").group("webapp");
+ old.section = Some("studio".into());
+ old.older = Some("k".into());
+ p.set_rows(vec![button, live, old]);
+ let (lines, titles) = list_layout(&p, false);
+ assert_eq!(lines, [None, Some(0), Some(1)], "the machine, the button, the row; beta folded");
+ assert_eq!(titles.iter().map(|t| t.1.as_str()).collect::<Vec<_>>(), ["studio"]);
+ p.unfolded.insert("k".into());
+ p.refilter();
+ assert_eq!(list_layout(&p, false).0, [None, Some(0), Some(1), Some(2)], "still the button, then beta");
+ }
+
/// A machine's heading, its folders level with it under it, a blank line only between machines:
/// no indent, and the cursor's row keeps both headings in view.
#[test]
diff --git a/tui/src/theme.rs b/tui/src/theme.rs
index f01b68a9c..1d3e5335d 100644
--- a/tui/src/theme.rs
+++ b/tui/src/theme.rs
@@ -1255,21 +1255,8 @@ pub fn engine_mark(engine: &str) -> (&'static str, Color) {
(mark, paint(color))
}
-/// The tile an engine's mark sits on, for the marks that have one: Codex's purple cloud on white,
-/// OpenCode's white square on black.
-pub fn engine_tile(engine: &str) -> Option<Color> {
- match engine {
- "codex" => Some(paint(Color::Rgb(0xFF, 0xFF, 0xFF))),
- "opencode" => Some(paint(Color::Rgb(0x00, 0x00, 0x00))),
- _ => None,
- }
-}
-
-/// An engine's mark as drawn: its colour, on its tile if it has one.
-pub fn engine_style(engine: &str) -> Style {
- let style = fg(engine_mark(engine).1);
- match engine_tile(engine) { Some(tile) => style.bg(tile), None => style }
-}
+/// An engine's mark as drawn: its colour.
+pub fn engine_style(engine: &str) -> Style { fg(engine_mark(engine).1) }
/// A colour as this terminal can show it: none under NO_COLOR, the nearest it has otherwise.
pub fn paint(c: Color) -> Color { if no_color() { Color::Reset } else { depth_fit(c) } }
@@ -1277,9 +1264,11 @@ pub fn paint(c: Color) -> Color { if no_color() { Color::Reset } else { depth_fi
fn engine_mark_raw(engine: &str) -> (&'static str, Color) {
match engine {
"claude" => ("✳", Color::Rgb(0xD9, 0x77, 0x57)),
- "codex" => ("☁", Color::Rgb(0x7C, 0x3A, 0xED)),
+ // (As their icons in assets/engine-icons: Codex's rounded cloud, in its purple; OpenCode's
+ // hollow frame, a line in the text's colour.)
+ "codex" => ("☁", Color::Rgb(0x8F, 0x83, 0xF8)),
"cursor" => ("▲", TEXT),
- "opencode" => ("■", Color::Rgb(0xFF, 0xFF, 0xFF)),
+ "opencode" => ("□", TEXT),
"pi" => ("π", ACCENT_SOFT),
"hermes" => ("☿", Color::Rgb(0xC7, 0x92, 0xEA)),
"amp" => ("ϟ", DANGER),
diff --git a/tui/tests/harness-list.py b/tui/tests/harness-list.py
index 2613b88bf..997bee861 100644
--- a/tui/tests/harness-list.py
+++ b/tui/tests/harness-list.py
@@ -89,12 +89,14 @@ try:
# The month-old ones are folded, and their folder is the last one on their machine.
assert 'Old session' not in s, s
- assert s.index('old-repo') < s.index('▸ 25 older'), s
assert s.index('old-repo') > s.index('billing'), 'newest folders first\n' + s
- # One column: a machine, its folders, their rows, no indent; never `machine · folder`.
+ # The button is on its folder's label, one line.
+ assert any('old-repo' in l and '▸ 25 older' in l for l in s.splitlines()), s
+
+ # One column: a machine, its folders, no indent; never `machine · folder`.
column = lambda text: next(l.index(text) for l in s.splitlines() if text in l)
- assert column('studio') == column('old-repo') == column('▸ 25 older'), s
+ assert column('studio') == column('old-repo'), s
assert ' · old-repo' not in s, s
# The keys line has the main keys and says where the rest are.
@@ -110,20 +112,25 @@ try:
s = taken('Old session 0')
assert '▸ 25 older' not in s, s
assert s.index('Old session 0') < s.index('Old session 2'), s
+ assert any('old-repo' in l and '▾ hide older' in l and '›' in l for l in s.splitlines()), s
+
+ # The same key hides them again, and shows them again.
+ keys('Enter'); gone('Old session 0'); taken('▸ 25 older')
+ keys('Enter'); taken('Old session 0')
# Opened again they are folded again; a search finds one, with no `older` row in its results.
keys('Escape'); gone('Search harnesses')
keys('C-b', 's'); taken('▸ 25 older')
type_text('Old session 7')
s = taken('Old session 7')
- assert 'older' not in s, s
+ assert '▸ 25 older' not in s and 'hide older' not in s, s
- # OpenCode's white square on black and Codex's purple cloud on white, cursor's row included.
- painted = coloured()
- assert any(p in painted for p in ('48;2;0;0;0', '48;5;16', '48;5;0')) and '■' in painted, repr(painted)
+ # OpenCode's hollow square and Codex's cloud, as their icons: marks with no tile behind them.
+ assert '□' in screen(), screen()
keys('C-u'); type_text('Old session 8'); taken('Old session 8')
- painted = coloured()
- assert any(p in painted for p in ('48;2;255;255;255', '48;5;231', '48;5;15')) and '☁' in painted, repr(painted)
+ assert '☁' in screen(), screen()
+ tiled = ('48;2;255;255;255m☁', '48;5;231m☁', '48;5;15m☁')
+ assert not any(t in coloured() for t in tiled), repr(coloured())
print('harness-list ok')
except BaseException:
if started: print(screen(), file=sys.stderr)