Skip to content

Commit 20bc7e5

Browse files
dominik-murarclaude
andcommitted
fix(web): chat size defaults to following the interface size
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 54c0bc3 commit 20bc7e5

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

‎apps/desktop/src/settings/DesktopClientSettings.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const clientSettings: ClientSettings = {
4444
fontFamilyComposer: "",
4545
fontFamilySans: "",
4646
fontFamilyTerminal: "",
47-
fontSizeChat: 14,
47+
fontSizeChat: null,
4848
fontSizeCode: 13,
4949
fontSizeInterface: 16,
5050
fontSizePrompt: 14,

‎apps/web/src/appearanceFonts.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
DEFAULT_CHAT_FONT_SIZE,
32
DEFAULT_CODE_FONT_SIZE,
43
DEFAULT_INTERFACE_FONT_SIZE,
54
DEFAULT_PROMPT_FONT_SIZE,
@@ -68,7 +67,7 @@ export interface AppearanceFontPreferences {
6867
readonly chat: string;
6968
readonly sizeInterface: number;
7069
readonly sizePrompt: number;
71-
readonly sizeChat: number;
70+
readonly sizeChat: number | null;
7271
readonly sizeCode: number;
7372
readonly smoothing: boolean;
7473
}
@@ -96,8 +95,7 @@ export function applyAppearanceFontVariables(
9695
root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`;
9796
root.style.setProperty("--font-size-prompt", `${clampPromptFontSize(preferences.sizePrompt)}px`);
9897
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) {
10199
root.style.removeProperty("--font-size-chat");
102100
} else {
103101
root.style.setProperty("--font-size-chat", `${chat}px`);
@@ -131,8 +129,9 @@ function clampPromptFontSize(value: number): number {
131129
return clampFontSize(value, MIN_PROMPT_FONT_SIZE, MAX_PROMPT_FONT_SIZE, DEFAULT_PROMPT_FONT_SIZE);
132130
}
133131

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)));
136135
}
137136

138137
function clampCodeFontSize(value: number): number {

‎apps/web/src/components/settings/TypographySettings.tsx‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function ChatFontRow() {
119119
value: settings.fontSizeChat,
120120
defaultValue: DEFAULT_UNIFIED_SETTINGS.fontSizeChat,
121121
onChange: (fontSizeChat) => updateSettings({ fontSizeChat }),
122+
onClear: () => updateSettings({ fontSizeChat: null }),
122123
}}
123124
preview={<ChatFontPreview />}
124125
/>
@@ -414,9 +415,11 @@ function FontFamilySettingsRow({
414415
label: string;
415416
min: number;
416417
max: number;
417-
value: number;
418-
defaultValue: number;
418+
value: number | null;
419+
defaultValue: number | null;
419420
onChange: (v: number) => void;
421+
/** Adds a "Default" option that stores null. */
422+
onClear?: () => void;
420423
};
421424
}) {
422425
const trimmed = value.trim();
@@ -535,19 +538,28 @@ function FontFamilySettingsRow({
535538
<div className="flex w-full items-center gap-2 sm:w-auto">
536539
<div className="min-w-0 flex-1 sm:w-44 sm:flex-none">{familyControl}</div>
537540
<Select
538-
value={String(size.value)}
541+
value={size.value === null ? "default" : String(size.value)}
539542
onValueChange={(next) => {
540543
if (typeof next !== "string") return;
544+
if (next === "default") {
545+
size.onClear?.();
546+
return;
547+
}
541548
const parsed = Number(next);
542549
if (Number.isInteger(parsed) && parsed >= size.min && parsed <= size.max) {
543550
size.onChange(parsed);
544551
}
545552
}}
546553
>
547554
<SelectTrigger size="sm" className="w-22 shrink-0" aria-label={size.label}>
548-
<SelectValue>{size.value} px</SelectValue>
555+
<SelectValue>{size.value === null ? "Default" : `${size.value} px`}</SelectValue>
549556
</SelectTrigger>
550557
<SelectPopup align="end" alignItemWithTrigger={false}>
558+
{size.onClear !== undefined ? (
559+
<SelectItem hideIndicator value="default">
560+
Default
561+
</SelectItem>
562+
) : null}
551563
{Array.from({ length: size.max - size.min + 1 }, (_, index) => size.min + index).map(
552564
(px) => (
553565
<SelectItem hideIndicator key={px} value={String(px)}>

‎packages/contracts/src/settings.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ export const MAX_CHAT_FONT_SIZE = 20;
172172
export const ChatFontSize = Schema.Int.check(
173173
Schema.isBetween({ minimum: MIN_CHAT_FONT_SIZE, maximum: MAX_CHAT_FONT_SIZE }),
174174
);
175-
export type ChatFontSize = typeof ChatFontSize.Type;
176-
export const DEFAULT_CHAT_FONT_SIZE: ChatFontSize = 14;
177175

178176
export const MIN_CODE_FONT_SIZE = 10;
179177
export const MAX_CODE_FONT_SIZE = 18;
@@ -440,9 +438,8 @@ export const ClientSettingsSchema = Schema.Struct({
440438
fontSizePrompt: PromptFontSize.pipe(
441439
Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROMPT_FONT_SIZE)),
442440
),
443-
fontSizeChat: ChatFontSize.pipe(
444-
Schema.withDecodingDefault(Effect.succeed(DEFAULT_CHAT_FONT_SIZE)),
445-
),
441+
// Null keeps messages on the interface size.
442+
fontSizeChat: Schema.NullOr(ChatFontSize).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
446443
fontSizeCode: CodeFontSize.pipe(
447444
Schema.withDecodingDefault(Effect.succeed(DEFAULT_CODE_FONT_SIZE)),
448445
),
@@ -1762,7 +1759,7 @@ export const ClientSettingsPatch = Schema.Struct({
17621759
onboardingCompletedAt: Schema.optionalKey(Schema.NullOr(Schema.String)),
17631760
fontSizeInterface: Schema.optionalKey(InterfaceFontSize),
17641761
fontSizePrompt: Schema.optionalKey(PromptFontSize),
1765-
fontSizeChat: Schema.optionalKey(ChatFontSize),
1762+
fontSizeChat: Schema.optionalKey(Schema.NullOr(ChatFontSize)),
17661763
fontSizeCode: Schema.optionalKey(CodeFontSize),
17671764
fontSizeTerminal: Schema.optionalKey(TerminalFontSize),
17681765
fontFamilyChat: Schema.optionalKey(FontFamilyPreference),

0 commit comments

Comments
 (0)