Skip to content

Commit 54c0bc3

Browse files
dominik-murarclaude
andcommitted
feat(web): choose a separate font for chat messages
Adds a Chat font (family and size) to Typography, shown with the other separate fonts. It applies to user and assistant messages and the new-thread heading; the rest of the UI keeps the interface font. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 97e35bc commit 54c0bc3

17 files changed

Lines changed: 141 additions & 7 deletions

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ const clientSettings: ClientSettings = {
3939
diffLayout: "stacked",
4040
environmentIdentificationMode: "artwork",
4141
favorites: [],
42+
fontFamilyChat: "",
4243
fontFamilyCode: "",
4344
fontFamilyComposer: "",
4445
fontFamilySans: "",
4546
fontFamilyTerminal: "",
47+
fontSizeChat: 14,
4648
fontSizeCode: 13,
4749
fontSizeInterface: 16,
4850
fontSizePrompt: 14,

‎apps/web/src/appInit.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,21 @@ function startClientAppearance(): void {
8383
previous?.fontFamilySans !== settings.fontFamilySans ||
8484
previous.fontFamilyCode !== settings.fontFamilyCode ||
8585
previous.fontFamilyComposer !== settings.fontFamilyComposer ||
86+
previous.fontFamilyChat !== settings.fontFamilyChat ||
8687
previous.fontSizeInterface !== settings.fontSizeInterface ||
8788
previous.fontSizePrompt !== settings.fontSizePrompt ||
89+
previous.fontSizeChat !== settings.fontSizeChat ||
8890
previous.fontSizeCode !== settings.fontSizeCode ||
8991
previous.fontSmoothing !== settings.fontSmoothing
9092
) {
9193
applyAppearanceFontVariables(root, {
9294
sans: settings.fontFamilySans,
9395
code: settings.fontFamilyCode,
9496
composer: settings.fontFamilyComposer,
97+
chat: settings.fontFamilyChat,
9598
sizeInterface: settings.fontSizeInterface,
9699
sizePrompt: settings.fontSizePrompt,
100+
sizeChat: settings.fontSizeChat,
97101
sizeCode: settings.fontSizeCode,
98102
smoothing: settings.fontSmoothing,
99103
});

‎apps/web/src/appearanceFonts.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import {
2+
DEFAULT_CHAT_FONT_SIZE,
23
DEFAULT_CODE_FONT_SIZE,
34
DEFAULT_INTERFACE_FONT_SIZE,
45
DEFAULT_PROMPT_FONT_SIZE,
6+
MAX_CHAT_FONT_SIZE,
57
MAX_CODE_FONT_SIZE,
68
MAX_INTERFACE_FONT_SIZE,
79
MAX_PROMPT_FONT_SIZE,
10+
MIN_CHAT_FONT_SIZE,
811
MIN_CODE_FONT_SIZE,
912
MIN_INTERFACE_FONT_SIZE,
1013
MIN_PROMPT_FONT_SIZE,
@@ -62,8 +65,10 @@ export interface AppearanceFontPreferences {
6265
readonly sans: string;
6366
readonly code: string;
6467
readonly composer: string;
68+
readonly chat: string;
6569
readonly sizeInterface: number;
6670
readonly sizePrompt: number;
71+
readonly sizeChat: number;
6772
readonly sizeCode: number;
6873
readonly smoothing: boolean;
6974
}
@@ -77,6 +82,7 @@ export function applyAppearanceFontVariables(
7782
["--font-sans", preferences.sans, DEFAULT_SANS_FONT_STACK],
7883
["--font-mono", preferences.code, DEFAULT_CODE_FONT_STACK],
7984
["--font-composer", preferences.composer, "var(--font-sans)"],
85+
["--font-chat", preferences.chat, "var(--font-sans)"],
8086
];
8187
for (const [variable, custom, fallback] of families) {
8288
const list = cssFontFamilies(custom);
@@ -89,6 +95,13 @@ export function applyAppearanceFontVariables(
8995

9096
root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`;
9197
root.style.setProperty("--font-size-prompt", `${clampPromptFontSize(preferences.sizePrompt)}px`);
98+
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) {
101+
root.style.removeProperty("--font-size-chat");
102+
} else {
103+
root.style.setProperty("--font-size-chat", `${chat}px`);
104+
}
92105
const code = clampCodeFontSize(preferences.sizeCode);
93106
root.style.setProperty("--font-size-code", `${code}px`);
94107
root.style.setProperty("--diffs-font-size", `${code}px`);
@@ -118,6 +131,10 @@ function clampPromptFontSize(value: number): number {
118131
return clampFontSize(value, MIN_PROMPT_FONT_SIZE, MAX_PROMPT_FONT_SIZE, DEFAULT_PROMPT_FONT_SIZE);
119132
}
120133

134+
function clampChatFontSize(value: number): number {
135+
return clampFontSize(value, MIN_CHAT_FONT_SIZE, MAX_CHAT_FONT_SIZE, DEFAULT_CHAT_FONT_SIZE);
136+
}
137+
121138
function clampCodeFontSize(value: number): number {
122139
return clampFontSize(value, MIN_CODE_FONT_SIZE, MAX_CODE_FONT_SIZE, DEFAULT_CODE_FONT_SIZE);
123140
}

‎apps/web/src/components/NoProjectsHero.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function NoProjectsHero() {
2828
<Empty size="hero" className="flex-1">
2929
<div className="w-full max-w-lg px-8 py-12">
3030
<EmptyHeader className="max-w-none">
31-
<EmptyTitle>What should we work on?</EmptyTitle>
31+
<EmptyTitle>
32+
<span className="font-chat">What should we work on?</span>
33+
</EmptyTitle>
3234
<EmptyDescription>
3335
{scratchTargetEnvironmentId === null
3436
? "Add a project to start your first thread."

‎apps/web/src/components/chat/DraftHeroHeadline.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export function DraftHeroHeadline({
387387
{projectSelector}
388388
</DraftHeroProjectHeading>
389389
) : (
390-
<h1 className="w-full text-center font-normal text-2xl text-foreground tracking-tight sm:text-3xl">
390+
<h1 className="w-full text-center font-chat font-normal text-2xl text-foreground tracking-tight sm:text-3xl">
391391
{isScratchDraft ? (
392392
<>What should we work on?</>
393393
) : canChooseProject ? (

‎apps/web/src/components/chat/DraftHeroProjectHeading.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export function DraftHeroProjectHeading({
3030
}, []);
3131

3232
return (
33-
<div ref={containerRef} className="group/draft-hero relative w-full" data-inline={fitsInline}>
33+
<div
34+
ref={containerRef}
35+
className="group/draft-hero relative w-full font-chat"
36+
data-inline={fitsInline}
37+
>
3438
<span
3539
aria-hidden="true"
3640
className="pointer-events-none invisible absolute inset-x-0 top-0 h-0 overflow-hidden"

‎apps/web/src/components/chat/TimelineAssistantRows.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function AssistantTimelineRow({ row }: { row: Extract<TimelineRow, { kind
4242
>
4343
<ChatMarkdown
4444
text={messageText}
45+
className="chat-message font-chat text-(length:--font-size-chat,var(--text-sm))"
4546
cwd={ctx.markdownCwd}
4647
threadRef={ctx.threadRef ?? undefined}
4748
isStreaming={Boolean(row.message.streaming)}

‎apps/web/src/components/chat/TimelineUserMessageRow.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ const UserMessageBody = memo(function UserMessageBody(props: {
904904
cwd={props.markdownCwd}
905905
threadRef={ctx.threadRef ?? undefined}
906906
skills={props.skills}
907-
className="text-foreground"
907+
className="chat-message font-chat text-(length:--font-size-chat,var(--text-sm)) text-foreground"
908908
lineBreaks
909909
parseRawHtml={false}
910910
renderContextReference={props.renderContextReference}

‎apps/web/src/components/chat/TriageDraftHero.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function TriageDraftHero(props: {
1515
const { copyToClipboard, isCopied } = useCopyToClipboard({ timeout: 1500, target: "command" });
1616
return (
1717
<div className="mx-auto flex w-full max-w-5xl flex-col items-center">
18-
<h1 className="w-full text-center font-normal text-2xl text-foreground tracking-tight sm:text-3xl">
18+
<h1 className="w-full text-center font-chat font-normal text-2xl text-foreground tracking-tight sm:text-3xl">
1919
What went wrong?
2020
</h1>
2121
<p className="mt-2 flex h-6 w-full items-center justify-center gap-1.5 text-sm">

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ export function PromptFontPreview() {
5454
);
5555
}
5656

57+
export function ChatFontPreview() {
58+
return (
59+
<div className="mt-1 mb-2 rounded-lg border border-border bg-background px-3 py-2 font-chat">
60+
<p className="text-xl tracking-tight">What should we build?</p>
61+
<p className="mt-1 text-(length:--font-size-chat,var(--text-sm)) leading-relaxed text-foreground/90">
62+
The flaky test raced the settings write. I moved the assertion after the commit, so it now
63+
waits on the persisted event instead of a timer.
64+
</p>
65+
</div>
66+
);
67+
}
68+
5769
const DIFF_PREVIEW_PATCH = [
5870
"diff --git a/src/formatUser.ts b/src/formatUser.ts",
5971
"--- a/src/formatUser.ts",

0 commit comments

Comments
 (0)