the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix: detect truncated codex status rows
Ogulcan Celike8acc76ef6d6
diff --git a/src/detect/agents/codex.rs b/src/detect/agents/codex.rsindex a53d93580..0a9bdadb2 100644--- a/src/detect/agents/codex.rs+++ b/src/detect/agents/codex.rs@@ -135,8 +135,7 @@ fn codex_live_working_line(line: &str) -> bool {let lower = trimmed.to_lowercase();codex_working_status_line(line)&& (trimmed.contains("Waiting for background terminal")- || lower.contains("esc to interrupt")- || lower.contains("esc…")+ || has_codex_status_interrupt_hint(&lower)|| lower.contains("background terminal running")|| lower.contains("/ps to view")|| lower.contains("/stop to close"))@@ -152,12 +151,52 @@ fn codex_working_status_line(line: &str) -> bool {trimmed.starts_with('•')&& (trimmed.contains("Working (")|| trimmed.contains("Waiting for background terminal (")- || lower.contains(" • esc to interrupt")+ || has_codex_status_interrupt_hint(&lower)|| lower.contains("reviewing approval request (")|| (lower.contains("reviewing ") && lower.contains(" approval requests ("))|| trimmed.contains("Booting MCP server:"))}+fn has_codex_status_interrupt_hint(lower_line: &str) -> bool {+ let Some((before_escape, after_escape)) = lower_line.split_once(" • esc") else {+ return false;+ };++ has_codex_status_elapsed(before_escape) && has_codex_status_escape_suffix(after_escape)+}++fn has_codex_status_elapsed(before_escape: &str) -> bool {+ let Some((_, elapsed)) = before_escape.rsplit_once('(') else {+ return false;+ };++ let parts: Vec<&str> = elapsed.split_whitespace().collect();+ (1..=3).contains(&parts.len())+ && parts.iter().all(|part| {+ part.len() >= 2+ && matches!(part.as_bytes().last(), Some(b'h' | b'm' | b's'))+ && part[..part.len() - 1].chars().all(|ch| ch.is_ascii_digit())+ })+}++fn has_codex_status_escape_suffix(after_escape: &str) -> bool {+ let suffix = after_escape.trim_start();+ if suffix.starts_with('…') || suffix.starts_with("to interrupt") {+ return true;+ }++ let Some(rest) = suffix.strip_prefix("to ") else {+ return false;+ };+ if rest.starts_with('…') {+ return true;+ }++ rest.split_once('…')+ .map(|(fragment, _)| !fragment.is_empty() && "interrupt".starts_with(fragment.trim_end()))+ .unwrap_or(false)+}+fn has_codex_current_prompt(content: &str) -> bool {codex_current_prompt_region(content).is_some()}diff --git a/src/detect/mod.rs b/src/detect/mod.rsindex 1e3a2288b..529574f9d 100644--- a/src/detect/mod.rs+++ b/src/detect/mod.rs@@ -1578,6 +1578,38 @@ mod tests {assert!(!detection.visible_idle);}+ #[test]+ fn codex_truncated_status_with_arbitrary_label_is_visible_working() {+ let detection = detect_agent(+ Some(Agent::Codex),+ "• Ran git diff -- src/detect/mod.rs\n └ diff output...\n\n• Considering patch updates (2m 26s • esc …\n\n\n› Fix Codex detection\n\n ~/Projects/herdr · master",+ );++ assert_eq!(detection.state, AgentState::Working);+ assert!(detection.visible_working);+ assert!(!detection.visible_idle);+ }++ #[test]+ fn codex_truncated_status_without_prompt_is_working() {+ assert_eq!(+ detect_codex("• Considering patch updates (2m 26s • esc …"),+ AgentState::Working+ );+ }++ #[test]+ fn codex_bullet_with_esc_text_without_timer_is_not_visible_working() {+ let detection = detect_agent(+ Some(Agent::Codex),+ "• Notes mention esc to interrupt as a phrase\n\n› Fix Codex detection\n\n ~/Projects/herdr · master",+ );++ assert_eq!(detection.state, AgentState::Idle);+ assert!(detection.visible_idle);+ assert!(!detection.visible_working);+ }+#[test]fn codex_background_terminal_status_above_current_prompt_stays_working() {let detection = detect_agent(