From 7d443b214935b0557f22093b37410bcbf64ff442 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sat, 8 Aug 2026 08:42:08 +0700 Subject: [PATCH] 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. --- src/ui/i18n/en.rs | 3 +-- src/ui/i18n/ja.rs | 1 - src/ui/i18n/mod.rs | 2 -- src/ui/i18n/zh.rs | 1 - src/ui/settings.rs | 61 ++++++++++++++++------------------------------ 5 files changed, 22 insertions(+), 46 deletions(-) diff --git a/src/ui/i18n/en.rs b/src/ui/i18n/en.rs index f883464d..fa4284db 100644 --- a/src/ui/i18n/en.rs +++ b/src/ui/i18n/en.rs @@ -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" } diff --git a/src/ui/i18n/ja.rs b/src/ui/i18n/ja.rs index 7fbe1803..36f894bc 100644 --- a/src/ui/i18n/ja.rs +++ b/src/ui/i18n/ja.rs @@ -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" } diff --git a/src/ui/i18n/mod.rs b/src/ui/i18n/mod.rs index 2661c437..f29eb229 100644 --- a/src/ui/i18n/mod.rs +++ b/src/ui/i18n/mod.rs @@ -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, diff --git a/src/ui/i18n/zh.rs b/src/ui/i18n/zh.rs index 70a82fb7..fadfe345 100644 --- a/src/ui/i18n/zh.rs +++ b/src/ui/i18n/zh.rs @@ -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" } diff --git a/src/ui/settings.rs b/src/ui/settings.rs index ac5de705..a522c68a 100644 --- a/src/ui/settings.rs +++ b/src/ui/settings.rs @@ -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::().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) -> Option
{ @@ -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()