Files
codex/codex-rs/tui/src/skills_helpers.rs
T
felixxia-oai b6de5b524c Use app-server skill metadata directly in the TUI (#34368)
## Why

The TUI already receives skill metadata from the app-server protocol, but converted it into the core-skills model before using it.

## What changed

- Use `codex_app_server_protocol::SkillMetadata` throughout skill toggles, mentions, and input submission.
- Remove the protocol-to-core conversion and the TUI's `codex-core-skills` dependency.

GitOrigin-RevId: 43d43d74bfb67fc21ef11a0ca0592aa44b89a122
2026-07-20 15:44:37 +00:00

47 lines
1.3 KiB
Rust

use codex_app_server_protocol::SkillMetadata;
use codex_utils_fuzzy_match::fuzzy_match;
pub(crate) fn skill_display_name(skill: &SkillMetadata) -> String {
if let Some(display_name) = skill
.interface
.as_ref()
.and_then(|interface| interface.display_name.as_deref())
{
return display_name.to_string();
}
if let Some((plugin_name, skill_name)) = skill.name.split_once(':')
&& !plugin_name.is_empty()
&& !skill_name.is_empty()
{
return format!("{skill_name} ({plugin_name})");
}
skill.name.clone()
}
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 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
}