mirror of
https://github.com/openai/codex.git
synced 2026-05-01 03:42:05 +03:00
Add UI for skill enable/disable. (#9627)
"/skill" will now allow you to enable/disable skills: <img width="658" height="199" alt="image" src="https://github.com/user-attachments/assets/bf8994c8-d6c1-462f-8bbb-f1ee9241caa4" />
This commit is contained in:
47
codex-rs/tui/src/skills_helpers.rs
Normal file
47
codex-rs/tui/src/skills_helpers.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
use codex_common::fuzzy_match::fuzzy_match;
|
||||
use codex_core::skills::model::SkillMetadata;
|
||||
|
||||
use crate::text_formatting::truncate_text;
|
||||
|
||||
pub(crate) const SKILL_NAME_TRUNCATE_LEN: usize = 21;
|
||||
|
||||
pub(crate) fn skill_display_name(skill: &SkillMetadata) -> &str {
|
||||
skill
|
||||
.interface
|
||||
.as_ref()
|
||||
.and_then(|interface| interface.display_name.as_deref())
|
||||
.unwrap_or(&skill.name)
|
||||
}
|
||||
|
||||
pub(crate) fn skill_description(skill: &SkillMetadata) -> &str {
|
||||
skill
|
||||
.interface
|
||||
.as_ref()
|
||||
.and_then(|interface| interface.short_description.as_deref())
|
||||
.or(skill.short_description.as_deref())
|
||||
.unwrap_or(&skill.description)
|
||||
}
|
||||
|
||||
pub(crate) fn truncate_skill_name(name: &str) -> String {
|
||||
truncate_text(name, SKILL_NAME_TRUNCATE_LEN)
|
||||
}
|
||||
|
||||
pub(crate) fn truncated_skill_display_name(skill: &SkillMetadata) -> String {
|
||||
truncate_skill_name(skill_display_name(skill))
|
||||
}
|
||||
|
||||
pub(crate) fn match_skill(
|
||||
filter: &str,
|
||||
display_name: &str,
|
||||
skill_name: &str,
|
||||
) -> Option<(Option<Vec<usize>>, i32)> {
|
||||
if let Some((indices, score)) = fuzzy_match(display_name, filter) {
|
||||
return Some((Some(indices), score));
|
||||
}
|
||||
if display_name != skill_name
|
||||
&& let Some((_indices, score)) = fuzzy_match(skill_name, filter)
|
||||
{
|
||||
return Some((None, score));
|
||||
}
|
||||
None
|
||||
}
|
||||
Reference in New Issue
Block a user