diff --git a/pebrel_app/i18n/en-US.json b/pebrel_app/i18n/en-US.json index 7029eef56..d26b282f1 100644 --- a/pebrel_app/i18n/en-US.json +++ b/pebrel_app/i18n/en-US.json @@ -199,6 +199,8 @@ } }, "settings": { + "show_tab_status": "Show tab activity indicators", + "show_tab_status_description": "Show running, waiting, completion and shell status badges. Changes apply to open tabs.", "search": { "terms": { "application": "application app update version github support", diff --git a/pebrel_app/i18n/zh-CN.json b/pebrel_app/i18n/zh-CN.json index d984b1849..108da7875 100644 --- a/pebrel_app/i18n/zh-CN.json +++ b/pebrel_app/i18n/zh-CN.json @@ -199,6 +199,8 @@ } }, "settings": { + "show_tab_status": "显示标签活动状态", + "show_tab_status_description": "显示运行、等待、完成状态与 Shell 短标。更改会立即应用到已打开的标签。", "search": { "terms": { "application": "应用 更新 版本 支持", diff --git a/pebrel_app/src/gpui_shell/config.rs b/pebrel_app/src/gpui_shell/config.rs index 008e9cc05..8ffb6daf6 100644 --- a/pebrel_app/src/gpui_shell/config.rs +++ b/pebrel_app/src/gpui_shell/config.rs @@ -80,6 +80,7 @@ pub struct Settings { pub notification_duration: pebrel_settings::NotificationDuration, /// 标签关闭按钮与标签插入动画都在渲染热路径读取,必须随全局设置驻留内存。 pub tab_close_visible: bool, + pub show_tab_status: bool, /// Use the working directory or SSH destination as the automatic tab title. pub static_tab_titles: bool, pub tab_reveal: pebrel_settings::TabRevealName, @@ -306,6 +307,7 @@ impl Settings { ai_toasts: runtime.ai_toasts, notification_duration: runtime.notification_duration, tab_close_visible: runtime.tab_close_visible, + show_tab_status: runtime.show_tab_status, static_tab_titles: runtime.static_tab_titles, tab_reveal: runtime.tab_reveal, ghost: runtime.ghost, diff --git a/pebrel_app/src/gpui_shell/settings_pane.rs b/pebrel_app/src/gpui_shell/settings_pane.rs index 73e5e462a..ed7671d04 100644 --- a/pebrel_app/src/gpui_shell/settings_pane.rs +++ b/pebrel_app/src/gpui_shell/settings_pane.rs @@ -815,6 +815,7 @@ impl SettingsPane { "dim_inactive_panes" => flag!(dim_inactive_panes), "multiline_paste_confirm" => flag!(multiline_paste_confirm), "tab_close_visible" => flag!(tab_close_visible), + "show_tab_status" => flag!(show_tab_status), "static_tab_titles" => flag!(static_tab_titles), "terminal_proxy" => flag!(terminal_proxy), "refresh_environment" => flag!(refresh_environment), diff --git a/pebrel_app/src/gpui_shell/settings_pane/appearance_advanced.rs b/pebrel_app/src/gpui_shell/settings_pane/appearance_advanced.rs index c9c83cfcb..b063ebeee 100644 --- a/pebrel_app/src/gpui_shell/settings_pane/appearance_advanced.rs +++ b/pebrel_app/src/gpui_shell/settings_pane/appearance_advanced.rs @@ -95,6 +95,13 @@ impl SettingsPane { self.runtime.dim_inactive_panes, cx, )) + .child(self.switch_row( + "show_tab_status", + language.text(crate::i18n::Message::SettingsShowTabStatus), + language.text(crate::i18n::Message::SettingsShowTabStatusDescription), + self.runtime.show_tab_status, + cx, + )) .child(self.switch_row( "tab_close_visible", language.text(crate::i18n::Message::SettingsAppearanceShowTabCloseButtons), diff --git a/pebrel_app/src/gpui_shell/settings_pane/theme_studio_tests.rs b/pebrel_app/src/gpui_shell/settings_pane/theme_studio_tests.rs index dc0badc5d..3aed76d47 100644 --- a/pebrel_app/src/gpui_shell/settings_pane/theme_studio_tests.rs +++ b/pebrel_app/src/gpui_shell/settings_pane/theme_studio_tests.rs @@ -1787,6 +1787,34 @@ fn theme_editor_save_only_forks_a_non_active_custom_template_without_publishing_ assert_eq!(settings_file_snapshot(), before_settings_file); } +#[gpui::test] +fn tab_status_switch_persists_and_hot_applies(cx: &mut TestAppContext) { + use crate::gpui_shell::config::Settings; + let _lock = lock_theme_studio(); + let _guard = SettingsBytesGuard::capture(); + std::fs::create_dir_all(pebrel_settings::settings_dir()).unwrap(); + std::fs::write(pebrel_settings::settings_path(), TEST_SETTINGS).unwrap(); + let (pane, mut window) = open_settings(cx); + window.simulate_resize(size(px(1280.0), px(1800.0))); + for expected in [false, true] { + draw(&mut window); + let bounds = window.debug_bounds("nebula-switch-show_tab_status").unwrap(); + window.simulate_event(gpui::ScrollWheelEvent { + position: gpui::point(bounds.center().x, px(900.0)), + delta: gpui::ScrollDelta::Pixels(gpui::point(px(0.0), px(900.0) - bounds.center().y)), + touch_phase: gpui::TouchPhase::Moved, + modifiers: Modifiers::default(), + }); + draw(&mut window); + click("nebula-switch-show_tab_status", &mut window); + assert_eq!(RuntimeSettings::load().show_tab_status, expected); + assert_eq!(window.read(|cx| cx.global::().show_tab_status), expected); + pane.read_with(&window, |pane, _| assert_eq!(pane.runtime.show_tab_status, expected)); + let reopened = window.update(|window, cx| cx.new(|cx| SettingsPane::new(window, cx))); + reopened.read_with(&window, |pane, _| assert_eq!(pane.runtime.show_tab_status, expected)); + } +} + #[gpui::test] fn theme_list_scroll_keeps_preview_visible_and_narrow_picker_accessible(cx: &mut TestAppContext) { let _fixture_guard = lock_theme_studio(); diff --git a/pebrel_app/src/gpui_shell/workspace/settings_navigation/ui_tests.rs b/pebrel_app/src/gpui_shell/workspace/settings_navigation/ui_tests.rs index 8a1be99ea..c33101d3f 100644 --- a/pebrel_app/src/gpui_shell/workspace/settings_navigation/ui_tests.rs +++ b/pebrel_app/src/gpui_shell/workspace/settings_navigation/ui_tests.rs @@ -265,3 +265,77 @@ fn density_changes_real_tab_bounds_and_sidebar_drag_pitch(cx: &mut TestAppContex } } } + +#[gpui::test] +fn hiding_tab_status_keeps_hover_close_selection_and_keyboard( + cx: &mut TestAppContext, +) { + use crate::gpui_shell::config::Settings; + use pebrel_settings::TabsPositionName; + let (_directory, workspace, mut window) = open_workspace(2, cx); + window.update(|window, cx| { + window.activate_window(); + cx.global_mut::().tab_reveal = pebrel_settings::TabRevealName::Instant; + workspace.update(cx, |workspace, cx| { + workspace.close_settings(window, cx); + workspace.active = 0; + cx.global_mut::().tab_close_visible = true; + }); + }); + for (position, row, status, close) in [ + (TabsPositionName::Sidebar, "sidebar-tab-1", "sidebar-tab-status-1", "close-sidebar-tab-1"), + (TabsPositionName::Top, "top-tab-1", "top-tab-status-1", "close-top-tab-1"), + ] { + for visible in [true, false, true, false] { + window.simulate_mouse_move(gpui::point(px(1.0), px(1.0)), None, Modifiers::default()); + window.update(|_, cx| { + workspace.update(cx, |workspace, cx| { + workspace.active = 0; + workspace.tab_meta[1].has_bell = true; + workspace.tabs_position = position; + workspace.sidebar_collapsed = false; + cx.global_mut::().show_tab_status = visible; + workspace.sync_settings_layout(false); + cx.notify(); + }); + }); + let bounds = tab_bounds(row, &mut window); + assert_eq!(window.debug_bounds(status).is_some(), visible); + workspace.read_with(&window, |workspace, cx| { + assert!( + workspace.tab_meta[1].has_bell, + "display preference does not clear observed state" + ); + assert_eq!( + workspace.tab_presentation(1, cx, true).activity, + if visible { SidebarActivity::Done } else { SidebarActivity::Idle } + ); + }); + window.simulate_mouse_move(bounds.center(), None, Modifiers::default()); + tab_bounds(row, &mut window); + assert!( + window.debug_bounds(close).is_some(), + "{close} remains laid out with status={visible}, row={bounds:?}" + ); + } + click_tab(row, &mut window); + workspace.read_with(&window, |workspace, _| assert_eq!(workspace.active, 1)); + } + window.update(|window, cx| { + workspace.update(cx, |workspace, cx| { + workspace.active = 0; + workspace.tabs_position = TabsPositionName::Top; + workspace.focus_active(window, cx); + workspace.sidebar_collapsed = false; + cx.notify(); + }); + }); + tab_bounds("top-tab-1", &mut window); + window.simulate_keystrokes("ctrl-tab"); + workspace.read_with(&window, |workspace, _| assert_eq!(workspace.active, 1)); + let row = tab_bounds("top-tab-1", &mut window); + window.simulate_mouse_move(row.center(), None, Modifiers::default()); + tab_bounds("top-tab-1", &mut window); + click_tab("close-top-tab-1", &mut window); + workspace.read_with(&window, |workspace, _| assert_eq!(workspace.tabs.len(), 1)); +} diff --git a/pebrel_app/src/gpui_shell/workspace/sidebar.rs b/pebrel_app/src/gpui_shell/workspace/sidebar.rs index d454d32c3..1c1bdb2a5 100644 --- a/pebrel_app/src/gpui_shell/workspace/sidebar.rs +++ b/pebrel_app/src/gpui_shell/workspace/sidebar.rs @@ -563,6 +563,7 @@ impl NebulaWorkspace { .inset_0() .justify_end() .items_center() + .debug_selector(move || format!("sidebar-tab-status-{ix}")) .group_hover(hover_group.clone(), |item| item.invisible()) .child(if matches!(activity, SidebarActivity::Idle) { status @@ -584,6 +585,9 @@ impl NebulaWorkspace { .when(tab_close_visible, |slot| { slot.child(Self::tab_status_icon( Button::new(("close-tab", ix)) + .debug_selector(move || { + format!("close-sidebar-tab-{ix}") + }) .icon(IconName::Close) .ghost() .xsmall() diff --git a/pebrel_app/src/gpui_shell/workspace/tab_presentation.rs b/pebrel_app/src/gpui_shell/workspace/tab_presentation.rs index eb0a67d02..c6b65b6c9 100644 --- a/pebrel_app/src/gpui_shell/workspace/tab_presentation.rs +++ b/pebrel_app/src/gpui_shell/workspace/tab_presentation.rs @@ -102,7 +102,14 @@ impl NebulaWorkspace { .unwrap_or((None, SidebarActivity::Idle)); // 事件 vs 状态的唯一裁定处(侧栏与顶栏共用这份 presentation),规则与 // 理由见 [`sidebar::resting_activity`]。 - let activity = sidebar::resting_activity(activity, active, self.meta(ix).has_bell); + let show_status = cx + .try_global::() + .is_none_or(|settings| settings.show_tab_status); + let activity = if show_status { + sidebar::resting_activity(activity, active, self.meta(ix).has_bell) + } else { + SidebarActivity::Idle + }; let brand_logo = program.as_deref().and_then(crate::display::ai_logo_for_program); let logo_image = brand_logo.and_then(|logo| self.sidebar_logo_images.get(&(logo, dark)).cloned()); @@ -126,10 +133,11 @@ impl NebulaWorkspace { // 的 shell,只贴其中一个(聚焦那个)是误导;数量胶囊「这是一组」才是 // 此时该占这个槽位的信息。顺带把 28px 让回标题——顶栏挤到 120px 时, // 图标+胶囊+短标三样一起上,标题只剩两三个字符。 - let shell_tag = (is_terminal && activity == SidebarActivity::Idle && pane_count <= 1) - .then_some(meta.shell_tag.clone()) - .flatten() - .filter(|tag| !tag.is_empty()); + let shell_tag = + (show_status && is_terminal && activity == SidebarActivity::Idle && pane_count <= 1) + .then_some(meta.shell_tag.clone()) + .flatten() + .filter(|tag| !tag.is_empty()); let renaming = self .tab_rename .as_ref() diff --git a/pebrel_app/src/gpui_shell/workspace/top_tabs.rs b/pebrel_app/src/gpui_shell/workspace/top_tabs.rs index 777c22cfd..181cc0ff7 100644 --- a/pebrel_app/src/gpui_shell/workspace/top_tabs.rs +++ b/pebrel_app/src/gpui_shell/workspace/top_tabs.rs @@ -496,6 +496,7 @@ impl NebulaWorkspace { .inset_0() .justify_end() .items_center() + .debug_selector(move || format!("top-tab-status-{ix}")) .group_hover(hover_group.clone(), |item| item.invisible()) .child(if matches!(activity, SidebarActivity::Idle) { status @@ -515,6 +516,9 @@ impl NebulaWorkspace { .when(tab_close_visible || settings_navigation, |slot| { slot.child(Self::tab_status_icon( Button::new(("top-close-tab", ix)) + .debug_selector(move || { + format!("close-top-tab-{ix}") + }) .icon(IconName::Close) .ghost() .xsmall() diff --git a/pebrel_settings/src/lib.rs b/pebrel_settings/src/lib.rs index f642b5eac..e5b83be1a 100644 --- a/pebrel_settings/src/lib.rs +++ b/pebrel_settings/src/lib.rs @@ -1045,6 +1045,8 @@ pub struct RuntimeSettings { pub multiline_paste_confirm: bool, /// 标签页关闭按钮(叉号)是否渲染:关 = 不渲染,仍可用中键关闭。 pub tab_close_visible: bool, + /// Presentation only; task observation and Runtime state remain active. + pub show_tab_status: bool, /// Keep the automatic tab title on the local directory or SSH destination. pub static_tab_titles: bool, /// 新建本地终端是否把 Windows 系统代理写入代理环境变量。自定义代理地址 @@ -1250,6 +1252,7 @@ impl RuntimeSettings { dim_inactive_panes: raw.bool_on("dim_inactive_panes").unwrap_or(true), multiline_paste_confirm: raw.bool_on("multiline_paste_confirm").unwrap_or(true), tab_close_visible: raw.bool_on("tab_close_visible").unwrap_or(true), + show_tab_status: raw.bool_on("show_tab_status").unwrap_or(true), static_tab_titles: raw.bool_on("static_tab_titles").unwrap_or(false), terminal_proxy: raw.bool_on("terminal_proxy").unwrap_or(false), refresh_environment: raw.bool_on("refresh_environment").unwrap_or(true), @@ -1412,6 +1415,17 @@ pub fn format_hex_rgb(rgb: Rgb8) -> String { #[cfg(test)] mod tests { + #[test] + fn tab_status_visibility_defaults_on_and_round_trips() { + let original = "custom=keep\n"; + assert!(RuntimeSettings::from_raw(&RawSettings::from_text(original)).show_tab_status); + let off = apply_updates(original, &[("show_tab_status", "0".into())]); + assert!(!RuntimeSettings::from_raw(&RawSettings::from_text(&off)).show_tab_status); + let on = apply_updates(&off, &[("show_tab_status", "1".into())]); + assert!(RuntimeSettings::from_raw(&RawSettings::from_text(&on)).show_tab_status); + assert!(on.contains("custom=keep")); + } + #[test] fn environment_refresh_defaults_and_round_trips() { for text in ["", "refresh_environment=\n", "refresh_environment=invalid\n"] { diff --git a/pebrel_settings/src/reset.rs b/pebrel_settings/src/reset.rs index 2838a0e25..0418b2c02 100644 --- a/pebrel_settings/src/reset.rs +++ b/pebrel_settings/src/reset.rs @@ -28,6 +28,7 @@ const RESET_KEYS: &[&str] = &[ "dim_inactive_panes", "multiline_paste_confirm", "tab_close_visible", + "show_tab_status", "static_tab_titles", "terminal_proxy", "refresh_environment", @@ -167,6 +168,13 @@ mod tests { use super::*; use crate::{RawSettings, RuntimeSettings}; + #[test] + fn reset_restores_tab_status_visibility() { + let text = default_settings_text("show_tab_status=0\ncustom=keep\n"); + assert!(RuntimeSettings::from_raw(&RawSettings::from_text(&text)).show_tab_status); + assert!(text.contains("custom=keep")); + } + #[test] fn reset_restores_auto_scrollbar_visibility() { let text = default_settings_text("scrollbar_visibility=always\ncustom=keep\n");