diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-25 03:45:47 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-25 03:45:47 +0300 |
| commit | fba05502cdf235eedc057c3857fdc95e8fbd781d (patch) | |
| tree | 5b9e32b16f3f6138ff821fafb5baa912860e99d2 /src/detect.rs | |
| parent | 0d7f2a01ee97edf89224d5196ffb354d6d96fac1 (diff) | |
fix(opencode): detect question prompt heuristics
Diffstat (limited to 'src/detect.rs')
| -rw-r--r-- | src/detect.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/detect.rs b/src/detect.rs index 4a0b8e7a..d6d48343 100644 --- a/src/detect.rs +++ b/src/detect.rs @@ -284,7 +284,7 @@ fn detect_cline(content: &str) -> AgentState { fn detect_opencode(content: &str) -> AgentState { // Blocked - if content.contains("△ Permission required") { + if content.contains("△ Permission required") || has_opencode_question_prompt(content) { return AgentState::Blocked; } @@ -547,6 +547,16 @@ fn has_cursor_spinner(content: &str) -> bool { false } +fn has_opencode_question_prompt(content: &str) -> bool { + let lower = content.to_lowercase(); + let has_enter_action = lower.contains("enter confirm") + || lower.contains("enter submit") + || lower.contains("enter toggle"); + let has_question_nav = content.contains("↑↓ select") || content.contains("⇆ tab"); + + lower.contains("esc dismiss") && has_enter_action && has_question_nav +} + /// Extract content above Claude's prompt box. /// The prompt box is two ─── border lines with ❯ between them. fn content_above_prompt_box(content: &str) -> &str { @@ -1035,6 +1045,28 @@ mod tests { } #[test] + fn opencode_waiting_question_prompt() { + assert_eq!( + detect_opencode( + "Goal Detail Confirm\n\ + What do you want help with right now?\n\ + 1. Code change\n\ + 5. Type your own answer\n\ + ⇆ tab ↑↓ select enter confirm esc dismiss", + ), + AgentState::Blocked + ); + } + + #[test] + fn opencode_waiting_question_confirm_tab() { + assert_eq!( + detect_opencode("Goal Detail Confirm\nReview\n⇆ tab enter submit esc dismiss"), + AgentState::Blocked + ); + } + + #[test] fn opencode_idle() { assert_eq!(detect_opencode("> "), AgentState::Idle); } |
