mirror of
https://github.com/openai/codex.git
synced 2026-11-05 08:28:29 +00:00
## Why With the local model layer and app-server routing in place from PR1, this PR moves the active TUI runtime onto app-server notifications. The affected pieces share the same event flow, so the command surface, session state, bottom-pane prompts, chat rendering, history/status views, and tests move together to keep the stacked branch buildable. This PR also removes the obsolete compatibility surface that is no longer used after the migration. The proposed protocol-boundary verifier layer was dropped from the stack; enforcing that final boundary will be simpler once `codex-tui` no longer needs any `codex_protocol` references. This PR is part 2 of a 2-PR stack: 1. Add TUI-owned replacement models and extract app-server event routing. 2. Move the active TUI flow to app-server notifications and delete obsolete adapter code. ## What changed - Rewired app command and session handling to use app-server request and notification shapes. - Moved approval overlays, request-user-input flows, MCP elicitation, realtime events, and review commands onto the app-server-facing model surface. - Updated chat rendering, history cells, status views, multi-agent UI, replay state, and TUI tests to use app-server notifications plus the local models introduced in PR1. - Deleted `codex-rs/tui/src/app/app_server_adapter.rs` and the superseded `chatwidget/tests/background_events.rs` fixture path. ## Verification - `cargo check -p codex-tui --tests` - Top of stack: `cargo test -p codex-tui`
140 lines
5.4 KiB
Rust
140 lines
5.4 KiB
Rust
//! Terminal-title focused tests for live chatwidget status-surface behavior.
|
|
|
|
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[tokio::test]
|
|
async fn terminal_title_shows_action_required_while_exec_approval_is_pending() {
|
|
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
chat.bottom_pane.set_task_running(/*running*/ true);
|
|
chat.refresh_terminal_title();
|
|
|
|
let request = ExecApprovalRequestEvent {
|
|
call_id: "call-action-required".into(),
|
|
approval_id: Some("call-action-required".into()),
|
|
turn_id: "turn-action-required".into(),
|
|
command: vec!["bash".into(), "-lc".into(), "echo hello".into()],
|
|
cwd: AbsolutePathBuf::current_dir().expect("current dir"),
|
|
reason: Some("need confirmation".into()),
|
|
network_approval_context: None,
|
|
proposed_execpolicy_amendment: None,
|
|
proposed_network_policy_amendments: None,
|
|
additional_permissions: None,
|
|
available_decisions: None,
|
|
};
|
|
handle_exec_approval_request(&mut chat, "sub-action-required", request);
|
|
|
|
chat.pre_draw_tick();
|
|
|
|
assert_eq!(
|
|
chat.last_terminal_title,
|
|
Some("[ ! ] Action Required | project".to_string())
|
|
);
|
|
assert!(!chat.should_animate_terminal_title_spinner());
|
|
|
|
chat.handle_key_event(KeyEvent::new(KeyCode::Char('y'), KeyModifiers::NONE));
|
|
chat.pre_draw_tick();
|
|
|
|
let title = chat
|
|
.last_terminal_title
|
|
.as_deref()
|
|
.expect("terminal title should be restored after approval");
|
|
assert!(title.contains("project"));
|
|
assert!(!title.contains("Action Required"));
|
|
assert!(chat.should_animate_terminal_title_spinner());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn terminal_title_action_required_respects_spinner_setting() {
|
|
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
chat.config.tui_terminal_title = Some(vec!["project".to_string()]);
|
|
chat.bottom_pane.set_task_running(/*running*/ true);
|
|
chat.refresh_terminal_title();
|
|
|
|
let request = ExecApprovalRequestEvent {
|
|
call_id: "call-no-spinner".into(),
|
|
approval_id: Some("call-no-spinner".into()),
|
|
turn_id: "turn-no-spinner".into(),
|
|
command: vec!["bash".into(), "-lc".into(), "echo hello".into()],
|
|
cwd: AbsolutePathBuf::current_dir().expect("current dir"),
|
|
reason: Some("need confirmation".into()),
|
|
network_approval_context: None,
|
|
proposed_execpolicy_amendment: None,
|
|
proposed_network_policy_amendments: None,
|
|
additional_permissions: None,
|
|
available_decisions: None,
|
|
};
|
|
handle_exec_approval_request(&mut chat, "sub-no-spinner", request);
|
|
|
|
chat.pre_draw_tick();
|
|
|
|
assert_eq!(chat.last_terminal_title, Some("project".to_string()));
|
|
assert!(!chat.should_animate_terminal_title_action_required());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn terminal_title_action_required_blinks_when_animations_are_enabled() {
|
|
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
chat.bottom_pane.set_task_running(/*running*/ true);
|
|
chat.terminal_title_animation_origin = Instant::now() - std::time::Duration::from_millis(1500);
|
|
chat.refresh_terminal_title();
|
|
|
|
let request = ExecApprovalRequestEvent {
|
|
call_id: "call-blink".into(),
|
|
approval_id: Some("call-blink".into()),
|
|
turn_id: "turn-blink".into(),
|
|
command: vec!["bash".into(), "-lc".into(), "echo hello".into()],
|
|
cwd: AbsolutePathBuf::current_dir().expect("current dir"),
|
|
reason: Some("need confirmation".into()),
|
|
network_approval_context: None,
|
|
proposed_execpolicy_amendment: None,
|
|
proposed_network_policy_amendments: None,
|
|
additional_permissions: None,
|
|
available_decisions: None,
|
|
};
|
|
handle_exec_approval_request(&mut chat, "sub-blink", request);
|
|
|
|
chat.pre_draw_tick();
|
|
|
|
assert_eq!(
|
|
chat.last_terminal_title,
|
|
Some("[ . ] Action Required | project".to_string())
|
|
);
|
|
assert!(chat.should_animate_terminal_title_action_required());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn terminal_title_activity_indicators_do_not_animate_when_animations_are_disabled() {
|
|
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
chat.config.animations = false;
|
|
chat.bottom_pane.set_task_running(/*running*/ true);
|
|
chat.terminal_title_animation_origin = Instant::now() - std::time::Duration::from_millis(1500);
|
|
chat.refresh_terminal_title();
|
|
|
|
assert_eq!(chat.last_terminal_title, Some("project".to_string()));
|
|
assert!(!chat.should_animate_terminal_title_spinner());
|
|
|
|
let request = ExecApprovalRequestEvent {
|
|
call_id: "call-no-animations".into(),
|
|
approval_id: Some("call-no-animations".into()),
|
|
turn_id: "turn-no-animations".into(),
|
|
command: vec!["bash".into(), "-lc".into(), "echo hello".into()],
|
|
cwd: AbsolutePathBuf::current_dir().expect("current dir"),
|
|
reason: Some("need confirmation".into()),
|
|
network_approval_context: None,
|
|
proposed_execpolicy_amendment: None,
|
|
proposed_network_policy_amendments: None,
|
|
additional_permissions: None,
|
|
available_decisions: None,
|
|
};
|
|
handle_exec_approval_request(&mut chat, "sub-no-animations", request);
|
|
|
|
chat.pre_draw_tick();
|
|
|
|
assert_eq!(
|
|
chat.last_terminal_title,
|
|
Some("[ ! ] Action Required | project".to_string())
|
|
);
|
|
assert!(!chat.should_animate_terminal_title_action_required());
|
|
}
|