Skip to content

Commit 450d86d

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

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
@@ -6869,6 +6869,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
68696869
<ComposerBanner.Attachment>
68706870
<ComposerBanner.Root
68716871
data-chat-composer-top-drawer="true"
6872+
data-conversation-font-scope
6873+
// The banner's fixed rem leading would clip a larger conversation size.
6874+
className="text-xs"
68726875
variant={activePendingApproval ? "warning" : "info"}
68736876
density={activePendingApproval ? "spacious" : "default"}
68746877
>

‎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",
@@ -3809,7 +3810,7 @@ function WorkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "workin
38093810
);
38103811
return (
38113812
<div className="border-b border-border/60 pb-2 pt-1">
3812-
<div className="flex h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed text-muted-foreground tabular-nums">
3813+
<div className="flex min-h-6 min-w-0 items-baseline gap-2 px-1 text-sm leading-relaxed text-muted-foreground tabular-nums">
38133814
<span
38143815
ref={shimmer ? observeVisibleAnimation : undefined}
38153816
className="relative shrink-0 overflow-hidden whitespace-nowrap"
@@ -4955,7 +4956,7 @@ function UserMessageReviewCommentCard({ comment }: { comment: ReviewCommentConte
49554956
</DiffWorkerPoolProvider>
49564957
)}
49574958
{renderablePatch?.kind === "raw" && (
4958-
<pre className="overflow-x-auto rounded-md bg-muted/40 p-2 text-xs">
4959+
<pre className="overflow-x-auto rounded-md bg-muted/40 p-2 text-(length:--font-size-code)">
49594960
{renderablePatch.text}
49604961
</pre>
49614962
)}

‎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
@@ -702,6 +702,7 @@ export function useSettingsRestore(onRestored?: () => void) {
702702
settings.fontFamilySans,
703703
settings.fontFamilyTerminal,
704704
settings.fontSizeCode,
705+
settings.fontSizeConversation,
705706
settings.fontSizeInterface,
706707
settings.fontSizePrompt,
707708
settings.fontSizeTerminal,
@@ -844,6 +845,7 @@ export function useSettingsRestore(onRestored?: () => void) {
844845
fontFamilyCode: DEFAULT_UNIFIED_SETTINGS.fontFamilyCode,
845846
fontFamilyTerminal: DEFAULT_UNIFIED_SETTINGS.fontFamilyTerminal,
846847
fontSizeInterface: DEFAULT_UNIFIED_SETTINGS.fontSizeInterface,
848+
fontSizeConversation: DEFAULT_UNIFIED_SETTINGS.fontSizeConversation,
847849
fontSizePrompt: DEFAULT_UNIFIED_SETTINGS.fontSizePrompt,
848850
fontSizeCode: DEFAULT_UNIFIED_SETTINGS.fontSizeCode,
849851
fontSizeTerminal: DEFAULT_UNIFIED_SETTINGS.fontSizeTerminal,
@@ -1576,6 +1578,42 @@ function InterfaceFontRow({ preview }: { preview?: ReactNode }) {
15761578
);
15771579
}
15781580

1581+
function ConversationFontRow() {
1582+
const settings = useScopedSettings();
1583+
const updateSettings = useUpdateScopedSettings();
1584+
return (
1585+
<SettingsRow
1586+
{...searchableSetting("conversation-font")}
1587+
description="Messages, tool activity, agent questions, and approvals. Follows the interface size unless set."
1588+
resetAction={
1589+
settings.fontSizeConversation !== DEFAULT_UNIFIED_SETTINGS.fontSizeConversation ? (
1590+
<SettingResetButton
1591+
label="conversation font size"
1592+
onClick={() =>
1593+
updateSettings({
1594+
fontSizeConversation: DEFAULT_UNIFIED_SETTINGS.fontSizeConversation,
1595+
})
1596+
}
1597+
/>
1598+
) : null
1599+
}
1600+
control={
1601+
<FontSizeSelect
1602+
label="Conversation font size"
1603+
min={MIN_INTERFACE_FONT_SIZE}
1604+
max={MAX_INTERFACE_FONT_SIZE}
1605+
value={settings.fontSizeConversation}
1606+
onChange={(fontSizeConversation) => updateSettings({ fontSizeConversation })}
1607+
follow={{
1608+
label: "Interface",
1609+
onSelect: () => updateSettings({ fontSizeConversation: null }),
1610+
}}
1611+
/>
1612+
}
1613+
/>
1614+
);
1615+
}
1616+
15791617
function PromptFontRow() {
15801618
const settings = useScopedSettings();
15811619
const updateSettings = useUpdateScopedSettings();
@@ -1748,6 +1786,7 @@ function FontSettingsGroup() {
17481786
return (
17491787
<>
17501788
<InterfaceFontRow />
1789+
<ConversationFontRow />
17511790
<PromptFontRow />
17521791
<CodeFontRow />
17531792
<TerminalFontRow />
@@ -1766,6 +1805,7 @@ function SimpleFontRows() {
17661805
return (
17671806
<>
17681807
<InterfaceFontRow preview={<PromptFontPreview />} />
1808+
<ConversationFontRow />
17691809
<CodeFontRow
17701810
title="Monospace font"
17711811
description="Code blocks, diffs, file previews, and the terminal."
@@ -2006,29 +2046,13 @@ function FontFamilySettingsRow({
20062046
const control = (
20072047
<div className="flex w-full items-center gap-2 sm:w-auto">
20082048
<div className="min-w-0 flex-1 sm:w-44 sm:flex-none">{familyControl}</div>
2009-
<Select
2010-
value={String(size.value)}
2011-
onValueChange={(next) => {
2012-
if (typeof next !== "string") return;
2013-
const parsed = Number(next);
2014-
if (Number.isInteger(parsed) && parsed >= size.min && parsed <= size.max) {
2015-
size.onChange(parsed);
2016-
}
2017-
}}
2018-
>
2019-
<SelectTrigger size="sm" className="w-22 shrink-0" aria-label={size.label}>
2020-
<SelectValue>{size.value} px</SelectValue>
2021-
</SelectTrigger>
2022-
<SelectPopup align="end" alignItemWithTrigger={false}>
2023-
{Array.from({ length: size.max - size.min + 1 }, (_, index) => size.min + index).map(
2024-
(px) => (
2025-
<SelectItem hideIndicator key={px} value={String(px)}>
2026-
{px} px
2027-
</SelectItem>
2028-
),
2029-
)}
2030-
</SelectPopup>
2031-
</Select>
2049+
<FontSizeSelect
2050+
label={size.label}
2051+
min={size.min}
2052+
max={size.max}
2053+
value={size.value}
2054+
onChange={size.onChange}
2055+
/>
20322056
</div>
20332057
);
20342058
return (
@@ -2044,6 +2068,61 @@ function FontFamilySettingsRow({
20442068
);
20452069
}
20462070

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

20492128
function AutoSettleDaysInput({

0 commit comments

Comments
 (0)