Skip to content

Commit 379f8d2

Browse files
superbicheclaude
andcommitted
feat(web): size conversation text independently
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 701fc83 commit 379f8d2

15 files changed

Lines changed: 272 additions & 47 deletions

‎apps/web/src/appearanceFonts.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { describe, expect, it } from "vite-plus/test";
22

33
import {
4+
type AppearanceFontPreferences,
5+
applyAppearanceFontVariables,
46
areFontAdvancesMonospace,
57
clampCodeFontSize,
68
clampInterfaceFontSize,
@@ -123,3 +125,57 @@ describe("font size clamping", () => {
123125
expect(clampPromptFontSize(Number.POSITIVE_INFINITY)).toBe(14);
124126
});
125127
});
128+
129+
describe("conversation font size", () => {
130+
const preferences: AppearanceFontPreferences = {
131+
sans: "",
132+
code: "",
133+
composer: "",
134+
sizeInterface: 16,
135+
sizeConversation: null,
136+
sizePrompt: 14,
137+
sizeCode: 13,
138+
smoothing: true,
139+
};
140+
141+
function createRoot() {
142+
const properties = new Map<string, string>();
143+
const style = {
144+
fontSize: "",
145+
setProperty: (name: string, value: string) => properties.set(name, value),
146+
removeProperty: (name: string) => properties.delete(name),
147+
};
148+
const root = style as unknown as CSSStyleDeclaration;
149+
return {
150+
apply(next: AppearanceFontPreferences) {
151+
applyAppearanceFontVariables({ style: root } as HTMLElement, next);
152+
return {
153+
fontSize: style.fontSize,
154+
conversation: properties.get("--font-size-conversation"),
155+
};
156+
},
157+
};
158+
}
159+
160+
it("leaves the conversation on the interface size until one is chosen", () => {
161+
expect(createRoot().apply({ ...preferences, sizeInterface: 18 })).toEqual({
162+
fontSize: "18px",
163+
conversation: undefined,
164+
});
165+
});
166+
167+
it("keeps an explicit conversation size when the interface size changes", () => {
168+
const root = createRoot();
169+
expect(root.apply({ ...preferences, sizeConversation: 18 }).conversation).toBe("18px");
170+
expect(root.apply({ ...preferences, sizeInterface: 13, sizeConversation: 18 })).toEqual({
171+
fontSize: "13px",
172+
conversation: "18px",
173+
});
174+
});
175+
176+
it("clears an explicit size on reset and clamps out-of-range values", () => {
177+
const root = createRoot();
178+
expect(root.apply({ ...preferences, sizeConversation: 40 }).conversation).toBe("20px");
179+
expect(root.apply(preferences).conversation).toBeUndefined();
180+
});
181+
});

‎apps/web/src/appearanceFonts.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export interface AppearanceFontPreferences {
8282
readonly code: string;
8383
readonly composer: string;
8484
readonly sizeInterface: number;
85+
/** Null follows the interface size. */
86+
readonly sizeConversation: number | null;
8587
readonly sizePrompt: number;
8688
readonly sizeCode: number;
8789
/** Grayscale `antialiased` rendering; false keeps the heavier platform default. */
@@ -94,7 +96,9 @@ export interface AppearanceFontPreferences {
9496
*
9597
* Sizes are always written: the interface size drives the root font size (and
9698
* with it every rem-based dimension), while the prompt and code sizes stay in
97-
* absolute pixels so they do not scale twice.
99+
* absolute pixels so they do not scale twice. The conversation size is the
100+
* exception: unset, `[data-conversation-font-scope]` falls back to the
101+
* interface's rem values unchanged.
98102
*/
99103
export function applyAppearanceFontVariables(
100104
root: HTMLElement,
@@ -116,6 +120,14 @@ export function applyAppearanceFontVariables(
116120
}
117121

118122
root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`;
123+
if (preferences.sizeConversation === null) {
124+
root.style.removeProperty("--font-size-conversation");
125+
} else {
126+
root.style.setProperty(
127+
"--font-size-conversation",
128+
`${clampInterfaceFontSize(preferences.sizeConversation)}px`,
129+
);
130+
}
119131
root.style.setProperty("--font-size-prompt", `${clampPromptFontSize(preferences.sizePrompt)}px`);
120132
const code = clampCodeFontSize(preferences.sizeCode);
121133
root.style.setProperty("--font-size-code", `${code}px`);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
6060
additions={summaryStat.additions}
6161
deletions={summaryStat.deletions}
6262
layout="inline"
63-
className="text-xs leading-4"
63+
className="text-xs"
6464
/>
6565
)}
6666
</div>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6783,6 +6783,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
67836783
<ComposerBanner.Attachment>
67846784
<ComposerBanner.Root
67856785
data-chat-composer-top-drawer="true"
6786+
data-conversation-font-scope
6787+
// The banner's fixed rem leading would clip a larger conversation size.
6788+
className="text-xs"
67866789
variant={activePendingApproval ? "warning" : "info"}
67876790
density={activePendingApproval ? "spacious" : "default"}
67886791
>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
16301630
<TooltipScrollDismissArea
16311631
ref={setTimelineViewportElement}
16321632
className="relative h-full min-h-0"
1633+
data-conversation-font-scope
16331634
data-assistant-citation-viewport="true"
16341635
>
16351636
{onCiteAssistantText && citationThreadRef ? (
@@ -1988,12 +1989,12 @@ function TimelineMinimap({
19881989
}}
19891990
>
19901991
<span className="dropdown-glass block rounded-xl p-3 text-left text-popover-foreground shadow-xl shadow-black/25">
1991-
<span className="block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium leading-5">
1992+
<span className="block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium">
19921993
{activeItem.userText ?? "User message"}
19931994
</span>
19941995
{activeItem.assistantText ? (
19951996
<span
1996-
className="mt-1 max-h-[3.75rem] overflow-hidden text-muted-foreground text-sm leading-5"
1997+
className="mt-1 max-h-[3lh] overflow-hidden text-muted-foreground text-sm"
19971998
style={{
19981999
display: "-webkit-box",
19992000
WebkitBoxOrient: "vertical",
@@ -3807,7 +3808,7 @@ function WorkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "workin
38073808
);
38083809
return (
38093810
<div className="border-b border-border/60 pb-2 pt-1">
3810-
<div className="flex h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed text-muted-foreground tabular-nums">
3811+
<div className="flex min-h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed text-muted-foreground tabular-nums">
38113812
<span
38123813
ref={shimmer ? observeVisibleAnimation : undefined}
38133814
className="relative shrink-0 overflow-hidden whitespace-nowrap"
@@ -4953,7 +4954,7 @@ function UserMessageReviewCommentCard({ comment }: { comment: ReviewCommentConte
49534954
</DiffWorkerPoolProvider>
49544955
)}
49554956
{renderablePatch?.kind === "raw" && (
4956-
<pre className="overflow-x-auto rounded-md bg-muted/40 p-2 text-xs">
4957+
<pre className="overflow-x-auto rounded-md bg-muted/40 p-2 text-(length:--font-size-code)">
49574958
{renderablePatch.text}
49584959
</pre>
49594960
)}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ export function SnapShotAttachmentDetails({
155155
</div>
156156
)}
157157
<div className="min-w-0 flex-1">
158-
<div className="flex min-w-0 items-center gap-1.5 text-2xs font-medium leading-3.5 text-white">
158+
<div className="flex min-w-0 items-center gap-1.5 text-2xs font-medium leading-tight text-white">
159159
<span className="truncate">{source.appName}</span>
160160
<SnapShotContentsButton source={source} className="pointer-events-auto" />
161161
</div>
162-
<div className="truncate text-3xs leading-3.5 text-white/70">
162+
<div className="truncate text-3xs text-white/70">
163163
{source.windowTitle || "Captured window"}
164164
</div>
165165
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function SetupHeaderRow({
143143
<div className="border-b border-border/60 pb-2 pt-1">
144144
<div
145145
className={cn(
146-
"flex h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed tabular-nums",
146+
"flex min-h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed tabular-nums",
147147
tone,
148148
)}
149149
>

‎apps/web/src/components/settings/SettingsPanels.logic.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ describe("typography settings restore", () => {
3131
}),
3232
).toEqual(["Interface font", "Code font"]);
3333
});
34+
35+
it("restores an explicit conversation size apart from the interface font", () => {
36+
expect(
37+
getChangedTypographySettingLabels({
38+
...DEFAULT_UNIFIED_SETTINGS,
39+
fontSizeConversation: DEFAULT_UNIFIED_SETTINGS.fontSizeInterface,
40+
}),
41+
).toEqual(["Conversation font"]);
42+
});
3443
});
3544

3645
describe("background activity settings restore", () => {

‎apps/web/src/components/settings/SettingsPanels.logic.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type TypographySettings = Pick<
8181
| "fontFamilyCode"
8282
| "fontFamilyTerminal"
8383
| "fontSizeInterface"
84+
| "fontSizeConversation"
8485
| "fontSizePrompt"
8586
| "fontSizeCode"
8687
| "fontSizeTerminal"
@@ -93,6 +94,9 @@ export function getChangedTypographySettingLabels(settings: TypographySettings):
9394
settings.fontSizeInterface !== DEFAULT_UNIFIED_SETTINGS.fontSizeInterface
9495
? ["Interface font"]
9596
: []),
97+
...(settings.fontSizeConversation !== DEFAULT_UNIFIED_SETTINGS.fontSizeConversation
98+
? ["Conversation font"]
99+
: []),
96100
...(settings.fontFamilyComposer !== DEFAULT_UNIFIED_SETTINGS.fontFamilyComposer ||
97101
settings.fontSizePrompt !== DEFAULT_UNIFIED_SETTINGS.fontSizePrompt
98102
? ["Prompt font"]

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

Lines changed: 102 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ export function useSettingsRestore(onRestored?: () => void) {
698698
settings.fontFamilySans,
699699
settings.fontFamilyTerminal,
700700
settings.fontSizeCode,
701+
settings.fontSizeConversation,
701702
settings.fontSizeInterface,
702703
settings.fontSizePrompt,
703704
settings.fontSizeTerminal,
@@ -838,6 +839,7 @@ export function useSettingsRestore(onRestored?: () => void) {
838839
fontFamilyCode: DEFAULT_UNIFIED_SETTINGS.fontFamilyCode,
839840
fontFamilyTerminal: DEFAULT_UNIFIED_SETTINGS.fontFamilyTerminal,
840841
fontSizeInterface: DEFAULT_UNIFIED_SETTINGS.fontSizeInterface,
842+
fontSizeConversation: DEFAULT_UNIFIED_SETTINGS.fontSizeConversation,
841843
fontSizePrompt: DEFAULT_UNIFIED_SETTINGS.fontSizePrompt,
842844
fontSizeCode: DEFAULT_UNIFIED_SETTINGS.fontSizeCode,
843845
fontSizeTerminal: DEFAULT_UNIFIED_SETTINGS.fontSizeTerminal,
@@ -1569,6 +1571,42 @@ function InterfaceFontRow({ preview }: { preview?: ReactNode }) {
15691571
);
15701572
}
15711573

1574+
function ConversationFontRow() {
1575+
const settings = useScopedSettings();
1576+
const updateSettings = useUpdateScopedSettings();
1577+
return (
1578+
<SettingsRow
1579+
{...searchableSetting("conversation-font")}
1580+
description="Messages, tool activity, agent questions, and approvals. Follows the interface size unless set."
1581+
resetAction={
1582+
settings.fontSizeConversation !== DEFAULT_UNIFIED_SETTINGS.fontSizeConversation ? (
1583+
<SettingResetButton
1584+
label="conversation font size"
1585+
onClick={() =>
1586+
updateSettings({
1587+
fontSizeConversation: DEFAULT_UNIFIED_SETTINGS.fontSizeConversation,
1588+
})
1589+
}
1590+
/>
1591+
) : null
1592+
}
1593+
control={
1594+
<FontSizeSelect
1595+
label="Conversation font size"
1596+
min={MIN_INTERFACE_FONT_SIZE}
1597+
max={MAX_INTERFACE_FONT_SIZE}
1598+
value={settings.fontSizeConversation}
1599+
onChange={(fontSizeConversation) => updateSettings({ fontSizeConversation })}
1600+
follow={{
1601+
label: "Interface",
1602+
onSelect: () => updateSettings({ fontSizeConversation: null }),
1603+
}}
1604+
/>
1605+
}
1606+
/>
1607+
);
1608+
}
1609+
15721610
function PromptFontRow() {
15731611
const settings = useScopedSettings();
15741612
const updateSettings = useUpdateScopedSettings();
@@ -1741,6 +1779,7 @@ function FontSettingsGroup() {
17411779
return (
17421780
<>
17431781
<InterfaceFontRow />
1782+
<ConversationFontRow />
17441783
<PromptFontRow />
17451784
<CodeFontRow />
17461785
<TerminalFontRow />
@@ -1759,6 +1798,7 @@ function SimpleFontRows() {
17591798
return (
17601799
<>
17611800
<InterfaceFontRow preview={<PromptFontPreview />} />
1801+
<ConversationFontRow />
17621802
<CodeFontRow
17631803
title="Monospace font"
17641804
description="Code blocks, diffs, file previews, and the terminal."
@@ -1999,29 +2039,13 @@ function FontFamilySettingsRow({
19992039
const control = (
20002040
<div className="flex w-full items-center gap-2 sm:w-auto">
20012041
<div className="min-w-0 flex-1 sm:w-44 sm:flex-none">{familyControl}</div>
2002-
<Select
2003-
value={String(size.value)}
2004-
onValueChange={(next) => {
2005-
if (typeof next !== "string") return;
2006-
const parsed = Number(next);
2007-
if (Number.isInteger(parsed) && parsed >= size.min && parsed <= size.max) {
2008-
size.onChange(parsed);
2009-
}
2010-
}}
2011-
>
2012-
<SelectTrigger size="sm" className="w-22 shrink-0" aria-label={size.label}>
2013-
<SelectValue>{size.value} px</SelectValue>
2014-
</SelectTrigger>
2015-
<SelectPopup align="end" alignItemWithTrigger={false}>
2016-
{Array.from({ length: size.max - size.min + 1 }, (_, index) => size.min + index).map(
2017-
(px) => (
2018-
<SelectItem hideIndicator key={px} value={String(px)}>
2019-
{px} px
2020-
</SelectItem>
2021-
),
2022-
)}
2023-
</SelectPopup>
2024-
</Select>
2042+
<FontSizeSelect
2043+
label={size.label}
2044+
min={size.min}
2045+
max={size.max}
2046+
value={size.value}
2047+
onChange={size.onChange}
2048+
/>
20252049
</div>
20262050
);
20272051
return (
@@ -2037,6 +2061,61 @@ function FontFamilySettingsRow({
20372061
);
20382062
}
20392063

2064+
const FOLLOW_FONT_SIZE_VALUE = "follow";
2065+
2066+
/**
2067+
* Pixel size picker for the typography rows. With `follow`, a null value is
2068+
* offered as a choice that tracks another size instead of storing its own.
2069+
*/
2070+
function FontSizeSelect({
2071+
label,
2072+
min,
2073+
max,
2074+
value,
2075+
onChange,
2076+
follow,
2077+
}: {
2078+
label: string;
2079+
min: number;
2080+
max: number;
2081+
value: number | null;
2082+
onChange: (value: number) => void;
2083+
follow?: { label: string; onSelect: () => void };
2084+
}) {
2085+
return (
2086+
<Select
2087+
value={value === null ? FOLLOW_FONT_SIZE_VALUE : String(value)}
2088+
onValueChange={(next) => {
2089+
if (typeof next !== "string") return;
2090+
if (next === FOLLOW_FONT_SIZE_VALUE) {
2091+
follow?.onSelect();
2092+
return;
2093+
}
2094+
const parsed = Number(next);
2095+
if (Number.isInteger(parsed) && parsed >= min && parsed <= max) {
2096+
onChange(parsed);
2097+
}
2098+
}}
2099+
>
2100+
<SelectTrigger size="sm" className="w-22 shrink-0" aria-label={label}>
2101+
<SelectValue>{value === null ? follow?.label : `${value} px`}</SelectValue>
2102+
</SelectTrigger>
2103+
<SelectPopup align="end" alignItemWithTrigger={false}>
2104+
{follow ? (
2105+
<SelectItem hideIndicator value={FOLLOW_FONT_SIZE_VALUE}>
2106+
{follow.label}
2107+
</SelectItem>
2108+
) : null}
2109+
{Array.from({ length: max - min + 1 }, (_, index) => min + index).map((px) => (
2110+
<SelectItem hideIndicator key={px} value={String(px)}>
2111+
{px} px
2112+
</SelectItem>
2113+
))}
2114+
</SelectPopup>
2115+
</Select>
2116+
);
2117+
}
2118+
20402119
const AUTO_SETTLE_DEFAULT_DAYS = DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays ?? 3;
20412120

20422121
function AutoSettleDaysInput({

0 commit comments

Comments
 (0)