Compare commits

...

1 Commits

Author SHA1 Message Date
Ahmed Ibrahim
9a057c56c0 TUI: mark running state on submit 2026-01-27 12:12:20 -08:00
2 changed files with 47 additions and 0 deletions

View File

@@ -680,6 +680,16 @@ impl ChatWidget {
.set_task_running(self.agent_turn_running || self.mcp_startup_status.is_some());
}
fn set_running_optimistically(&mut self) {
if self.agent_turn_running {
return;
}
self.agent_turn_running = true;
self.update_task_running_state();
self.bottom_pane.set_interrupt_hint_visible(true);
self.request_redraw();
}
fn restore_reasoning_status_header(&mut self) {
if let Some(header) = extract_first_bold(&self.reasoning_buffer) {
self.set_status_header(header);
@@ -2443,6 +2453,7 @@ impl ChatWidget {
self.reasoning_buffer.clear();
self.full_reasoning_buffer.clear();
self.set_status_header(String::from("Working"));
self.set_running_optimistically();
self.submit_user_message(user_message);
} else {
self.queue_user_message(user_message);

View File

@@ -320,6 +320,42 @@ async fn submission_preserves_text_elements_and_local_images() {
assert_eq!(stored_images, local_images);
}
#[tokio::test]
async fn submitted_sets_task_running_before_turn_started() {
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(None).await;
let conversation_id = ThreadId::new();
let rollout_file = NamedTempFile::new().unwrap();
let configured = codex_core::protocol::SessionConfiguredEvent {
session_id: conversation_id,
forked_from_id: None,
model: "test-model".to_string(),
model_provider_id: "test-provider".to_string(),
approval_policy: AskForApproval::Never,
sandbox_policy: SandboxPolicy::ReadOnly,
cwd: PathBuf::from("/home/user/project"),
reasoning_effort: Some(ReasoningEffortConfig::default()),
history_log_id: 0,
history_entry_count: 0,
initial_messages: None,
rollout_path: Some(rollout_file.path().to_path_buf()),
};
chat.handle_codex_event(Event {
id: "initial".into(),
msg: EventMsg::SessionConfigured(configured),
});
drain_insert_history(&mut rx);
chat.bottom_pane
.set_composer_text("hello".to_string(), Vec::new(), Vec::new());
assert!(!chat.bottom_pane.is_task_running());
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
let _ = next_submit_op(&mut op_rx);
assert!(chat.bottom_pane.is_task_running());
}
#[tokio::test]
async fn interrupted_turn_restores_queued_messages_with_images_and_elements() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;