From d477341e6af816ff4396042b084a0378ef437b4a Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sat, 30 May 2026 23:54:41 +0300 Subject: refactor: split agent detection by agent Move screen detection into per-agent modules and keep visible-state arbitration centralized in terminal state. Tighten Codex prompt-scoped working detection and Claude hook/screen recovery for stale blocked and idle reports. Add a focused just recipe for single-test runs. refs #349 refs #352 --- src/detect/agents/droid.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/detect/agents/droid.rs (limited to 'src/detect/agents/droid.rs') diff --git a/src/detect/agents/droid.rs b/src/detect/agents/droid.rs new file mode 100644 index 00000000..ea19da3f --- /dev/null +++ b/src/detect/agents/droid.rs @@ -0,0 +1,39 @@ +use super::super::{has_braille_spinner, AgentState}; + +/// Droid detection. +/// +/// Working: braille spinner line (⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏) + "Thinking..." + "(Press ESC to stop)" +/// Blocked: EXECUTE prompt with selection box ("Yes, allow" / "No, cancel") + +/// "Use ↑↓ to navigate, Enter to select" +/// Idle: prompt box visible, no spinner, no selection prompt +pub(super) fn detect(content: &str) -> AgentState { + let lower = content.to_lowercase(); + + // Blocked: EXECUTE approval prompt with selection UI chrome + // Primary (AND): structural keyword + chrome text = certain + let has_execute = content.contains("EXECUTE"); + let has_selection_chrome = lower.contains("enter to select") + || lower.contains("↑↓ to navigate") + || lower.contains("esc to cancel"); + let has_selection_options = lower.contains("> yes, allow") || lower.contains("> no, cancel"); + + if has_execute && (has_selection_chrome || has_selection_options) { + return AgentState::Blocked; + } + // Secondary: selection chrome + options together (no EXECUTE needed) + if has_selection_chrome && has_selection_options { + return AgentState::Blocked; + } + + // Working: braille spinner character at start of a line + "Thinking..." + // The braille chars (⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏) are very specific — won't appear in normal content + if has_braille_spinner(content) && lower.contains("esc to stop") { + return AgentState::Working; + } + // Fallback: "ESC to stop" alone is still a strong signal (it's UI chrome) + if lower.contains("esc to stop") { + return AgentState::Working; + } + + AgentState::Idle +} -- cgit v1.2.3