|
1 | 1 | import { |
2 | | - DEFAULT_CHAT_FONT_SIZE, |
3 | 2 | DEFAULT_CODE_FONT_SIZE, |
4 | 3 | DEFAULT_INTERFACE_FONT_SIZE, |
5 | 4 | DEFAULT_PROMPT_FONT_SIZE, |
@@ -68,7 +67,7 @@ export interface AppearanceFontPreferences { |
68 | 67 | readonly chat: string; |
69 | 68 | readonly sizeInterface: number; |
70 | 69 | readonly sizePrompt: number; |
71 | | - readonly sizeChat: number; |
| 70 | + readonly sizeChat: number | null; |
72 | 71 | readonly sizeCode: number; |
73 | 72 | readonly smoothing: boolean; |
74 | 73 | } |
@@ -96,8 +95,7 @@ export function applyAppearanceFontVariables( |
96 | 95 | root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`; |
97 | 96 | root.style.setProperty("--font-size-prompt", `${clampPromptFontSize(preferences.sizePrompt)}px`); |
98 | 97 | const chat = clampChatFontSize(preferences.sizeChat); |
99 | | - // The default leaves messages on their rem size, so they keep following the interface size. |
100 | | - if (chat === DEFAULT_CHAT_FONT_SIZE) { |
| 98 | + if (chat === null) { |
101 | 99 | root.style.removeProperty("--font-size-chat"); |
102 | 100 | } else { |
103 | 101 | root.style.setProperty("--font-size-chat", `${chat}px`); |
@@ -131,8 +129,9 @@ function clampPromptFontSize(value: number): number { |
131 | 129 | return clampFontSize(value, MIN_PROMPT_FONT_SIZE, MAX_PROMPT_FONT_SIZE, DEFAULT_PROMPT_FONT_SIZE); |
132 | 130 | } |
133 | 131 |
|
134 | | -function clampChatFontSize(value: number): number { |
135 | | - return clampFontSize(value, MIN_CHAT_FONT_SIZE, MAX_CHAT_FONT_SIZE, DEFAULT_CHAT_FONT_SIZE); |
| 132 | +function clampChatFontSize(value: number | null): number | null { |
| 133 | + if (value === null || !Number.isFinite(value)) return null; |
| 134 | + return Math.min(MAX_CHAT_FONT_SIZE, Math.max(MIN_CHAT_FONT_SIZE, Math.round(value))); |
136 | 135 | } |
137 | 136 |
|
138 | 137 | function clampCodeFontSize(value: number): number { |
|
0 commit comments