Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

sort plugins first in menu (#14163)

sayan-oaia3cd9f16f5b3
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
index bf2eb17895..ba16a52b54 100644
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
@@ -3580,6 +3580,7 @@ impl ChatComposer {
search_terms,
path: Some(skill.path_to_skills_md.to_string_lossy().into_owned()),
category_tag: Some("[Skill]".to_string()),
+ sort_rank: 1,
});
}
}
@@ -3631,6 +3632,7 @@ impl ChatComposer {
search_terms,
path: Some(format!("plugin://{}", plugin.config_name)),
category_tag: Some("[Plugin]".to_string()),
+ sort_rank: 0,
});
}
}
@@ -3654,6 +3656,7 @@ impl ChatComposer {
search_terms,
path: Some(format!("app://{connector_id}")),
category_tag: Some("[App]".to_string()),
+ sort_rank: 1,
});
}
}
diff --git a/codex-rs/tui/src/bottom_pane/skill_popup.rs b/codex-rs/tui/src/bottom_pane/skill_popup.rs
index 4e8a8ae6d0..9cff417615 100644
--- a/codex-rs/tui/src/bottom_pane/skill_popup.rs
+++ b/codex-rs/tui/src/bottom_pane/skill_popup.rs
@@ -25,6 +25,7 @@ pub(crate) struct MentionItem {
pub(crate) search_terms: Vec<String>,
pub(crate) path: Option<String>,
pub(crate) category_tag: Option<String>,
+ pub(crate) sort_rank: u8,
}
const MENTION_NAME_TRUNCATE_LEN: usize = 24;
@@ -130,14 +131,12 @@ impl SkillPopup {
let filter = self.query.trim();
let mut out: Vec<(usize, Option<Vec<usize>>, i32)> = Vec::new();
- if filter.is_empty() {
- for (idx, _mention) in self.mentions.iter().enumerate() {
+ for (idx, mention) in self.mentions.iter().enumerate() {
+ if filter.is_empty() {
out.push((idx, None, 0));
+ continue;
}
- return out;
- }
- for (idx, mention) in self.mentions.iter().enumerate() {
let mut best_match: Option<(Option<Vec<usize>>, i32)> = None;
if let Some((indices, score)) = fuzzy_match(&mention.display_name, filter) {
@@ -170,11 +169,15 @@ impl SkillPopup {
}
out.sort_by(|a, b| {
- a.2.cmp(&b.2).then_with(|| {
- let an = self.mentions[a.0].display_name.as_str();
- let bn = self.mentions[b.0].display_name.as_str();
- an.cmp(bn)
- })
+ self.mentions[a.0]
+ .sort_rank
+ .cmp(&self.mentions[b.0].sort_rank)
+ .then_with(|| a.2.cmp(&b.2))
+ .then_with(|| {
+ let an = self.mentions[a.0].display_name.as_str();
+ let bn = self.mentions[b.0].display_name.as_str();
+ an.cmp(bn)
+ })
});
out
diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__mention_popup_type_prefixes.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__mention_popup_type_prefixes.snap
index fec45981b7..a894bffcb2 100644
--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__mention_popup_type_prefixes.snap
+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__mention_popup_type_prefixes.snap
@@ -6,8 +6,8 @@ expression: terminal.backend()
"› $goog "
" "
" "
-" Google Calendar [Skill] Find availability and plan event changes "
" 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 "
" "
" Press enter to insert or esc to close "