fix(settings): build the command-line setting out of the same pieces as the rest

It was the one hand-rolled row on the page: a quieter heading than every
other section, a full-width description, and the only switch in Settings
standing to the left of its own label. It was also the one row the
settings search could neither highlight nor dim, so searching "cli"
badged Agents with (2) and showed one match. Run it through
section_header and settings_row, and point the index entry at the label
the row actually renders.
This commit is contained in:
l0ng-ai
2026-08-08 08:42:08 +07:00
parent e17bebb7e2
commit 7d443b2149
5 changed files with 22 additions and 46 deletions
+1 -2
View File
@@ -618,9 +618,8 @@ pub fn translate_en(key: L10nKey) -> &'static str {
}
L10nKey::SettingsSearchCodexKeywords => "agent integration hooks install openai codex",
L10nKey::SettingsSearchCommandLineToolKeywords => {
"cli tty7 path shell command install symlink terminal iterm agent script"
"command line tool cli tty7 path shell command install symlink terminal iterm agent script"
}
L10nKey::SettingsSearchCommandLineToolTitle => "Command line tool",
L10nKey::SettingsSearchCopilotCliKeywords => {
"agent integration hooks install github copilot"
}
-1
View File
@@ -627,7 +627,6 @@ pub fn translate_ja(key: L10nKey) -> Option<&'static str> {
L10nKey::SettingsSearchCommandLineToolKeywords => {
"cli tty7 パス シェル コマンド インストール シンボリックリンク ターミナル iterm エージェント スクリプト command line tool"
}
L10nKey::SettingsSearchCommandLineToolTitle => "コマンドラインツール",
L10nKey::SettingsSearchCopilotCliKeywords => {
"エージェント 統合 フック インストール github copilot agent integration hooks install"
}
-2
View File
@@ -513,7 +513,6 @@ l10n_keys! {
SettingsSearchClaudeCodeKeywords,
SettingsSearchCodexKeywords,
SettingsSearchCommandLineToolKeywords,
SettingsSearchCommandLineToolTitle,
SettingsSearchCopilotCliKeywords,
SettingsSearchCopyOnSelectKeywords,
SettingsSearchCursorBlinkKeywords,
@@ -1480,7 +1479,6 @@ mod tests {
L10nKey::SettingsSearchClaudeCodeKeywords,
L10nKey::SettingsSearchCodexKeywords,
L10nKey::SettingsSearchCommandLineToolKeywords,
L10nKey::SettingsSearchCommandLineToolTitle,
L10nKey::SettingsSearchCopilotCliKeywords,
L10nKey::SettingsSearchCopyOnSelectKeywords,
L10nKey::SettingsSearchCursorBlinkKeywords,
-1
View File
@@ -556,7 +556,6 @@ pub fn translate_zh(key: L10nKey) -> Option<&'static str> {
L10nKey::SettingsSearchCommandLineToolKeywords => {
"命令行工具 cli tty7 路径 shell 命令 安装 符号链接 terminal command line tool"
}
L10nKey::SettingsSearchCommandLineToolTitle => "命令行工具",
L10nKey::SettingsSearchCopilotCliKeywords => {
"Copilot CLI agent 集成 hook 安装 GitHub copilot agent integration hooks install"
}
+21 -40
View File
@@ -383,7 +383,7 @@ fn settings_search_entries() -> &'static [SearchEntry] {
},
SearchEntry {
section: Agents,
title: SettingsSearchCommandLineToolTitle,
title: SettingsInstallCliOnPath,
keywords: SettingsSearchCommandLineToolKeywords,
},
]
@@ -3967,44 +3967,24 @@ impl Tty7App {
}
let install_cli_on_path = cx.global::<Config>().install_cli_on_path;
page.child(
v_flex()
.mt_6()
.gap_2()
.child(self.section_rule(cx))
.child(
div()
.text_sm()
.font_weight(FontWeight::MEDIUM)
.text_color(foreground)
.child(t(L10nKey::SettingsCommandLine)),
)
.child(
div()
.text_sm()
.text_color(muted_fg)
.child(t(L10nKey::SettingsCommandLineDesc)),
)
.child(
h_flex()
.gap_2()
.items_center()
.child(
crate::ui::theme::switch("install-cli-on-path", cx)
.checked(install_cli_on_path)
.on_click(cx.listener(|this, on: &bool, _w, cx| {
this.set_install_cli_on_path(*on, cx)
})),
)
.child(
div()
.text_sm()
.text_color(foreground)
.child(t(L10nKey::SettingsInstallCliOnPath)),
),
),
)
.into_any_element()
let cli_switch = crate::ui::theme::switch("install-cli-on-path", cx)
.checked(install_cli_on_path)
.on_click(cx.listener(|this, on: &bool, _w, cx| this.set_install_cli_on_path(*on, cx)));
// Built from the same pieces as every other setting in the app: a
// section header, then a row whose label and description sit left of
// its control. Hand-rolled, this was the one switch that stood to the
// left of its own label — and the one row the settings search could
// neither highlight nor dim, so a query that counted it in the nav
// badge left nothing on the page looking like the match.
page.child(self.section_rule(cx))
.child(self.section_header(t(L10nKey::SettingsCommandLine), cx))
.child(self.settings_row(
t(L10nKey::SettingsInstallCliOnPath),
t(L10nKey::SettingsCommandLineDesc),
cli_switch.into_any_element(),
cx,
))
.into_any_element()
}
fn agent_hooks_machine_picker(&self, selected: HostId, cx: &mut Context<Self>) -> Option<Div> {
@@ -5531,7 +5511,7 @@ mod tests {
fn command_line_tool_is_searchable_under_agents() {
let entry = settings_search_entries()
.iter()
.find(|entry| entry.title == L10nKey::SettingsSearchCommandLineToolTitle)
.find(|entry| entry.title == L10nKey::SettingsInstallCliOnPath)
.expect("the CLI setting should be searchable");
assert_eq!(entry.section.profile_label(), "settings:agents");
@@ -5550,6 +5530,7 @@ mod tests {
"History search",
"Dim inactive panes",
"Option (⌥) acts as Meta",
"Install the `tty7` command on PATH",
] {
assert!(
settings_search_entries()