The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
feat: keep ecc2 lead selected after multi-spawn
Affaan Mustafa92c9d1f2c9c4
diff --git a/ecc2/src/tui/dashboard.rs b/ecc2/src/tui/dashboard.rsindex 63cb7133b..cb55d98f9 100644--- a/ecc2/src/tui/dashboard.rs+++ b/ecc2/src/tui/dashboard.rs@@ -1981,7 +1981,9 @@ impl Dashboard {{Ok(session_id) => session_id,Err(error) => {- self.refresh_after_spawn(created_ids.first().map(String::as_str));+ let preferred_selection =+ post_spawn_selection_id(source_session_id.as_deref(), &created_ids);+ self.refresh_after_spawn(preferred_selection.as_deref());let mut summary = if created_ids.is_empty() {format!("spawn failed: {error}")} else {@@ -2026,7 +2028,9 @@ impl Dashboard {created_ids.push(session_id);}- self.refresh_after_spawn(created_ids.first().map(String::as_str));+ let preferred_selection =+ post_spawn_selection_id(source_session_id.as_deref(), &created_ids);+ self.refresh_after_spawn(preferred_selection.as_deref());let mut note = build_spawn_note(&plan, created_ids.len());if let Some(layout_note) = self.auto_split_layout_after_spawn(created_ids.len()) {note.push_str(" | ");@@ -3526,6 +3530,19 @@ fn build_spawn_note(plan: &SpawnPlan, created_count: usize) -> String {}}+fn post_spawn_selection_id(+ source_session_id: Option<&str>,+ created_ids: &[String],+) -> Option<String> {+ if created_ids.len() > 1 {+ source_session_id+ .map(ToOwned::to_owned)+ .or_else(|| created_ids.first().cloned())+ } else {+ created_ids.first().cloned()+ }+}+fn looks_like_file_change(text: &str) -> bool {let lower = text.trim().to_ascii_lowercase();if lower.is_empty() {@@ -6527,6 +6544,31 @@ diff --git a/src/next.rs b/src/next.rs);}+ #[test]+ fn post_spawn_selection_prefers_lead_for_multi_spawn() {+ let preferred = post_spawn_selection_id(+ Some("lead-12345678"),+ &["child-a".to_string(), "child-b".to_string()],+ );++ assert_eq!(preferred.as_deref(), Some("lead-12345678"));+ }++ #[test]+ fn post_spawn_selection_keeps_single_spawn_on_created_session() {+ let preferred = post_spawn_selection_id(Some("lead-12345678"), &["child-a".to_string()]);++ assert_eq!(preferred.as_deref(), Some("child-a"));+ }++ #[test]+ fn post_spawn_selection_falls_back_to_first_created_when_no_lead_exists() {+ let preferred =+ post_spawn_selection_id(None, &["child-a".to_string(), "child-b".to_string()]);++ assert_eq!(preferred.as_deref(), Some("child-a"));+ }+#[test]fn toggle_theme_persists_config() {let mut dashboard = test_dashboard(Vec::new(), 0);