fix(opencode): detect question prompt heuristics

This commit is contained in:
Ogulcan Celik
2026-04-25 03:45:47 +03:00
parent 0d7f2a01ee
commit fba05502cd
+33 -1
View File
@@ -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 {
@@ -1034,6 +1044,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);