Open the agents overview from an empty composer (#41917)

## What changed

- Open the agents overview with Left from an empty, focused composer in local-daemon sessions.
- Keep the shortcut inactive while editing text, using transient input surfaces, or when Left has been explicitly remapped.
- Show the contextual shortcut in the footer and shortcuts overlay.
- Leave the configurable `open_agents` action unbound by default instead of assigning `Alt+A`.

## Testing

- Add coverage for session eligibility, input-state guards, editor and Vim remaps, event dispatch, and footer rendering.

GitOrigin-RevId: ef17db3d9d09c3a08c3f7353c5b8a02f2b61c696
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-31 21:53:02 +00:00
1 parent 907c34e867
commit 0a2e2bf957
23 files changed
+335 -71

No files matched your search

@@ -0,0 +1,29 @@
//! Availability of the empty-prompt agents shortcut and its footer hint.
//!
//! Only local-daemon sessions enable this shortcut. Draft contents, transient input surfaces,
//! and explicit editor remaps take precedence over navigation.
use super::*;
impl ChatComposer {
pub(crate) fn set_agents_navigation_enabled(&mut self, enabled: bool) {
self.agents_navigation_enabled = enabled;
}
pub(super) fn agents_navigation_available(&self) -> bool {
let move_left = if self.draft.textarea.is_vim_normal_mode() {
&self.vim_normal_keymap.move_left
} else {
&self.editor_keymap.move_left
};
self.agents_navigation_enabled
&& move_left.is_pressed(KeyCode::Left.into())
&& self.has_focus
&& self.draft.input_enabled
&& self.slash_commands_enabled()
&& self.is_empty()
&& !self.is_in_paste_burst()
&& !self.popup_active()
&& !self.draft.textarea.is_vim_operator_pending()
}
}
@@ -0,0 +1,108 @@
use super::tests::new_test_composer;
use super::tests::snapshot_composer_state_with_width;
use super::*;
use assert_matches::assert_matches;
use pretty_assertions::assert_eq;
#[test]
fn left_navigates_only_from_an_empty_prompt() {
let (mut composer, mut events) = new_test_composer();
composer.set_agents_navigation_enabled(/*enabled*/ true);
composer.insert_str("ab");
composer.handle_key_event(KeyCode::Left.into());
composer.insert_str("!");
assert_eq!(composer.current_text(), "a!b");
assert!(events.try_recv().is_err());
composer.clear_for_ctrl_c();
for kind in [KeyEventKind::Repeat, KeyEventKind::Release] {
composer.handle_key_event(KeyEvent::new_with_kind(
KeyCode::Left,
KeyModifiers::NONE,
kind,
));
}
assert!(events.try_recv().is_err());
composer.handle_key_event(KeyCode::Left.into());
assert_matches!(events.try_recv(), Ok(AppEvent::OpenAgentsOverview));
}
#[test]
fn left_respects_attachments_pastes_and_other_input_surfaces() {
let setups: [fn(&mut ChatComposer); 4] = [
|composer| composer.config = ChatComposerConfig::plain_text(),
|composer| composer.set_remote_image_urls(vec!["https://example.com/image.png".into()]),
|composer| {
composer.handle_key_event(KeyCode::Char('x').into());
},
|composer| {
composer.handle_key_event(KeyEvent::new(KeyCode::Char('r'), KeyModifiers::CONTROL));
},
];
for setup in setups {
let (mut composer, mut events) = new_test_composer();
composer.set_agents_navigation_enabled(/*enabled*/ true);
setup(&mut composer);
composer.handle_key_event(KeyCode::Left.into());
assert!(
!std::iter::from_fn(|| events.try_recv().ok())
.any(|event| matches!(event, AppEvent::OpenAgentsOverview))
);
}
}
#[test]
fn agents_navigation_hint_snapshots() {
for name in [
"agents_navigation_enabled",
"agents_navigation_help",
"agents_navigation_status",
] {
snapshot_composer_state_with_width(
name,
/*width*/ 80,
/*enhanced_keys_supported*/ false,
|composer| {
composer.set_agents_navigation_enabled(/*enabled*/ true);
match name {
"agents_navigation_help" => {
composer.handle_key_event(KeyCode::Char('?').into());
}
"agents_navigation_status" => {
composer.set_status_line_enabled(/*enabled*/ true);
composer.set_status_line(Some(Line::from("model · project")));
}
_ => {}
}
},
);
}
}
#[test]
fn left_respects_editor_and_vim_history_remaps() {
use codex_config::types::KeybindingSpec;
use codex_config::types::KeybindingsSpec;
use codex_config::types::TuiKeymap;
for vim in [false, true] {
let (mut composer, mut events) = new_test_composer();
composer.set_agents_navigation_enabled(/*enabled*/ true);
composer.insert_str("previous");
composer.handle_key_event(KeyCode::Enter.into());
let mut config = TuiKeymap::default();
if vim {
config.vim_normal.move_left = Some(KeybindingsSpec::One(KeybindingSpec("h".into())));
config.vim_normal.move_up = Some(KeybindingsSpec::One(KeybindingSpec("left".into())));
} else {
config.editor.move_left = Some(KeybindingsSpec::One(KeybindingSpec("ctrl-b".into())));
config.editor.move_up = Some(KeybindingsSpec::One(KeybindingSpec("left".into())));
}
composer.set_keymap_bindings(&RuntimeKeymap::from_config(&config).unwrap());
composer.set_vim_enabled(vim);
assert!(composer.footer_props().key_hints.agents.is_none());
composer.handle_key_event(KeyCode::Left.into());
assert_eq!(composer.current_text(), "previous");
assert!(events.try_recv().is_err());
}
}
@@ -211,7 +211,7 @@ impl ChatComposer {
&mut self,
key_event: KeyEvent,
) -> (InputResult, bool) {
if self.handle_shortcut_overlay_key(&key_event) {
if self.handle_empty_prompt_shortcut(&key_event) {
return (InputResult::None, true);
}
if key_event.code == KeyCode::Esc {