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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Fix Project search across machine names and large histories (#527)
Deeddf6fb0b3248
diff --git a/tui/README.md b/tui/README.mdindex 4c360fa34..7f6228a3b 100644--- a/tui/README.md+++ b/tui/README.md@@ -170,7 +170,10 @@ beside the focused pane when needed. Lowercase `C-b n` remains next window.Agent combines coding agents and installed Store harnesses; a Store harness then offers itscompatible coding agents. Project offers Clone Repository, Open Folder, New Folder and recentmachine/folder pairs. Folder actions choose a machine first. Ctrl-L in the folder browser edits-a path. Task opens an editor in the same panel: Enter accepts, Alt-Enter inserts a newline,+a path. Project search includes recent folders from every machine; combine a machine name and+folder, such as `office harness` or `m2 harness`, in either order. The local machine's actual+name remains searchable when its label says `local`.+Task opens an editor in the same panel: Enter accepts, Alt-Enter inserts a newline,and pasted tasks retain line breaks. Escape preserves the task in the draft. Supported agentsreceive it as their first message; an unavailable first task or one exceeding the daemon's2,000-character limit is explained before launch. A blank task starts an ordinary session.diff --git a/tui/src/new_harness.rs b/tui/src/new_harness.rsindex 0e0b98dd7..877237655 100644--- a/tui/src/new_harness.rs+++ b/tui/src/new_harness.rs@@ -596,6 +596,8 @@ fn project_rows(app: &App, draft: &Draft) -> Vec<Row> {std::cmp::Reverse(a.recency()),)});+ // Search every known folder. Capping this local-first list before filtering can hide+ // every remote project when the local machine has a large history.let mut seen = std::collections::HashSet::new();for a in agents {let machine = app.fleet.launch_machine_id(&a.machine_id);@@ -625,9 +627,6 @@ fn project_rows(app: &App, draft: &Draft) -> Vec<Row> {row.label.push_str(" · offline");}rows.push(row);- if seen.len() == 60 {- break;- }}rows}@@ -776,7 +775,8 @@ fn child(app: &mut App, form: &mut Form, kind: Choice, initial: &str) {Choice::Task => "Harness anything…",};let mut picker = Picker::new("", hint);- picker.keep_order = true;+ picker.keep_order = kind != Choice::Project;+ picker.search_extra = kind == Choice::Project;picker.query = initial.into();picker.qcursor = initial.chars().count();picker.empty = "No matches".into();@@ -1694,6 +1694,66 @@ mod tests {assert_eq!(recent[0].label, "~/repo @ local");}+ #[tokio::test]+ async fn project_search_reaches_remote_machines_after_a_large_local_history() {+ let mut app = app();+ for name in ["office", "m2"] {+ app.fleet.machines.push(crate::fleet::Machine {+ id: name.into(), name: name.into(), local: false,+ status: "running".into(), reach: crate::fleet::Reach::Ready,+ });+ app.homes.insert(name.into(), "/home/dev".into());+ }+ for (machine, count) in [("local", 100), ("office", 1), ("m2", 1)] {+ for i in 0..count {+ let agent = crate::fleet::agent_from(machine, &json!({+ "id": format!("agent-{i}"), "engine": "codex",+ "project": {"cwd": format!("/home/dev/harnesses/autonomous-harness-2026-{i:03}")},+ }), None);+ app.fleet.agents.insert(agent.key(), agent);+ }+ }+ open(&mut app, None, None);+ let Some(Modal::NewHarness(mut form)) = app.modal.take() else { panic!() };+ child(&mut app, &mut form, Choice::Project, "");+ assert_eq!(form.child.as_ref().unwrap().picker.rows.iter().filter(|r| r.id.starts_with("at:")).count(), 102);+ for machine in ["office", "m2"] {+ for query in [format!("{machine} harness"), format!("harness {machine}")] {+ let picker = &mut form.child.as_mut().unwrap().picker;+ picker.set_query(&query);+ let selected = picker.current().expect("the remote project is searchable");+ assert_eq!(selected.id, format!("at:{machine}\t/home/dev/harnesses/autonomous-harness-2026-000"), "{query}");+ assert!(selected.label.ends_with(&format!(" @ {machine}")));+ assert!(!selected.disabled);+ }+ choose(&mut app, &mut form);+ assert_eq!(form.draft.machine, machine);+ assert!(matches!(&form.draft.project, Project::Folder(path) if path == "/home/dev/harnesses/autonomous-harness-2026-000"));+ child(&mut app, &mut form, Choice::Project, "");+ }+ }++ #[tokio::test]+ async fn project_search_keeps_the_short_local_machine_name_searchable() {+ let mut app = app();+ app.fleet.machine_mut("local").unwrap().name = "M2".into();+ let agent = crate::fleet::agent_from("local", &json!({+ "id": "agent", "engine": "codex", "project": {"cwd": "/home/dev/harnesses/repo"},+ }), None);+ app.fleet.agents.insert(agent.key(), agent);+ open(&mut app, None, None);+ let Some(Modal::NewHarness(mut form)) = app.modal.take() else { panic!() };+ child(&mut app, &mut form, Choice::Project, "");+ let picker = &mut form.child.as_mut().unwrap().picker;+ for query in ["m2 harness", "harness m2", "M2 harness", "local harness"] {+ picker.set_query(query);+ let selected = picker.current().expect("the real machine name and local both work");+ assert_eq!(selected.id, "at:local\t/home/dev/harnesses/repo", "{query}");+ assert_eq!(selected.label, "~/harnesses/repo @ local");+ assert!(picker.visible.iter().all(|(i, hits)| hits.iter().all(|at| (*at as usize) < picker.rows[*i].label.chars().count())));+ }+ }+#[tokio::test]async fn daemon_return_redirects_an_idle_local_draft_but_keeps_a_pending_receipt() {for pending in [false, true] {diff --git a/tui/src/picker.rs b/tui/src/picker.rsindex e82d20498..1c0ba0202 100644--- a/tui/src/picker.rs+++ b/tui/src/picker.rs@@ -91,6 +91,9 @@ pub struct Picker {pub heading: Option<String>,pub placeholder: String,pub query: String,+ /// Include hidden row text in fuzzy matching and ranking. Compact project labels use+ /// this so a machine's real name stays searchable when the label says "local".+ pub search_extra: bool,pub rows: Vec<Row>,/// (row index, label char indices matched)pub visible: Vec<(usize, Vec<u32>)>,@@ -242,6 +245,7 @@ impl Picker {heading: None,placeholder: placeholder.into(),query: String::new(),+ search_extra: false,rows: Vec::new(),visible: Vec::new(),cursor: 0,@@ -366,7 +370,12 @@ impl Picker {for (index, row) in self.rows.iter().enumerate() {if row.disabled || self.excluded.contains(&row.id) || !offered(row) { continue }let keywords = format!("{} {}", row.label, row.extra);- let chars: Vec<char> = if self.live { steady_line(row, self.text_w, edge) } else { line(row).chars().collect() };+ let mut chars: Vec<char> = if self.live { steady_line(row, self.text_w, edge) } else { line(row).chars().collect() };+ let shown_chars = chars.len();+ if self.search_extra && !row.extra.is_empty() {+ chars.push(' ');+ chars.extend(row.extra.chars());+ }let seen = line(row);let with_keywords = !o.no_extended && q.matches_with_extra(&chars, |word, sensitive, inverse| {let keyword = (word.chars().count() >= 3 || STATE_WORDS.contains(&word)) && names_word(&keywords, word, sensitive);@@ -382,7 +391,7 @@ impl Picker {let mut rank = crate::fzf::rank(&hit, &chars, if self.live { &live_tiebreak } else { &o.tiebreak });// --tac: the input read bottom-up, ties too.rank.push(if o.tac { -(index as i64) } else { index as i64 });- scored.push((rank, index, hit.positions.iter().map(|p| *p as u32).collect()));+ scored.push((rank, index, hit.positions.iter().filter(|p| **p < shown_chars).map(|p| *p as u32).collect()));}// The keywords behind a row (engine, machine, branch): whole words of three// letters or more find it, after everything that matched what you see.diff --git a/tui/tests/mock-daemon.mjs b/tui/tests/mock-daemon.mjsindex 58cc3c154..1b4a2bc57 100644--- a/tui/tests/mock-daemon.mjs+++ b/tui/tests/mock-daemon.mjs@@ -46,6 +46,14 @@ const agents = DEMO ? {[LOCAL]: [agent(randomUUID(), 'Mock Claude', 'claude'), agent(randomUUID(), 'Mock Codex', 'codex'), agent(randomUUID(), 'Mock paused', 'claude', 'stopped')],[REMOTE]: [agent(randomUUID(), 'Remote shell', 'terminal')],}+if (process.env.MOCK_PROJECT_SEARCH === '1') {+ // A large local history must not keep remote folders out of the project picker.+ for (let i = 0; i < 70; i++) {+ agents[LOCAL].push(project(agent(`project-search-${i}`, `Local project ${i}`, 'codex'),+ `autonomous-harness-2026-${String(i).padStart(3, '0')}`, 'main'))+ }+}+// Opt-in viewer fixtures, so the normal terminal roster and its tests keep their identities.if (process.env.MOCK_VIEWER === '1') {agents[LOCAL].push({ ...agent('mock-blender', 'Mock Blender', 'claude'), dsh: 'autonomous/blender',@@ -208,8 +216,8 @@ const server = http.createServer((req, res) => {}if (req.url === '/api/status') return json(res, { machineId: LOCAL, signedIn: true, version: 'mock', webUrl: process.env.MOCK_WEB_URL || 'https://harness.example' })if (req.url === '/api/machines') return json(res, { machines: [- { machineId: LOCAL, name: DEMO ? 'studio' : 'mock-local', status: 'running' },- { machineId: REMOTE, name: DEMO ? 'gpu-box' : 'mock-remote', status: 'running' },+ { machineId: LOCAL, name: process.env.MOCK_PROJECT_SEARCH === '1' ? 'M2' : DEMO ? 'studio' : 'mock-local', status: 'running' },+ { machineId: REMOTE, name: process.env.MOCK_PROJECT_SEARCH === '1' ? 'office' : DEMO ? 'gpu-box' : 'mock-remote', status: 'running' },] })// Harnesses that finish a turn with no window watching: their transcripts change now// (tokenUsage.updatedAt), as the daemon would record (POST /test/finish?n=5).diff --git a/tui/tests/new-harness.py b/tui/tests/new-harness.pyindex 217ab2fcb..2c1256bbf 100644--- a/tui/tests/new-harness.py+++ b/tui/tests/new-harness.py@@ -28,7 +28,8 @@ ENV = {k: os.environ[k] for k in ('PATH', 'LANG', 'LC_ALL', 'TZ', 'NODE_PATH') iENV.update(HOME=str(BASE), HN_TMPDIR=str(BASE), HN_SOCKET_NAME=PREFIX, PORT=str(PORT),RUST_BACKTRACE='1',TERM='xterm-256color', COLORTERM='truecolor', SHELL='/bin/sh', HARNESS_TUI_DESK='sync',- HARNESS_TUI_NOTIFY='off', HN_DESKTOP='off', MOCK_DEMO='1', MOCK_RECONNECT='1', MOCK_NEW_UI='1')+ HARNESS_TUI_NOTIFY='off', HN_DESKTOP='off', MOCK_DEMO='1', MOCK_RECONNECT='1', MOCK_NEW_UI='1',+ MOCK_PROJECT_SEARCH='1')OUTPUT = Path(os.environ['HN_NEW_UI_OUTPUT']) if os.environ.get('HN_NEW_UI_OUTPUT') else Noneif OUTPUT: OUTPUT.mkdir(parents=True, exist_ok=True)@@ -153,6 +154,10 @@ try:before = create_count()input_before = len(state('reconnect')['inputs'])keys('Right'); assert create_count() == before, 'Right on New Harness must not launch'+ field('Project'); type_text('office ml-lab'); keys('Enter'); shows('ml-lab @ office')+ field('Project'); type_text('m2 webapp'); keys('Enter'); shows('webapp @ local')+ assert create_count() == before, 'searching projects across machines only changes the draft'+ print('PASS New Harness: short local machine name and remote folders after a large local history', flush=True)# The chooser opens in the form's place (the panel stays put), once you go into it.keys('Down'); assert 'Search agents and harnesses' not in screen(), 'moving over Agent keeps the form'keys('Tab'); shows('Search agents and harnesses')@@ -160,7 +165,7 @@ try:snapshot('new-harness-agent')type_text('codex'); keys('Escape')shows('Approvals'); field('Agent'); type_text('codex'); keys('Enter')- field('Project'); shows('Clone Repository'); snapshot('new-harness-project')+ field('Project'); shows('Search projects'); snapshot('new-harness-project')type_text('clone'); keys('Enter'); shows('Choose a machine'); keys('Enter'); shows('GitHub URL')raw('\x1b[200~autonomous-ai/openharness\x1b[201~'); keys('Enter')shows('Clone: autonomous-ai/')