Lightweight coding agent that runs in your terminal
Rust
Use readable plugin mentions without suppressing same-name skills (#51865)
canvrno-oai746103b592a3
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rsindex c919e31c92..7a36cd9959 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs@@ -6873,7 +6873,7 @@ mod tests {}}- fn test_plugin_summary(name: &str, description: &str) -> PluginCapabilitySummary {+ pub(super) fn test_plugin_summary(name: &str, description: &str) -> PluginCapabilitySummary {PluginCapabilitySummary {config_name: format!("{name}@test"),display_name: name.to_string(),diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/snapshot_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/snapshot_tests.rsindex 2a22f909a2..f15a360a2a 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/snapshot_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/snapshot_tests.rs@@ -1,17 +1,50 @@-//! Snapshot coverage for draft text, shortcuts, and live voice controls in the composer.+//! Snapshot coverage for draft text, plugin mentions, shortcuts, and live voice controls.use super::tests::new_test_composer;use super::tests::snapshot_composer_state_with_width;+use super::tests::test_plugin_summary;+use crate::bottom_pane::MentionBinding;use crate::bottom_pane::footer::FooterMode;use crate::key_hint;use crate::key_hint::ShortcutHint;use crate::keymap::RuntimeKeymap;use crate::render::renderable::Renderable;+use codex_plugin::PluginCapabilitySummary;use crossterm::event::KeyCode;+use crossterm::event::KeyEvent;+use crossterm::event::KeyModifiers;use pretty_assertions::assert_eq;use ratatui::buffer::Buffer;use ratatui::layout::Rect;+#[test]+fn plugin_mention_uses_display_name_for_opaque_id() {+ snapshot_composer_state_with_width(+ "plugin_mention_uses_display_name_for_opaque_id",+ /*width*/ 100,+ /*enhanced_keys_supported*/ false,+ |composer| {+ let plugin_name = "app-6a6b12e06c5c8191ac5d5252fa5f92c8";+ composer.set_mentions_v2_enabled(/*enabled*/ true);+ composer.set_plugin_mentions(Some(vec![PluginCapabilitySummary {+ display_name: "Postman".to_string(),+ ..test_plugin_summary(plugin_name, "")+ }]));+ composer.set_text_content("@Postm".to_string(), Vec::new(), Vec::new());+ composer.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));++ assert_eq!(+ composer.mention_bindings(),+ vec![MentionBinding {+ sigil: '@',+ mention: "Postman".to_string(),+ path: format!("plugin://{plugin_name}@test"),+ }]+ );+ },+ );+}+#[test]fn shortcut_footer_displays_configured_chords() {use codex_config::types::KeybindingSpec;diff --git a/codex-rs/tui/src/bottom_pane/mentions_v2/search_catalog.rs b/codex-rs/tui/src/bottom_pane/mentions_v2/search_catalog.rsindex 113f59ac0b..3b9fa6686d 100644--- a/codex-rs/tui/src/bottom_pane/mentions_v2/search_catalog.rs+++ b/codex-rs/tui/src/bottom_pane/mentions_v2/search_catalog.rs@@ -132,6 +132,21 @@ fn plugin_mention_name(plugin_name: &str, display_name: &str) -> String {return result;}+ // Generated app IDs have no useful words to title-case; use a bounded mention label instead.+ if let Some(app_id) = plugin_name.strip_prefix("app-")+ && app_id.len() == 32+ && app_id+ .bytes()+ .all(|byte| matches!(byte, b'0'..=b'9' | b'a'..=b'f'))+ && (1..=64).contains(&display_name.len())+ && display_name+ .bytes()+ .all(crate::mention_codec::is_mention_name_char)+ && !crate::mention_codec::is_common_env_var(display_name)+ {+ return display_name.to_owned();+ }+title_case_plugin_name(plugin_name)}@@ -242,6 +257,34 @@ mod tests {plugin_mention_name("google_calendar", "Google Calendar"),"Google_Calendar");+ assert_eq!(+ plugin_mention_name(+ "app-6a6b12e06c5c8191ac5d5252fa5f92c8",+ "app_6a6b12e06c5c8191ac5d5252fa5f92c8"+ ),+ "app-6a6b12e06c5c8191ac5d5252fa5f92c8"+ );+ }++ #[test]+ fn generated_app_mentions_use_bounded_display_names() {+ let plugin_name = "app-6a6b12e06c5c8191ac5d5252fa5f92c8";+ for display_name in ["Postman", "foo-bar_baz", &"a".repeat(64)] {+ assert_eq!(plugin_mention_name(plugin_name, display_name), display_name);+ }+ for display_name in [+ "",+ "Foo Bar",+ "Café",+ "PATH",+ "XDG_CONFIG_HOME",+ &"a".repeat(65),+ ] {+ assert_eq!(+ plugin_mention_name(plugin_name, display_name),+ "App-6a6b12e06c5c8191ac5d5252fa5f92c8"+ );+ }}#[test]@@ -251,5 +294,19 @@ mod tests {plugin_mention_name("browser-use", "Browser Use"),"Browser-Use");+ for (plugin_name, expected) in [+ ("1vault", "1vault"),+ ("app-short", "App-Short"),+ (+ "app-6a6b12e06c5c8191ac5d5252fa5f92cg",+ "App-6a6b12e06c5c8191ac5d5252fa5f92cg",+ ),+ (+ "app-6A6B12E06C5C8191AC5D5252FA5F92C8",+ "App-6A6B12E06C5C8191AC5D5252FA5F92C8",+ ),+ ] {+ assert_eq!(plugin_mention_name(plugin_name, "Vault"), expected);+ }}}diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__plugin_mention_uses_display_name_for_opaque_id.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__plugin_mention_uses_display_name_for_opaque_id.snapnew file mode 100644index 0000000000..72b578ddce--- /dev/null+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__plugin_mention_uses_display_name_for_opaque_id.snap@@ -0,0 +1,13 @@+---+source: tui/src/bottom_pane/chat_composer.rs+expression: terminal.backend()+---+" "+"› @Postman "+" "+" "+" "+" "+" "+" "+" 100% context left "diff --git a/codex-rs/tui/src/chatwidget/input_submission.rs b/codex-rs/tui/src/chatwidget/input_submission.rsindex e20aaa3a70..9998e77583 100644--- a/codex-rs/tui/src/chatwidget/input_submission.rs+++ b/codex-rs/tui/src/chatwidget/input_submission.rs@@ -289,6 +289,7 @@ impl ChatWidget {collect_tool_mentions(reply_text.as_deref().unwrap_or(&text), &HashMap::new());let bound_names: HashSet<String> = mention_bindings.iter()+ .filter(|binding| binding.sigil == '$').map(|binding| binding.mention.clone()).collect();let mut skill_names_lower: HashSet<String> = HashSet::new();diff --git a/codex-rs/tui/src/chatwidget/tests/composer_submission.rs b/codex-rs/tui/src/chatwidget/tests/composer_submission.rsindex 6bc5164c3b..491c96f2d1 100644--- a/codex-rs/tui/src/chatwidget/tests/composer_submission.rs+++ b/codex-rs/tui/src/chatwidget/tests/composer_submission.rs@@ -1011,6 +1011,68 @@ async fn submission_prefers_selected_duplicate_skill_path() {assert_eq!(selected_skill_paths, vec![user_skill_path.to_path_buf()]);}+#[tokio::test]+async fn plugin_mention_does_not_suppress_same_name_skill() {+ let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;+ chat.thread_id = Some(ThreadId::new());+ chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);+ chat.bottom_pane+ .set_plugin_mentions(Some(vec![PluginCapabilitySummary {+ config_name: "app-0123456789abcdef0123456789abcdef@test".to_string(),+ display_name: "foo".to_string(),+ plugin_namespace: None,+ description: None,+ has_skills: true,+ mcp_server_names: Vec::new(),+ app_connector_ids: Vec::new(),+ }]));+ let skill_path = test_path_buf("/tmp/foo/SKILL.md").abs();+ chat.set_skills(Some(vec![SkillMetadata {+ name: "foo".to_string(),+ description: "Foo skill".to_string(),+ short_description: None,+ interface: None,+ dependencies: None,+ path: skill_path.clone(),+ scope: crate::test_support::skill_scope_user(),+ enabled: true,+ plugin_id: None,+ }]));++ chat.submit_user_message(UserMessage {+ text: "@foo $foo".to_string(),+ local_images: Vec::new(),+ remote_image_urls: Vec::new(),+ text_elements: Vec::new(),+ mention_bindings: vec![MentionBinding {+ sigil: '@',+ mention: "foo".to_string(),+ path: "plugin://app-0123456789abcdef0123456789abcdef@test".to_string(),+ }],+ });++ let Op::UserTurn { items, .. } = next_submit_op(&mut op_rx) else {+ panic!("expected Op::UserTurn");+ };+ assert_eq!(+ items,+ vec![+ UserInput::Text {+ text: "@foo $foo".to_string(),+ text_elements: Vec::new(),+ },+ UserInput::Skill {+ name: "foo".to_string(),+ path: skill_path.to_path_buf(),+ },+ UserInput::Mention {+ name: "foo".to_string(),+ path: "plugin://app-0123456789abcdef0123456789abcdef@test".to_string(),+ },+ ]+ );+}+#[tokio::test]async fn blocked_image_restore_preserves_mention_bindings() {let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;