mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Use the shared composer in the agent command center (#42428)
## What changed - Replace the command center's single-line new-task input with the shared chat composer, including multiline editing, paste handling, Vim mode, configured keybindings, cursor behavior, and input validation. - Keep task drafts and editor state across dashboard refreshes and reconnects while separating composer focus from list, search, and rename actions. - Preserve whitespace in dispatched task prompts, block submission while offline, and restore unsent prompts after dispatch failures when the composer is still available. ## Testing - Add coverage for focus routing, draft retention, multiline pastes, custom keybindings, Vim mode, offline editing, failed-dispatch recovery, and responsive rendering. GitOrigin-RevId: a609ae95d497cbae0ebcac4cdcc50fe49d74832a
This commit is contained in:
1 parent
cac96cd7b1
commit
62f553bfd0
20 files changed
+717
-145
No files matched your search
@@ -199,7 +199,9 @@ async fn disconnected_command_center_keeps_input_and_blocks_actions() -> Result<
|
||||
};
|
||||
let view = app.agents_overview_view(Vec::new(), /*selected_thread_id*/ None);
|
||||
app.chat_widget.show_bottom_pane_view(Box::new(view));
|
||||
app.agents_overview.view_state.lock().unwrap().input = "task draft".into();
|
||||
app.chat_widget.handle_paste("task draft".into());
|
||||
app.chat_widget
|
||||
.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
app.handle_tui_event(
|
||||
&mut tui,
|
||||
@@ -232,7 +234,14 @@ async fn disconnected_command_center_keeps_input_and_blocks_actions() -> Result<
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(
|
||||
app.agents_overview.view_state.lock().unwrap().input,
|
||||
app.agents_overview
|
||||
.view_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.composer
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_text_with_pending(),
|
||||
"task draft!"
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -271,3 +271,28 @@ async fn physical_chords_route_list_and_mixed_request_input_modals() -> Result<(
|
||||
assert!(app.chat_widget.can_launch_external_editor());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn dashboard_chord_hint_survives_refresh_and_clears_on_cancel() -> Result<()> {
|
||||
let mut app = make_test_app().await;
|
||||
app.keymap = RuntimeKeymap::from_config(&toml::from_str(
|
||||
"[editor]\ninsert_newline = [\"ctrl-x n\"]",
|
||||
)?)
|
||||
.unwrap();
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
let view = app.agents_overview_view(Vec::new(), /*selected_thread_id*/ None);
|
||||
app.chat_widget.show_bottom_pane_view(Box::new(view));
|
||||
let before = render_bottom_popup(&app.chat_widget, /*width*/ 80);
|
||||
assert_eq!(app.route_key_chord_event(&mut tui, ctrl('x')), None);
|
||||
let _ = app.agents_overview_view(Vec::new(), /*selected_thread_id*/ None);
|
||||
insta::assert_snapshot!(
|
||||
render_bottom_popup(&app.chat_widget, /*width*/ 80).lines().last().unwrap(),
|
||||
@" ctrl + x … waiting for next key esc cancel"
|
||||
);
|
||||
assert_eq!(
|
||||
app.route_key_chord_event(&mut tui, KeyCode::Esc.into()),
|
||||
None
|
||||
);
|
||||
assert_eq!(render_bottom_popup(&app.chat_widget, /*width*/ 80), before);
|
||||
Ok(())
|
||||
}
|
||||
@@ -139,8 +139,20 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
);
|
||||
app.agents_overview.visible_thread_ids = view.thread_ids();
|
||||
app.chat_widget.show_bottom_pane_view(Box::new(view));
|
||||
app.agents_overview.view_state.lock().unwrap().input = "Keep this task draft".into();
|
||||
if previous_thread.is_some() {
|
||||
app.agents_overview.view_state.lock().unwrap().input = "Keep this task draft".into();
|
||||
} else {
|
||||
app.chat_widget.handle_paste("Keep this task draft".into());
|
||||
}
|
||||
app.agents_overview.view_state.lock().unwrap().renaming = previous_thread.is_some();
|
||||
let draft = |app: &App| {
|
||||
let state = app.agents_overview.view_state.lock().unwrap();
|
||||
if previous_thread.is_some() {
|
||||
state.input.clone()
|
||||
} else {
|
||||
state.composer.as_ref().unwrap().current_text_with_pending()
|
||||
}
|
||||
};
|
||||
let stale_request = Uuid::new_v4();
|
||||
app.agents_overview.request_id = Some(stale_request);
|
||||
app.agents_overview.refresh_pending = true;
|
||||
@@ -262,10 +274,7 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
.await?;
|
||||
app.handle_tui_event(&mut tui, &mut session, TuiEvent::Paste("!".into()))
|
||||
.await?;
|
||||
assert_eq!(
|
||||
app.agents_overview.view_state.lock().unwrap().input,
|
||||
"Keep this task draft!"
|
||||
);
|
||||
assert_eq!(draft(&app), "Keep this task draft!");
|
||||
if previous_thread.is_none() {
|
||||
assert_snapshot!(
|
||||
"daemon_command_center_reconnecting",
|
||||
@@ -335,7 +344,7 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
assert!(!app.agents_overview.visible_thread_ids.contains(&vanished));
|
||||
assert!(app.agents_overview.visible_thread_ids.contains(&added));
|
||||
assert_eq!(
|
||||
app.agents_overview.view_state.lock().unwrap().input,
|
||||
draft(&app),
|
||||
if previous_thread.is_some() {
|
||||
""
|
||||
} else {
|
||||
@@ -386,6 +395,14 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert!(app.chat_widget.has_active_view());
|
||||
app.handle_tui_event(
|
||||
&mut tui,
|
||||
&mut session,
|
||||
TuiEvent::Key(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE)),
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert!(!app.chat_widget.has_active_view());
|
||||
assert_eq!(app.current_displayed_thread_id(), Some(id));
|
||||
let history = drain_history(&mut app, &mut tui, &mut session, &mut events).await?;
|
||||
|
||||
@@ -424,7 +424,9 @@ async fn removing_remote_thread_omits_disconnect_guidance() -> Result<()> {
|
||||
app.chat_widget.handle_thread_session(resumed.session);
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
let archived = matches!(&event, AppEvent::ArchiveCurrentThread);
|
||||
let AppRunControl::Exit(reason) = app.handle_event(&mut tui, &mut server, event).await?
|
||||
// Keep the large dispatcher future off the Windows test thread's stack.
|
||||
let AppRunControl::Exit(reason) =
|
||||
Box::pin(app.handle_event(&mut tui, &mut server, event)).await?
|
||||
else {
|
||||
panic!("removing the current thread must exit");
|
||||
};
|
||||
@@ -1162,14 +1164,15 @@ async fn dynamic_tool_requests_ignore_other_namespaces_and_dispatch_tui_namespac
|
||||
assert_eq!(list_requests[0]["sourceKinds"], serde_json::Value::Null);
|
||||
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
app.handle_event(
|
||||
// Box each dispatcher await so this test does not retain its large future inline.
|
||||
Box::pin(app.handle_event(
|
||||
&mut tui,
|
||||
&mut app_server,
|
||||
AppEvent::DynamicToolCallCompleted {
|
||||
request_id,
|
||||
response,
|
||||
},
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
let completed = tokio::time::timeout(std::time::Duration::from_secs(/*secs*/ 5), async {
|
||||
loop {
|
||||
@@ -1321,7 +1324,7 @@ async fn dynamic_tool_requests_ignore_other_namespaces_and_dispatch_tui_namespac
|
||||
panic!("expected background task registration before its first turn: {registration:?}")
|
||||
};
|
||||
assert!(recorded_params(&requests, "turn/start").is_empty());
|
||||
app.handle_event(
|
||||
Box::pin(app.handle_event(
|
||||
&mut tui,
|
||||
&mut app_server,
|
||||
AppEvent::DynamicToolThreadStarted {
|
||||
@@ -1329,7 +1332,7 @@ async fn dynamic_tool_requests_ignore_other_namespaces_and_dispatch_tui_namespac
|
||||
task_tools_available,
|
||||
registered,
|
||||
},
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
assert!(
|
||||
app.agents_overview
|
||||
@@ -1409,7 +1412,7 @@ async fn dynamic_tool_requests_ignore_other_namespaces_and_dispatch_tui_namespac
|
||||
};
|
||||
assert_eq!(continued_thread_id, creation_source);
|
||||
assert_eq!(recorded_params(&requests, "turn/start").len(), 1);
|
||||
app.handle_event(
|
||||
Box::pin(app.handle_event(
|
||||
&mut tui,
|
||||
&mut app_server,
|
||||
AppEvent::DynamicToolThreadStarted {
|
||||
@@ -1417,7 +1420,7 @@ async fn dynamic_tool_requests_ignore_other_namespaces_and_dispatch_tui_namespac
|
||||
task_tools_available,
|
||||
registered,
|
||||
},
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
let AppEvent::DynamicToolCallCompleted { response, .. } =
|
||||
tokio::time::timeout(std::time::Duration::from_secs(/*secs*/ 5), events.recv())
|
||||
|
||||
+5
-5
@@ -21,8 +21,8 @@ expression: "render_bottom_popup(&app.chat_widget, 100)"
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
New task › task draft!
|
||||
ctrl+c quit · actions paused until the list is refreshed
|
||||
New task
|
||||
|
||||
› task draft!
|
||||
|
||||
esc tasks · dispatch paused
|
||||
+5
-5
@@ -21,8 +21,8 @@ expression: "render_bottom_popup(&app.chat_widget, 100)"
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
New task › Keep this task draft!
|
||||
ctrl+c quit · actions paused until the list is refreshed
|
||||
New task
|
||||
|
||||
› Keep this task draft!
|
||||
|
||||
esc tasks · dispatch paused
|
||||
+5
-5
@@ -21,8 +21,8 @@ expression: "render_bottom_popup(&app.chat_widget, 100)"
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
New task › Keep this task draft!
|
||||
ctrl+c quit · actions paused until the list is refreshed
|
||||
New task
|
||||
|
||||
› Keep this task draft!
|
||||
|
||||
esc tasks · dispatch paused
|
||||
+5
-5
@@ -21,8 +21,8 @@ expression: "render_bottom_popup(&app.chat_widget, 100)"
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
New task › Describe a task and press enter to dispatch it
|
||||
↑↓ navigate ctrl+o resume enter open ctrl+f search ctrl+s group ctrl+r rename ctrl+x stop esc
|
||||
back
|
||||
New task
|
||||
|
||||
› Describe a new task
|
||||
|
||||
enter create task ctrl+j newline esc tasks
|
||||
Reference in new issue
Block a user