fix(tui): expose mention behavior in config

This commit is contained in:
cyq
2026-06-02 06:54:27 +08:00
committed by Hunter Bown
parent 73cd721665
commit f185d46917
3 changed files with 43 additions and 0 deletions
+5
View File
@@ -595,6 +595,11 @@ pub fn set_config_value(app: &mut App, key: &str, value: &str, persist: bool) ->
app.composer.mention_completion_cache = None;
app.needs_redraw = true;
}
"mention_menu_behavior" | "mention_behavior" | "mention_menu" => {
app.mention_menu_behavior = settings.mention_menu_behavior.clone();
app.composer.mention_completion_cache = None;
app.needs_redraw = true;
}
"mention_walk_depth" | "mention_depth" | "completions_walk_depth" => {
app.mention_walk_depth = settings.mention_walk_depth;
app.composer.mention_completion_cache = None;
+31
View File
@@ -68,6 +68,7 @@ pub struct SettingsSection {
pub composer_vim_mode: ComposerVimModeValue,
#[schemars(range(min = 0))]
pub mention_menu_limit: usize,
pub mention_menu_behavior: MentionMenuBehaviorValue,
#[schemars(range(min = 0))]
pub mention_walk_depth: usize,
pub transcript_spacing: TranscriptSpacingValue,
@@ -204,6 +205,13 @@ pub enum ComposerVimModeValue {
Vim,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum MentionMenuBehaviorValue {
Fuzzy,
Browser,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum TranscriptSpacingValue {
@@ -332,6 +340,7 @@ pub fn build_document(app: &App, config: &Config) -> Result<ConfigUiDocument> {
composer_border: settings.composer_border,
composer_vim_mode: settings.composer_vim_mode.as_str().into(),
mention_menu_limit: settings.mention_menu_limit,
mention_menu_behavior: settings.mention_menu_behavior.as_str().into(),
mention_walk_depth: settings.mention_walk_depth,
transcript_spacing: settings.transcript_spacing.as_str().into(),
status_indicator: settings.status_indicator.as_str().into(),
@@ -513,6 +522,10 @@ pub fn apply_document(
"mention_menu_limit",
&doc.settings.mention_menu_limit.to_string(),
),
(
"mention_menu_behavior",
doc.settings.mention_menu_behavior.as_setting(),
),
(
"mention_walk_depth",
&doc.settings.mention_walk_depth.to_string(),
@@ -782,6 +795,24 @@ impl From<&str> for ComposerVimModeValue {
}
}
impl MentionMenuBehaviorValue {
fn as_setting(self) -> &'static str {
match self {
Self::Fuzzy => "fuzzy",
Self::Browser => "browser",
}
}
}
impl From<&str> for MentionMenuBehaviorValue {
fn from(value: &str) -> Self {
match value.trim().to_ascii_lowercase().as_str() {
"browser" => Self::Browser,
_ => Self::Fuzzy,
}
}
}
impl TranscriptSpacingValue {
fn as_setting(self) -> &'static str {
match self {
+7
View File
@@ -772,6 +772,13 @@ impl ConfigView {
editable: true,
scope: ConfigScope::Saved,
},
ConfigRow {
section: ConfigSection::Composer,
key: "mention_menu_behavior".to_string(),
value: settings.mention_menu_behavior.clone(),
editable: true,
scope: ConfigScope::Saved,
},
ConfigRow {
section: ConfigSection::Composer,
key: "mention_walk_depth".to_string(),