From d6b58bb948fdcd92b22abb65ebfcae07fd40f94b Mon Sep 17 00:00:00 2001 From: Mark Christiansen Date: Sun, 2 Nov 2025 01:14:21 +1100 Subject: [PATCH] agent_ui: Use agent font size tokens for thread markdown rendering (#41610) Release Notes: - N/A --- Previously, agent markdown rendering used hardcoded font sizes (TextSize::Default and TextSize::Small) which ignored the agent_ui_font_size and agent_buffer_font_size settings. This updates the markdown style to respect these settings. This pull request adds support for customizing the font size of code blocks in agent responses, making it possible to set a distinct font size for code within the agent panel. The changes ensure that if the new setting is not specified, the font size will fall back to the agent UI font size, maintaining consistent appearance. (I am a frontend developer without any Rust knowledge so this is co-authored with Claude Code) **Theme settings extension:** * Added a new `agent_buffer_code_font_size` setting to `ThemeSettingsContent`, `ThemeSettings`, and the default settings JSON, allowing users to specify the font size for code blocks in agent responses. [[1]](diffhunk://#diff-a3bba02a485aba48e8e9a9d85485332378aa4fe29a0c50d11ae801ecfa0a56a4R69-R72) [[2]](diffhunk://#diff-aed3a9217587d27844c57ac8aff4a749f1fb1fc5d54926ef5065bf85f8fd633aR118-R119) [[3]](diffhunk://#diff-42e01d7aacb60673842554e30970b4ddbbaee7a2ec2c6f2be1c0b08b0dd89631R82-R83) * Updated the VSCode import logic to recognize and import the new `agent_buffer_code_font_size` setting. **Font size application in agent UI:** * Modified the agent UI rendering logic in `thread_view.rs` to use the new `agent_buffer_code_font_size` for code blocks, and to fall back to the agent UI font size if unset. [[1]](diffhunk://#diff-f73942e8d4f8c4d4d173d57d7c58bb653c4bb6ae7079533ee501750cdca27d98L5584-R5584) [[2]](diffhunk://#diff-f73942e8d4f8c4d4d173d57d7c58bb653c4bb6ae7079533ee501750cdca27d98L5596-R5598) * Implemented a helper method in `ThemeSettings` to retrieve the code block font size, with fallback logic to ensure a value is always used. * Updated the settings application logic to propagate the new code block font size setting throughout the theme system. ### Example Screenshots ![Screenshot 2025-10-31 at 12 38 28](https://github.com/user-attachments/assets/cbc34232-ab1f-40bf-a006-689678380e47) ![Screenshot 2025-10-31 at 12 37 45](https://github.com/user-attachments/assets/372b5cf8-2df8-425a-b052-12136de7c6bd) --------- Co-authored-by: Danilo Leal --- crates/agent_ui/src/acp/thread_view.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 0ae60ebe0df91c61eb5c968d5ee23ec18ef87187..a4b3106fa9d9ded053ff2f33b720ec3b10512d01 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -5596,7 +5596,7 @@ fn default_markdown_style( let theme_settings = ThemeSettings::get_global(cx); let colors = cx.theme().colors(); - let buffer_font_size = TextSize::Small.rems(cx); + let buffer_font_size = theme_settings.agent_buffer_font_size(cx); let mut text_style = window.text_style(); let line_height = buffer_font_size * 1.75; @@ -5608,9 +5608,9 @@ fn default_markdown_style( }; let font_size = if buffer_font { - TextSize::Small.rems(cx) + theme_settings.agent_buffer_font_size(cx) } else { - TextSize::Default.rems(cx) + theme_settings.agent_ui_font_size(cx) }; let text_color = if muted_text {