The best way to control Claude Code, Codex and more from any computer or phone
fix(web): the prompt box follows the interface font size (#26559)
Co-authored-by: chief-archivist <thecradlearchives@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
dw3105 committed
Oct 31, 2026 at 02:40 UTC
00b2d0e2712dc8c1724e81640c16fde27180ea17
4 files changed
+107
-24
apps/web/src/appInit.tsx
+15
-2
@@ -1,9 +1,10 @@
1
import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
2
import type { ClientSettings } from "@t3tools/contracts/settings";
3
import { createBrowserHistory, createHashHistory } from "@tanstack/react-router";
4
+import * as Schema from "effect/Schema";
5
6
import { applyAppearanceContrast } from "./appearanceContrast";
6
-import { applyAppearanceFontVariables } from "./appearanceFonts";
7
+import { applyAppearanceFontVariables, TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "./appearanceFonts";
8
import { startElectronBrowserHost } from "./browser/ElectronBrowserHost";
9
import { startBrowserProfileReporting } from "./browser/BrowserProfileReporter";
10
import { startPreviewTitleRecording } from "./browserHistoryStore";
@@ -30,6 +31,7 @@ import {
31
} from "./composerDraftStore";
32
import { startDefaultThemeAdoption } from "./hooks/useDefaultTheme";
33
import { startEnvironmentThemeRepaint } from "./hooks/useEnvironmentTheme";
34
+import { readLocalStorageValue, subscribeLocalStorageKey } from "./hooks/useLocalStorage";
35
import {
36
getClientSettings,
37
startModelPreferencesMigration,
@@ -58,10 +60,18 @@ import { resolveThreadRouteTarget } from "./threadRoutes";
60
function startClientAppearance(): void {
61
const root = document.documentElement;
62
let applied: ClientSettings | null = null;
63
+ let appliedSeparateFonts: boolean | null = null;
64
const apply = () => {
65
const settings = getClientSettings();
66
const previous = applied;
67
applied = settings;
68
+ const separateFonts = readLocalStorageValue(
69
+ TYPOGRAPHY_ADVANCED_STORAGE_KEY,
70
+ false,
71
+ Schema.Boolean,
72
+ );
73
+ const previousSeparateFonts = appliedSeparateFonts;
74
+ appliedSeparateFonts = separateFonts;
75
if (previous?.diffColorScheme !== settings.diffColorScheme) {
76
root.dataset.diffColorScheme = settings.diffColorScheme;
77
}
@@ -86,7 +96,8 @@ function startClientAppearance(): void {
96
previous.fontSizeInterface !== settings.fontSizeInterface ||
97
previous.fontSizePrompt !== settings.fontSizePrompt ||
98
previous.fontSizeCode !== settings.fontSizeCode ||
89
- previous.fontSmoothing !== settings.fontSmoothing
99
+ previous.fontSmoothing !== settings.fontSmoothing ||
100
+ previousSeparateFonts !== separateFonts
101
) {
102
applyAppearanceFontVariables(root, {
103
sans: settings.fontFamilySans,
@@ -96,10 +107,12 @@ function startClientAppearance(): void {
107
sizePrompt: settings.fontSizePrompt,
108
sizeCode: settings.fontSizeCode,
109
smoothing: settings.fontSmoothing,
110
+ separate: separateFonts,
111
});
112
}
113
};
114
subscribeClientSettings(apply);
115
+ subscribeLocalStorageKey(TYPOGRAPHY_ADVANCED_STORAGE_KEY, apply);
116
apply();
117
}
118
apps/web/src/appearanceFonts.browser.test.ts
new
+55
@@ -0,0 +1,55 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+
3
+import "~/index.css";
4
+import { applyAppearanceFontVariables } from "./appearanceFonts";
5
+
6
+function renderedFontSize(style: (probe: HTMLElement) => void): string {
7
+ const probe = document.createElement("div");
8
+ style(probe);
9
+ document.body.append(probe);
10
+ try {
11
+ return getComputedStyle(probe).fontSize;
12
+ } finally {
13
+ probe.remove();
14
+ }
15
+}
16
+
17
+const composerFontSize = () =>
18
+ renderedFontSize((probe) => {
19
+ // The composer editor's own size class.
20
+ probe.className = "text-(length:--font-size-prompt,var(--text-sm))";
21
+ });
22
+
23
+const touchComposerFontSize = () =>
24
+ renderedFontSize((probe) => {
25
+ probe.style.fontSize = "var(--font-size-prompt-touch)";
26
+ });
27
+
28
+describe("applyAppearanceFontVariables", () => {
29
+ it("sizes the composer from the interface size until fonts are set separately", () => {
30
+ const root = document.documentElement;
31
+ const style = root.getAttribute("style");
32
+ const preferences = {
33
+ sans: "",
34
+ code: "",
35
+ composer: "",
36
+ sizeInterface: 20,
37
+ sizePrompt: 14,
38
+ sizeCode: 13,
39
+ smoothing: true,
40
+ };
41
+ try {
42
+ applyAppearanceFontVariables(root, { ...preferences, separate: false });
43
+ expect(composerFontSize()).toBe("17.5px");
44
+ expect(touchComposerFontSize()).toBe("17.5px");
45
+
46
+ applyAppearanceFontVariables(root, { ...preferences, separate: true });
47
+ expect(composerFontSize()).toBe("14px");
48
+ // iOS zooms into inputs under 16px.
49
+ expect(touchComposerFontSize()).toBe("16px");
50
+ } finally {
51
+ if (style === null) root.removeAttribute("style");
52
+ else root.setAttribute("style", style);
53
+ }
54
+ });
55
+});
apps/web/src/appearanceFonts.ts
+7
-3
@@ -66,9 +66,10 @@ export interface AppearanceFontPreferences {
66
readonly sizePrompt: number;
67
readonly sizeCode: number;
68
readonly smoothing: boolean;
69
+ readonly separate: boolean;
70
}
71
71
-/** Always writes sizes: interface size sets the root; prompt and code use pixels to avoid double scaling. */
72
+/** Interface size sets the root; prompt and code use pixels to avoid double scaling. */
73
export function applyAppearanceFontVariables(
74
root: HTMLElement,
75
preferences: AppearanceFontPreferences,
@@ -76,7 +77,7 @@ export function applyAppearanceFontVariables(
77
const families: ReadonlyArray<readonly [variable: string, custom: string, fallback: string]> = [
78
["--font-sans", preferences.sans, DEFAULT_SANS_FONT_STACK],
79
["--font-mono", preferences.code, DEFAULT_CODE_FONT_STACK],
79
- ["--font-composer", preferences.composer, "var(--font-sans)"],
80
+ ["--font-composer", preferences.separate ? preferences.composer : "", "var(--font-sans)"],
81
];
82
for (const [variable, custom, fallback] of families) {
83
const list = cssFontFamilies(custom);
@@ -88,7 +89,10 @@ export function applyAppearanceFontVariables(
89
}
90
91
root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`;
91
- root.style.setProperty("--font-size-prompt", `${clampPromptFontSize(preferences.sizePrompt)}px`);
92
+ root.style.setProperty(
93
+ "--font-size-prompt",
94
+ preferences.separate ? `${clampPromptFontSize(preferences.sizePrompt)}px` : "var(--text-sm)",
95
+ );
96
const code = clampCodeFontSize(preferences.sizeCode);
97
root.style.setProperty("--font-size-code", `${code}px`);
98
root.style.setProperty("--diffs-font-size", `${code}px`);
apps/web/src/hooks/useLocalStorage.ts
+30
-19
@@ -123,6 +123,35 @@ function decodeOrInitial<T, E>(
123
}
124
}
125
126
+export function readLocalStorageValue<T, E>(
127
+ key: string,
128
+ initialValue: T,
129
+ schema: Schema.Codec<T, E>,
130
+): T {
131
+ return decodeOrInitial(key, schema, readSerializedValue(key), initialValue);
132
+}
133
+
134
+/** Fires on writes from this tab and from other tabs. */
135
+export function subscribeLocalStorageKey(key: string, onChange: () => void): () => void {
136
+ const handleStorageChange = (event: StorageEvent) => {
137
+ if (event.key === key) {
138
+ onChange();
139
+ }
140
+ };
141
+ const handleLocalChange = (event: CustomEvent<LocalStorageChangeDetail>) => {
142
+ if (event.detail.key === key) {
143
+ onChange();
144
+ }
145
+ };
146
+
147
+ window.addEventListener("storage", handleStorageChange);
148
+ window.addEventListener(LOCAL_STORAGE_CHANGE_EVENT, handleLocalChange as EventListener);
149
+ return () => {
150
+ window.removeEventListener("storage", handleStorageChange);
151
+ window.removeEventListener(LOCAL_STORAGE_CHANGE_EVENT, handleLocalChange as EventListener);
152
+ };
153
+}
154
+
155
export function writeLocalStorageValue<T, E>(
156
key: string,
157
value: T | ((val: T) => T),
@@ -169,25 +198,7 @@ export function useLocalStorage<T, E>(
198
): [T, (value: T | ((val: T) => T)) => void] {
199
const getSnapshot = () => readSerializedValue(key);
200
172
- const subscribe = (onStoreChange: () => void) => {
173
- const handleStorageChange = (event: StorageEvent) => {
174
- if (event.key === key) {
175
- onStoreChange();
176
- }
177
- };
178
- const handleLocalChange = (event: CustomEvent<LocalStorageChangeDetail>) => {
179
- if (event.detail.key === key) {
180
- onStoreChange();
181
- }
182
- };
183
-
184
- window.addEventListener("storage", handleStorageChange);
185
- window.addEventListener(LOCAL_STORAGE_CHANGE_EVENT, handleLocalChange as EventListener);
186
- return () => {
187
- window.removeEventListener("storage", handleStorageChange);
188
- window.removeEventListener(LOCAL_STORAGE_CHANGE_EVENT, handleLocalChange as EventListener);
189
- };
190
- };
201
+ const subscribe = (onStoreChange: () => void) => subscribeLocalStorageKey(key, onStoreChange);
202
203
const serializedValue = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
204
const storedValue = decodeOrInitial(key, schema, serializedValue, initialValue);