Files
codex/codex-rs/protocol/src/request_user_input_tests.rs
Shijie Rao e2c0837923 Make user input blocking behavior explicit (#36410)
## Why

Clients need to know whether a `request_user_input` request must wait for an
explicit response or may auto-resolve. Using `autoResolutionMs` as that signal
conflated the blocking decision with timeout policy.

## What changed

- Add required `isBlocking` fields to user input protocol and app-server
  request payloads. Plan-mode requests are blocking, while requests from other
  enabled modes are non-blocking.
- Drive the TUI's auto-resolution behavior from `isBlocking` and remove
  `autoResolutionMs` from the model-facing tool schema.
- Deprecate `autoResolutionMs` while retaining it for compatibility, and treat
  legacy payloads without `isBlocking` as blocking.

## Testing

- Cover mode-derived blocking behavior, legacy deserialization, app-server
  forwarding, delegated requests, and TUI auto-resolution.

GitOrigin-RevId: 29aade657ef743065ec264376ba567a9b353d7d7
2026-08-01 00:38:10 +00:00

45 lines
1.3 KiB
Rust

use super::*;
use pretty_assertions::assert_eq;
use serde_json::json;
#[test]
fn request_user_input_event_defaults_legacy_missing_is_blocking_to_true() {
let event: RequestUserInputEvent = serde_json::from_value(json!({
"call_id": "call-1",
"turn_id": "turn-1",
"questions": [{
"id": "q1",
"header": "Confirm",
"question": "Continue?",
"options": [{
"label": "Yes",
"description": "Continue."
}]
}],
"autoResolutionMs": 60_000
}))
.expect("legacy request_user_input event should deserialize");
assert_eq!(
event,
RequestUserInputEvent {
call_id: "call-1".to_string(),
turn_id: "turn-1".to_string(),
questions: vec![RequestUserInputQuestion {
id: "q1".to_string(),
header: "Confirm".to_string(),
question: "Continue?".to_string(),
is_other: false,
is_secret: false,
options: Some(vec![RequestUserInputQuestionOption {
label: "Yes".to_string(),
description: "Continue.".to_string(),
}]),
}],
is_blocking: true,
auto_resolution_ms: Some(60_000),
}
);
}