From ba7d30afe3259049ebdddbc025d0c19a8b5336aa Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Sat, 11 Apr 2026 03:38:18 -0400 Subject: [PATCH] Fix agent panel font size incrementing by 2px instead of 1px Split the shared AgentFontSize in-memory global into separate AgentUiFontSize and AgentBufferFontSize globals. Previously, both adjust_agent_ui_font_size and adjust_agent_buffer_font_size read from and wrote to the same global, so calling them back-to-back in handle_font_size_action applied the delta twice. --- crates/agent_ui/src/conversation_view.rs | 5 ++-- crates/theme_settings/src/settings.rs | 32 ++++++++++++--------- crates/theme_settings/src/theme_settings.rs | 12 ++++---- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs index 528e38333144524c4a4dffa63a7a8b107c829e41..b533f7ad03fefcc4545b0bf15fd732ebe5faf29b 100644 --- a/crates/agent_ui/src/conversation_view.rs +++ b/crates/agent_ui/src/conversation_view.rs @@ -53,7 +53,7 @@ use std::time::Instant; use std::{collections::BTreeMap, rc::Rc, time::Duration}; use terminal_view::terminal_panel::TerminalPanel; use text::Anchor; -use theme_settings::AgentFontSize; +use theme_settings::{AgentBufferFontSize, AgentUiFontSize}; use ui::{ Callout, CircularProgress, CommonAnimationExt, ContextMenu, ContextMenuEntry, CopyButton, DecoratedIcon, DiffStat, Disclosure, Divider, DividerColor, IconDecoration, IconDecorationKind, @@ -601,7 +601,8 @@ impl ConversationView { let agent_server_store = project.read(cx).agent_server_store().clone(); let subscriptions = vec![ cx.observe_global_in::(window, Self::agent_ui_font_size_changed), - cx.observe_global_in::(window, Self::agent_ui_font_size_changed), + cx.observe_global_in::(window, Self::agent_ui_font_size_changed), + cx.observe_global_in::(window, Self::agent_ui_font_size_changed), cx.subscribe_in( &agent_server_store, window, diff --git a/crates/theme_settings/src/settings.rs b/crates/theme_settings/src/settings.rs index 7b8261d27b6ef1c04677d74f868f85e6356daba7..08b8532a3551e5ccc10c079af0ad930cc8e445f8 100644 --- a/crates/theme_settings/src/settings.rs +++ b/crates/theme_settings/src/settings.rs @@ -96,11 +96,17 @@ pub(crate) struct UiFontSize(Pixels); impl Global for UiFontSize {} -/// In-memory override for the font size in the agent panel. +/// In-memory override for the UI font size in the agent panel. #[derive(Default)] -pub struct AgentFontSize(Pixels); +pub struct AgentUiFontSize(Pixels); -impl Global for AgentFontSize {} +impl Global for AgentUiFontSize {} + +/// In-memory override for the buffer font size in the agent panel. +#[derive(Default)] +pub struct AgentBufferFontSize(Pixels); + +impl Global for AgentBufferFontSize {} /// Represents the selection of a theme, which can be either static or dynamic. #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] @@ -378,7 +384,7 @@ impl ThemeSettings { /// Returns the agent panel font size. Falls back to the UI font size if unset. pub fn agent_ui_font_size(&self, cx: &App) -> Pixels { - cx.try_global::() + cx.try_global::() .map(|size| size.0) .or(self.agent_ui_font_size) .map(clamp_font_size) @@ -387,7 +393,7 @@ impl ThemeSettings { /// Returns the agent panel buffer font size. pub fn agent_buffer_font_size(&self, cx: &App) -> Pixels { - cx.try_global::() + cx.try_global::() .map(|size| size.0) .or(self.agent_buffer_font_size) .map(clamp_font_size) @@ -543,16 +549,16 @@ pub fn reset_ui_font_size(cx: &mut App) { pub fn adjust_agent_ui_font_size(cx: &mut App, f: impl FnOnce(Pixels) -> Pixels) { let agent_ui_font_size = ThemeSettings::get_global(cx).agent_ui_font_size(cx); let adjusted_size = cx - .try_global::() + .try_global::() .map_or(agent_ui_font_size, |adjusted_size| adjusted_size.0); - cx.set_global(AgentFontSize(clamp_font_size(f(adjusted_size)))); + cx.set_global(AgentUiFontSize(clamp_font_size(f(adjusted_size)))); cx.refresh_windows(); } /// Resets the agent response font size in the agent panel to the default value. pub fn reset_agent_ui_font_size(cx: &mut App) { - if cx.has_global::() { - cx.remove_global::(); + if cx.has_global::() { + cx.remove_global::(); cx.refresh_windows(); } } @@ -561,16 +567,16 @@ pub fn reset_agent_ui_font_size(cx: &mut App) { pub fn adjust_agent_buffer_font_size(cx: &mut App, f: impl FnOnce(Pixels) -> Pixels) { let agent_buffer_font_size = ThemeSettings::get_global(cx).agent_buffer_font_size(cx); let adjusted_size = cx - .try_global::() + .try_global::() .map_or(agent_buffer_font_size, |adjusted_size| adjusted_size.0); - cx.set_global(AgentFontSize(clamp_font_size(f(adjusted_size)))); + cx.set_global(AgentBufferFontSize(clamp_font_size(f(adjusted_size)))); cx.refresh_windows(); } /// Resets the user message font size in the agent panel to the default value. pub fn reset_agent_buffer_font_size(cx: &mut App) { - if cx.has_global::() { - cx.remove_global::(); + if cx.has_global::() { + cx.remove_global::(); cx.refresh_windows(); } } diff --git a/crates/theme_settings/src/theme_settings.rs b/crates/theme_settings/src/theme_settings.rs index 39ffe8327460431ede9c2d1c9a012d0de503fdb2..9be00af4755d394c2d67292e9e183c1792fd6a5b 100644 --- a/crates/theme_settings/src/theme_settings.rs +++ b/crates/theme_settings/src/theme_settings.rs @@ -28,12 +28,12 @@ pub use crate::schema::{ }; use crate::settings::adjust_buffer_font_size; pub use crate::settings::{ - AgentFontSize, BufferLineHeight, FontFamilyName, IconThemeName, IconThemeSelection, - ThemeAppearanceMode, ThemeName, ThemeSelection, ThemeSettings, adjust_agent_buffer_font_size, - adjust_agent_ui_font_size, adjust_ui_font_size, adjusted_font_size, appearance_to_mode, - clamp_font_size, default_theme, observe_buffer_font_size_adjustment, - reset_agent_buffer_font_size, reset_agent_ui_font_size, reset_buffer_font_size, - reset_ui_font_size, set_icon_theme, set_mode, set_theme, setup_ui_font, + AgentBufferFontSize, AgentUiFontSize, BufferLineHeight, FontFamilyName, IconThemeName, + IconThemeSelection, ThemeAppearanceMode, ThemeName, ThemeSelection, ThemeSettings, + adjust_agent_buffer_font_size, adjust_agent_ui_font_size, adjust_ui_font_size, + adjusted_font_size, appearance_to_mode, clamp_font_size, default_theme, + observe_buffer_font_size_adjustment, reset_agent_buffer_font_size, reset_agent_ui_font_size, + reset_buffer_font_size, reset_ui_font_size, set_icon_theme, set_mode, set_theme, setup_ui_font, }; pub use theme::UiDensity;