From 543f79fa9e9055d002400c99d4bba1887376a609 Mon Sep 17 00:00:00 2001 From: Lstarsky0 <59827030+Lstarsky0@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:12:10 +0800 Subject: [PATCH] fix(tui): use the footer's own words in the settings preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The footer preview at the bottom of /settings draws with the real footer renderer, but it passed the raw setting values in as chip text. With Startup mode set to Work the preview read "● ask agent" while the footer under the composer reads "● ask work", and with Plan it read "● ask plan" where the footer reads "● read only plan". Parse the two rows into AppMode and ApprovalMode and take the words and inks from the helpers the footer itself uses (mode_label, permission_label_for, header_mode_ink, header_permission_ink). The preview now also follows the UI language like the footer does. The 80x24 and 120x32 Settings goldens pinned "● ask agent" on the preview line; they now read "● ask work". Signed-off-by: Lstarsky0 <59827030+Lstarsky0@users.noreply.github.com> --- .../src/tui/goldens/config_panel_120x32.txt | 2 +- .../src/tui/goldens/config_panel_80x24.txt | 2 +- crates/tui/src/tui/underwater.rs | 6 ++-- crates/tui/src/tui/views/mod.rs | 31 ++++++++++--------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/crates/tui/src/tui/goldens/config_panel_120x32.txt b/crates/tui/src/tui/goldens/config_panel_120x32.txt index 77f7e57f03..e5b1087e12 100644 --- a/crates/tui/src/tui/goldens/config_panel_120x32.txt +++ b/crates/tui/src/tui/goldens/config_panel_120x32.txt @@ -26,7 +26,7 @@ │ │ │ │ system | terminal | shoreline | shoreline-light | underwater | underwater-retro | dark | light | grayscale |… - Preview: ● ask agent + Preview: ● ask work type=filter, Up/Down=select, Enter=edit, Esc=close ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── diff --git a/crates/tui/src/tui/goldens/config_panel_80x24.txt b/crates/tui/src/tui/goldens/config_panel_80x24.txt index fa426f5ede..34b00b13bd 100644 --- a/crates/tui/src/tui/goldens/config_panel_80x24.txt +++ b/crates/tui/src/tui/goldens/config_panel_80x24.txt @@ -18,7 +18,7 @@ system | terminal | shoreline | shoreline-light | underwater |… Enter or click again: Enter opens choices · Theme: current terminal · saved terminal · applies on save - Preview: ● ask agent + Preview: ● ask work type=filter, Up/Down=select, Enter=edit, PgUp/PgDn=scroll, Esc=close ────────────────────────────────────────────────────────────────────────────── diff --git a/crates/tui/src/tui/underwater.rs b/crates/tui/src/tui/underwater.rs index 690492ac34..904c42287c 100644 --- a/crates/tui/src/tui/underwater.rs +++ b/crates/tui/src/tui/underwater.rs @@ -687,7 +687,7 @@ impl ShellPhase { /// Exhaustive on purpose: a new [`AppMode`] must be handed a Policy ink /// deliberately rather than inheriting act's by falling through a wildcard. -fn header_mode_ink(mode: AppMode) -> ChromeInk { +pub(crate) fn header_mode_ink(mode: AppMode) -> ChromeInk { match mode { AppMode::Plan => ChromeInk::PolicyPlan, AppMode::Operate => ChromeInk::PolicyOperate, @@ -695,7 +695,7 @@ fn header_mode_ink(mode: AppMode) -> ChromeInk { } } -fn header_permission_ink(mode: ApprovalMode) -> ChromeInk { +pub(crate) fn header_permission_ink(mode: ApprovalMode) -> ChromeInk { match mode { ApprovalMode::Suggest | ApprovalMode::Never => ChromeInk::PermissionAsk, ApprovalMode::Auto => ChromeInk::PermissionAutoReview, @@ -900,7 +900,7 @@ pub(crate) fn phase_marker_with_activity( } } -fn mode_label(locale: Locale, mode: AppMode) -> Cow<'static, str> { +pub(crate) fn mode_label(locale: Locale, mode: AppMode) -> Cow<'static, str> { match mode { AppMode::Agent => tr(locale, MessageId::ChipModeAct), AppMode::Plan => tr(locale, MessageId::ChipModePlan), diff --git a/crates/tui/src/tui/views/mod.rs b/crates/tui/src/tui/views/mod.rs index 267baa786f..51571847a3 100644 --- a/crates/tui/src/tui/views/mod.rs +++ b/crates/tui/src/tui/views/mod.rs @@ -5300,25 +5300,26 @@ impl ConfigView { let context_percent = self.snapshot.context_budget.as_ref().map_or(0, |budget| { u8::try_from(budget.percent_basis_points / 100).unwrap_or(100) }); - let mode = value_of("default_mode").unwrap_or_else(|| "agent".to_string()); - let mode_ink = match mode.as_str() { - "plan" => palette::ChromeInk::PolicyPlan, - "operate" => palette::ChromeInk::PolicyOperate, - _ => palette::ChromeInk::PolicyAct, - }; - let permission = value_of("approval_mode") + let mode = value_of("default_mode").map_or(codewhale_config::AppMode::Agent, |value| { + codewhale_config::AppMode::from_setting(&value) + }); + let approval = value_of("approval_mode") .or_else(|| value_of("permission_posture")) - .unwrap_or_else(|| "ask".to_string()); - let permission_ink = match permission.as_str() { - "auto-review" => palette::ChromeInk::PermissionAutoReview, - "full-access" => palette::ChromeInk::PermissionFullAccess, - _ => palette::ChromeInk::PermissionAsk, - }; + .and_then(|value| codewhale_execpolicy::ApprovalMode::from_config_value(&value)) + .unwrap_or(codewhale_execpolicy::ApprovalMode::Suggest); + let mode_label = crate::tui::underwater::mode_label(self.locale, mode); + let permission = crate::core::authority::permission_label_for(self.locale, mode, approval); let footer = crate::tui::phase_strip::TidelineFooter::new( &theme, - (permission.as_str(), permission_ink), + ( + permission.as_ref(), + crate::tui::underwater::header_permission_ink(approval), + ), ) - .mode_chip(Some((mode.as_str(), mode_ink))) + .mode_chip(Some(( + mode_label.as_ref(), + crate::tui::underwater::header_mode_ink(mode), + ))) .context_percent(context_percent); crate::tui::phase_strip::render_tideline_footer( Rect {