mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Add slash command argument completion to the TUI composer (#62343)
## Why The slash command menu helps users find commands, but leaves them to recall fixed arguments such as `on` and `off` for `/raw`. ## What changed Show prefix-filtered suggestions for the first argument of supported slash commands. For example, type `/mcp lo` and press `Tab` to complete `/mcp login`. `Enter` and configured submit shortcuts still submit the draft as typed. Give mention completion priority and limit argument suggestions to commands available in the current thread and connection state. ## Testing Add tests for popup rendering, argument replacement, submit shortcuts, and changes in thread availability and connection state. GitOrigin-RevId: 8682c323064457dd9307b0a1520469011a8df9f3
This commit is contained in:
committed by
copyberry
parent
71527c18c7
commit
42cf4edfcd
@@ -302,6 +302,24 @@ async fn completed_global_chords_toggle_output_and_request_external_editor() ->
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn composer_submit_chord_works_with_slash_argument_popup() -> Result<()> {
|
||||
let (mut app, mut tui, mut app_server) = chord_app().await?;
|
||||
let config = toml::from_str("[composer]\nsubmit = 'ctrl-x enter'")?;
|
||||
app.keymap = RuntimeKeymap::from_config(&config).expect("valid composer submit chord");
|
||||
app.chat_widget.apply_keymap_update(config, &app.keymap);
|
||||
app.chat_widget.set_raw_output_mode(/*enabled*/ true);
|
||||
app.chat_widget.apply_external_edit("/raw off".to_owned());
|
||||
assert!(!app.chat_widget.no_modal_or_popup_active());
|
||||
|
||||
press(&mut app, &mut tui, &mut app_server, ctrl('x')).await?;
|
||||
assert!(app.key_chord_matcher.is_pending());
|
||||
assert!(app.chat_widget.raw_output_mode());
|
||||
press(&mut app, &mut tui, &mut app_server, KeyCode::Enter.into()).await?;
|
||||
assert!(!app.chat_widget.raw_output_mode());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn wrong_second_stroke_passes_through_but_escape_is_consumed() -> Result<()> {
|
||||
let (mut app, mut tui, mut app_server) = chord_app().await?;
|
||||
|
||||
@@ -254,3 +254,43 @@ async fn unavailable_thread_new_and_clear_start_a_writable_session() -> Result<(
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn argument_popup_tracks_thread_availability_before_the_next_key() -> Result<()> {
|
||||
let (mut app, _events, _ops) = make_test_app_with_channels().await;
|
||||
let id = ThreadId::new();
|
||||
app.active_thread_id = Some(id);
|
||||
app.primary_thread_id = Some(id);
|
||||
app.app_server_target = AppServerTarget::Remote {
|
||||
endpoint: crate::resolve_remote_addr("ws://127.0.0.1:1")?,
|
||||
};
|
||||
app.chat_widget
|
||||
.handle_thread_session(test_thread_session(id, app.config.cwd.to_path_buf()));
|
||||
app.ensure_thread_channel(id).mark_live();
|
||||
app.chat_widget
|
||||
.restore_user_message_to_composer("/mcp ".into());
|
||||
assert!(!app.chat_widget.no_modal_or_popup_active());
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
let size = tui.terminal.last_known_screen_size;
|
||||
|
||||
app.ensure_thread_channel(id).mark_replay_only();
|
||||
app.handle_draw_pre_render(&mut tui, size)?;
|
||||
app.chat_widget.pre_draw_tick();
|
||||
assert!(app.chat_widget.no_modal_or_popup_active());
|
||||
|
||||
app.ensure_thread_channel(id).mark_live();
|
||||
app.handle_draw_pre_render(&mut tui, size)?;
|
||||
app.chat_widget.pre_draw_tick();
|
||||
assert!(!app.chat_widget.no_modal_or_popup_active());
|
||||
|
||||
app.reconnect.offline = true;
|
||||
app.handle_draw_pre_render(&mut tui, size)?;
|
||||
app.chat_widget.pre_draw_tick();
|
||||
assert!(app.chat_widget.no_modal_or_popup_active());
|
||||
|
||||
app.reconnect.offline = false;
|
||||
app.handle_draw_pre_render(&mut tui, size)?;
|
||||
app.chat_widget.pre_draw_tick();
|
||||
assert!(!app.chat_widget.no_modal_or_popup_active());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user