Deduplicate plugin skills in unified mentions (#40501)

## Why

Unified `@` search could show a plugin alongside the skills it owns, creating duplicate entry points for the same capability.

## What changed

- Add a nullable `pluginId` to `SkillMetadata` returned by `skills/list` so clients can associate skills with their owning plugin without inspecting names or paths.
- Hide a plugin's owned skills from unified `@` results when that plugin is present, while retaining standalone skills and skills with unknown ownership.
- Keep `$` focused on individual skills and apps, and use it consistently as the skills-list shortcut. Preserve the legacy mention behavior when `mentions_v2` is disabled.

## Testing

- Cover plugin ownership in `skills/list` and the updated `@` and `$` composer results.

GitOrigin-RevId: e168cdff8d0c58f74ce4c228a683880a3167775b
This commit is contained in:
victor-openai authored and copyberry committed 2026-08-25 00:15:49 +00:00
1 parent 465eafacbc
commit 5918c743f3
18 files changed
+121 -25

No files matched your search

+56 -3
View File
@@ -9,6 +9,12 @@
//! - Turning raw key streams into explicit paste operations on platforms where terminals
//! don't provide reliable bracketed paste (notably Windows).
//!
//! # Mention Menus
//!
//! By default, `@` lists plugins, filesystem entries, and skills. Skills are hidden when their
//! owning plugin is listed. `$` lists individual skills and apps, but not plugins.
//! Disabling `mentions_v2` restores file-only `@` search and adds plugins back to `$`.
//!
//! # Key Event Routing
//!
//! Most key handling goes through [`ChatComposer::handle_key_event`], which dispatches to a
@@ -4207,7 +4213,9 @@ impl ChatComposer {
}
}
if let Some(plugins) = self.plugins.as_ref() {
if !self.mentions_v2_enabled
&& let Some(plugins) = self.plugins.as_ref()
{
for plugin in plugins {
let (plugin_name, marketplace_name) = plugin
.config_name
@@ -6855,6 +6863,7 @@ mod tests {
path: test_path_buf(&format!("/tmp/{name}/SKILL.md")).abs(),
scope: crate::test_support::skill_scope_user(),
enabled: true,
plugin_id: None,
}
}
@@ -7506,6 +7515,7 @@ mod tests {
path: skill_path.clone(),
scope: crate::test_support::skill_scope_user(),
enabled: true,
plugin_id: None,
}]));
let ActivePopup::Skill(popup) = &composer.popups.active else {
@@ -7519,7 +7529,7 @@ mod tests {
}
#[test]
fn mention_items_show_plugin_owned_skill_and_app_duplicates() {
fn mention_items_keep_direct_skills_and_apps_with_unified_mentions() {
let skill_path = test_path_buf("/tmp/repo/google-calendar/SKILL.md").abs();
let (tx, _rx) = unbounded_channel::<AppEvent>();
let sender = AppEventSender::new(tx);
@@ -7550,6 +7560,7 @@ mod tests {
path: skill_path.clone(),
scope: crate::test_support::skill_scope_repo(),
enabled: true,
plugin_id: Some("google-calendar@debug".to_string()),
}]));
composer.set_plugin_mentions(Some(vec![PluginCapabilitySummary {
config_name: "google-calendar@debug".to_string(),
@@ -7595,6 +7606,25 @@ mod tests {
);
assert_eq!(mentions[2].category_tag, Some("[App]".to_string()));
assert_eq!(mentions[2].path, Some("app://google_calendar".to_string()));
composer.set_mentions_v2_enabled(/*enabled*/ true);
assert_eq!(
composer
.mention_items()
.into_iter()
.map(|mention| (mention.insert_text, mention.path))
.collect::<Vec<_>>(),
vec![
(
"$google-calendar:availability".to_string(),
Some(skill_path.display().to_string()),
),
(
"$google-calendar".to_string(),
Some("app://google_calendar".to_string()),
),
],
);
}
#[test]
@@ -7629,11 +7659,32 @@ mod tests {
let features = codex_features::Features::with_defaults();
composer
.set_mentions_v2_enabled(features.enabled(codex_features::Feature::MentionsV2));
composer.set_skill_mentions(Some(vec![
SkillMetadata {
name: "sample-tools:search".to_string(),
plugin_id: Some("sample@test".to_string()),
..test_skill_metadata("sample-search")
},
SkillMetadata {
name: "sample:summarize".to_string(),
plugin_id: Some("sample@test".to_string()),
..test_skill_metadata("sample-summarize")
},
SkillMetadata {
name: "sample:notes".to_string(),
..test_skill_metadata("sample-notes")
},
SkillMetadata {
name: "sample:other".to_string(),
plugin_id: Some("sample@other-marketplace".to_string()),
..test_skill_metadata("sample-other")
},
]));
composer.set_text_content("@sa".to_string(), Vec::new(), Vec::new());
composer.set_plugin_mentions(Some(vec![PluginCapabilitySummary {
config_name: "sample@test".to_string(),
display_name: "Sample Plugin".to_string(),
plugin_namespace: None,
plugin_namespace: Some("sample".to_string()),
description: Some("Plugin with skills and an MCP server".to_string()),
has_skills: true,
mcp_server_names: vec!["sample".to_string()],
@@ -7823,6 +7874,7 @@ mod tests {
/*width*/ 72,
/*enhanced_keys_supported*/ false,
|composer| {
composer.set_mentions_v2_enabled(/*enabled*/ true);
composer.set_connectors_enabled(/*enabled*/ true);
composer.set_text_content("$goog".to_string(), Vec::new(), Vec::new());
composer.set_skill_mentions(Some(vec![SkillMetadata {
@@ -7843,6 +7895,7 @@ mod tests {
path: test_path_buf("/tmp/repo/google-calendar/SKILL.md").abs(),
scope: crate::test_support::skill_scope_repo(),
enabled: true,
plugin_id: None,
}]));
composer.set_plugin_mentions(Some(vec![PluginCapabilitySummary {
config_name: "google-calendar@debug".to_string(),
@@ -1,3 +1,5 @@
use std::collections::HashSet;
use codex_app_server_protocol::SkillMetadata;
use codex_plugin::PluginCapabilitySummary;
@@ -15,9 +17,25 @@ pub(crate) fn build_search_catalog(
plugins: Option<&[PluginCapabilitySummary]>,
tasks: &[TaskMention],
) -> Vec<Candidate> {
let plugin_ids: HashSet<_> = plugins
.into_iter()
.flatten()
.map(|plugin| plugin.config_name.as_str())
.collect();
let mut candidates = Vec::new();
if let Some(skills) = skills {
candidates.extend(skills.iter().map(skill_candidate));
// Keep skills visible when older servers omit plugin ownership.
candidates.extend(
skills
.iter()
.filter(|skill| {
!skill
.plugin_id
.as_deref()
.is_some_and(|plugin_id| plugin_ids.contains(plugin_id))
})
.map(skill_candidate),
);
}
if let Some(plugins) = plugins {
+1
View File
@@ -2782,6 +2782,7 @@ mod tests {
path: test_path_buf("/tmp/test-skill/SKILL.md").abs(),
scope: crate::test_support::skill_scope_user(),
enabled: true,
plugin_id: None,
}]),
});
@@ -6,8 +6,8 @@ expression: terminal.backend()
"› @sa "
" "
" "
" "
" "
"> Sample Plugin Plugin with skills and an MCP server Plugin"
"> Sample Plugin Plugin with skills and an MCP server Plugin"
" other (sample) Example skill used in tests. Skill "
" notes (sample) Example skill used in tests. Skill "
" "
" enter insert · esc close · ←/→ switch search modes [All Results] Filesystem Only Plugins "
@@ -6,7 +6,7 @@ expression: terminal.backend()
"› $goog "
" "
" "
" Google Calendar [Plugin] Connect Google Calendar for scheduling, ava…"
" "
" Google Calendar [Skill] Find availability and plan event changes "
" Google Calendar [App] Look up events and availability "
" "
+2 -14
View File
@@ -14,32 +14,20 @@ use codex_app_server_protocol::SkillMetadata;
use codex_app_server_protocol::SkillsListEntry;
use codex_app_server_protocol::SkillsListResponse;
use codex_connectors::AppInfo;
use codex_features::Feature;
use codex_protocol::parse_command::ParsedCommand;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_plugins::mention_syntax::TOOL_MENTION_SIGIL;
impl ChatWidget {
pub(crate) fn open_skills_list(&mut self) {
if self.config.features.enabled(Feature::MentionsV2) {
self.insert_str("@");
} else {
self.insert_str("$");
}
self.insert_str("$");
}
pub(crate) fn open_skills_menu(&mut self) {
let list_shortcut = if self.config.features.enabled(Feature::MentionsV2) {
'@'
} else {
'$'
};
let items = vec![
SelectionItem {
name: "List skills".to_string(),
description: Some(format!(
"Tip: press {list_shortcut} to open this list directly."
)),
description: Some("Tip: press $ to open this list directly.".to_string()),
actions: vec![Box::new(|tx| {
tx.send(AppEvent::OpenSkillsList);
})],
@@ -5,7 +5,7 @@ expression: popup
Skills
Choose an action
› 1. List skills Tip: press @ to open this list directly.
› 1. List skills Tip: press $ to open this list directly.
2. Enable/Disable Skills Enable or disable skills.
Press enter to confirm or esc to go back
@@ -886,6 +886,7 @@ async fn submission_prefers_selected_duplicate_skill_path() {
path: repo_skill_path,
scope: crate::test_support::skill_scope_repo(),
enabled: true,
plugin_id: None,
},
SkillMetadata {
name: "figma".to_string(),
@@ -896,6 +897,7 @@ async fn submission_prefers_selected_duplicate_skill_path() {
path: user_skill_path.clone(),
scope: crate::test_support::skill_scope_user(),
enabled: true,
plugin_id: None,
},
]));