feat(web): configurable fonts and sizes under Settings → Appearance #5103
main fromrefs/pull/5103/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/appearanceFonts.ts line 121OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +101,21 @@101+ { label: "IBM Plex Mono", family: "IBM Plex Mono" },102+ { label: "Ubuntu Mono", family: "Ubuntu Mono" },103+ { label: "Courier New", family: "Courier New" },104+];105+106+export function isFontFamilyAvailable(family: string): boolean {107+ const families = cssFontFamilies(family);108+ if (families === null) return false;109+ // Generic keywords always resolve.110+ if (/^(system-ui|sans-serif|serif|monospace|ui-monospace)$/i.test(families)) return true;111+ try {112+ return document.fonts.check(`12px ${families}`);113+ } catch {114+ return false;115+ }116+}117+118+/** Webfonts the app bundles; offered even before document.fonts has loaded them. */119+const BUNDLED_FAMILIES = new Set(["DM Sans", "JetBrains Mono"]);120+121+export function availableFontOptions(options: readonly FontOption[]): readonly FontOption[] {
StiensWout(GitHub profile, opens in a new tab) changed the title
- apps/web/src/components/settings/SettingsPanels.tsx line 964OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -951,3 +961,4 @@951961 const { theme, setTheme } = useTheme();952962 const settings = usePrimarySettings();953963 const updateSettings = useUpdatePrimarySettings();964+ const sansOptions = useMemo(() => availableFontOptions(SANS_FONT_OPTIONS), []);apps/web/src/components/ThreadTerminalDrawer.tsx line 395OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -380,3 +390,6 @@380390 const setup = async (): Promise<(() => void) | null> => {381391 const terminalOptions: GhosttyTerminalSurfaceOptions = {382392 theme: terminalThemeFromApp(mount),393+ ...(terminalFontFamilyRef.current.length > 0394+ ? { font: { family: terminalFontFamilyRef.current } }395+ : {}),apps/web/src/components/settings/SettingsPanels.tsx line 1342OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1115,0 +1322,21 @@1322+ {options.map((option) => (1323+ <SelectItem hideIndicator key={option.family} value={option.family}>1324+ <span style={{ fontFamily: option.family }}>{option.label}</span>1325+ </SelectItem>1326+ ))}1327+ <SelectItem hideIndicator value={CUSTOM_FONT_VALUE}>1328+ Custom…1329+ </SelectItem>1330+ </SelectPopup>1331+ </Select>1332+ {customMode ? (1333+ <Input1334+ aria-label={`${title} custom family`}1335+ autoCapitalize="off"1336+ autoComplete="off"1337+ onChange={(event) => onValueChange(event.currentTarget.value)}1338+ placeholder="Font family name"1339+ spellCheck={false}1340+ value={value}1341+ />1342+ ) : null}apps/web/src/components/settings/SettingsPanels.tsx line 974OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -951,3 +961,14 @@951961 const { theme, setTheme } = useTheme();952962 const settings = usePrimarySettings();953963 const updateSettings = useUpdatePrimarySettings();964+ const sansOptions = useMemo(() => availableFontOptions(SANS_FONT_OPTIONS), []);965+ const monoOptions = useMemo(() => availableFontOptions(MONO_FONT_OPTIONS), []);966+ const composerOptions = useMemo(967+ () => [...sansOptions, ...monoOptions],968+ [monoOptions, sansOptions],969+ );970+ const sansStack = appearanceFontStack(settings.fontFamilySans, DEFAULT_SANS_FONT_STACK);971+ const composerStack =972+ settings.fontFamilyComposer.trim().length > 0973+ ? appearanceFontStack(settings.fontFamilyComposer, DEFAULT_SANS_FONT_STACK)974+ : sansStack;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/web/src/components/settings/SettingsPanels.tsx line 1407OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -1115,0 +1387,21 @@1387+ <SelectItem hideIndicator value={CUSTOM_FONT_VALUE}>1388+ Custom…1389+ </SelectItem>1390+ </SelectPopup>1391+ </Select>1392+ {showCustomInput ? (1393+ <Input1394+ aria-label={`${title} custom family`}1395+ aria-invalid={draftPending || undefined}1396+ autoCapitalize="off"1397+ autoComplete="off"1398+ onChange={(event) => {1399+ const next = event.currentTarget.value;1400+ // Latch custom mode so clearing the text keeps the field open.1401+ setCustomMode(true);1402+ setCustomDraft(next);1403+ // Commit only names that resolve to an installed font; the1404+ // current font holds while a partial or unknown name is typed.1405+ if (next.trim().length > 0 && isFontFamilyAvailable(next)) {1406+ onValueChange(next);1407+ }
StiensWout(GitHub profile, opens in a new tab) changed the title
StiensWout(GitHub profile, opens in a new tab) changed the title
- apps/web/src/components/settings/SettingsPanels.tsx line 1400OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1115,0 +1380,21 @@1380+ // after mount, so a persisted custom family must reveal the input on its own.1381+ const showCustomInput = customMode || (trimmed.length > 0 && !matchesOption);1382+ const draftTrimmed = customDraft.trim();1383+ // Flag an unknown name only once typing pauses, not on every keystroke.1384+ const draftPending = draftSettled && showCustomInput && draftTrimmed !== trimmed;1385+ const categories = fontOptionCategories(options);1386+ const selected =1387+ trimmed.length === 0 && !customMode1388+ ? DEFAULT_FONT_VALUE1389+ : customMode || !matchesOption1390+ ? CUSTOM_FONT_VALUE1391+ : trimmed;1392+ return (1393+ <SettingsRow1394+ title={title}1395+ description={description}1396+ resetAction={1397+ trimmed.length > 0 || customMode ? (1398+ <SettingResetButton1399+ label={`${title.toLowerCase()} family`}1400+ onClick={() => {
- apps/web/src/components/settings/SettingsPanels.tsx line 1466OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1115,0 +1446,21 @@1446+ commitTimerRef.current = null;1447+ }1448+ setCustomDraft(value);1449+ setDraftSettled(true);1450+ if (trimmed.length === 0) setCustomMode(false);1451+ }1452+ }}1453+ placeholder="Font family name"1454+ spellCheck={false}1455+ value={customDraft}1456+ />1457+ <Tooltip>1458+ <TooltipTrigger1459+ render={1460+ <Button1461+ aria-label={`Choose ${title.toLowerCase()} from the list`}1462+ className="size-8 shrink-0 text-muted-foreground hover:text-foreground"1463+ onClick={() => {1464+ setCustomMode(false);1465+ onValueChange("");1466+ }}apps/web/src/components/settings/SettingsPanels.tsx line 1450OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1115,0 +1430,21 @@1430+ }1431+ commitTimerRef.current = window.setTimeout(() => {1432+ commitTimerRef.current = null;1433+ commitDraft(next);1434+ }, 400);1435+ }}1436+ onKeyDown={(event) => {1437+ if (event.key === "Enter") flushDraft();1438+ if (event.key === "Escape") {1439+ // Discard uncommitted typing without leaving the settings1440+ // page (Escape closes it), and drop back to the list only1441+ // when there is no committed family to return to.1442+ event.preventDefault();1443+ event.stopPropagation();1444+ if (commitTimerRef.current !== null) {1445+ window.clearTimeout(commitTimerRef.current);1446+ commitTimerRef.current = null;1447+ }1448+ setCustomDraft(value);1449+ setDraftSettled(true);1450+ if (trimmed.length === 0) setCustomMode(false);apps/web/src/components/settings/SettingsPanels.tsx line 1420OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1115,0 +1400,21 @@1400+ <SettingResetButton1401+ label={`${title.toLowerCase()} family`}1402+ onClick={() => {1403+ setCustomMode(false);1404+ onValueChange("");1405+ }}1406+ />1407+ ) : null1408+ }1409+ control={1410+ // The custom input replaces the dropdown rather than stacking under it,1411+ // so entering custom mode does not change the row height.1412+ <div className="flex w-full items-center gap-1.5 sm:w-56">1413+ {showCustomInput ? (1414+ <>1415+ <Input1416+ aria-label={`${title} custom family`}1417+ aria-invalid={draftPending || undefined}1418+ autoCapitalize="off"1419+ autoComplete="off"1420+ autoFocus@@ -1014,5 +1018,5 @@1014101810151019 pre,10161020 code {1017- font-family:1018- "SF Mono", "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;1021+ font-family: var(--font-mono);1022+ font-size-adjust: var(--font-mono-adjust, none);
- apps/web/src/components/settings/SettingsPanels.tsx line 622Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -585,4 +614,14 @@585614 ? ["Project Grouping"]586615 : []),587616 ...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),617+ ...(settings.fontFamilySans !== DEFAULT_UNIFIED_SETTINGS.fontFamilySans618+ ? ["Interface font"]619+ : []),620+ ...(settings.fontFamilyComposer !== DEFAULT_UNIFIED_SETTINGS.fontFamilyComposer621+ ? ["Prompt font"]622+ : []),623+ ...(settings.fontFamilyCode !== DEFAULT_UNIFIED_SETTINGS.fontFamilyCode ? ["Code font"] : []),624+ ...(settings.fontFamilyTerminal !== DEFAULT_UNIFIED_SETTINGS.fontFamilyTerminal625+ ? ["Terminal font"]626+ : []),588627 ...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace
- apps/web/src/components/settings/SettingsPanels.tsx line 672Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -628,3 +667,11 @@628667 settings.newWorktreesStartFromOrigin,629668 settings.diffIgnoreWhitespace,630669 settings.environmentIdentificationMode,670+ settings.fontFamilyCode,671+ settings.fontFamilyComposer,672+ settings.fontFamilySans,673+ settings.fontFamilyTerminal,674+ settings.fontSizeCode,675+ settings.fontSizeInterface,676+ settings.fontSizePrompt,677+ settings.fontSizeTerminal,@@ -0,0 +75,21 @@75+ const families: ReadonlyArray<readonly [variable: string, custom: string, fallback: string]> = [76+ ["--font-sans", preferences.sans, DEFAULT_SANS_FONT_STACK],77+ ["--font-mono", preferences.code, DEFAULT_CODE_FONT_STACK],78+ // The composer falls back to whatever the sans preference resolves to.79+ ["--font-composer", preferences.composer, "var(--font-sans)"],80+ ];81+ for (const [variable, custom, fallback] of families) {82+ const list = cssFontFamilies(custom);83+ if (list === null) {84+ root.style.removeProperty(variable);85+ } else {86+ root.style.setProperty(variable, `${list}, ${fallback}`);87+ }88+ }89+90+ root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`;91+ root.style.setProperty("--font-size-prompt", `${clampPromptFontSize(preferences.sizePrompt)}px`);92+ const code = clampCodeFontSize(preferences.sizeCode);93+ root.style.setProperty("--font-size-code", `${code}px`);94+ // The @pierre/diffs surfaces read their own hook for code text.95+ root.style.setProperty("--diffs-font-size", `${code}px`);
- apps/web/src/components/BranchToolbarEnvironmentSelector.tsx line 57Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -49,4 +49,6 @@4949 ) : (5050 <CloudIcon className="size-3 shrink-0" />5151 )}52- <span className="truncate">{activeEnvironment?.label ?? "Run on"}</span>52+ <span className="truncate @max-[38rem]/composer-context:hidden">53+ {activeEnvironment?.label ?? "Run on"}54+ </span>apps/web/src/components/BranchToolbarBranchSelector.tsx line 757Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -749,4 +749,6 @@749749 disabled={isInitialBranchesLoadPending || isBranchActionPending}750750 >751751 <GitBranchIcon className="size-3 shrink-0 opacity-70" />752- <span className="min-w-0 max-w-[240px] truncate">{triggerLabel}</span>752+ <span className="min-w-0 max-w-[240px] truncate @max-[38rem]/composer-context:hidden">753+ {triggerLabel}754+ </span>apps/web/src/components/BranchToolbarEnvModeSelector.tsx line 95OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -92,4 +92,4 @@9292 ) : (9393 <FolderIcon className="size-3" />9494 )}95- <SelectValue />95+ <span className="@max-[38rem]/composer-context:hidden">
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/web/src/components/BranchToolbar.tsx line 226OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -214,3 +214,13 @@214214 );215215 });216216217+/**218+ * Collapse the strip's labels to icons only once they actually stop fitting.219+ * The natural width is remembered from the last expanded measurement, so the220+ * hidden labels cannot shrink the content and flip the decision straight back.221+ */222+function useLabelsOverflow(ref: RefObject<HTMLDivElement | null>): boolean {223+ const [overflows, setOverflows] = useState(false);224+ const naturalWidthRef = useRef(0);225+226+ useEffect(() => {
- apps/web/src/components/BranchToolbar.tsx line 257Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -216,0 +225,21 @@225+226+ useEffect(() => {227+ const element = ref.current;228+ if (!element) return;229+230+ const measure = () => {231+ const available = element.clientWidth;232+ if (available === 0) return;233+ if (!overflows) {234+ // Labels truncate rather than overflow, so the strip's own scrollWidth235+ // never grows. Sum how much each label is clipped by instead: that236+ // deficit plus the current width is what the row really needs.237+ let deficit = 0;238+ for (const label of element.querySelectorAll<HTMLElement>("[data-composer-label]")) {239+ deficit += Math.max(0, label.scrollWidth - label.clientWidth);240+ }241+ naturalWidthRef.current = available + deficit;242+ }243+ if (naturalWidthRef.current === 0) return;244+ setOverflows(naturalWidthRef.current > available + 1);245+ };apps/web/src/components/BranchToolbar.tsx line 244OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -216,0 +224,21 @@224+ const naturalWidthRef = useRef(0);225+226+ useEffect(() => {227+ const element = ref.current;228+ if (!element) return;229+230+ const measure = () => {231+ const available = element.clientWidth;232+ if (available === 0) return;233+ if (!overflows) {234+ // Labels truncate rather than overflow, so the strip's own scrollWidth235+ // never grows. Sum how much each label is clipped by instead: that236+ // deficit plus the current width is what the row really needs.237+ let deficit = 0;238+ for (const label of element.querySelectorAll<HTMLElement>("[data-composer-label]")) {239+ deficit += Math.max(0, label.scrollWidth - label.clientWidth);240+ }241+ naturalWidthRef.current = available + deficit;242+ }243+ if (naturalWidthRef.current === 0) return;244+ setOverflows(naturalWidthRef.current > available + 1);
- apps/web/src/terminal/ghostty/surface.ts line 88Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -62,3 +67,19 @@67+ const bare = name.trim();68+ if (bare.length === 0) return "";69+ if (/^(['"]).*\1$/.test(bare)) return bare;70+ if (/^[a-zA-Z][a-zA-Z0-9-]*$/.test(bare)) return bare;71+ return `"${bare.replaceAll('"', "")}"`;72+ })73+ .filter((name) => name.length > 0)74+ .join(", ");75+}76+6277 export function terminalFontFamily(family?: string): string {63- const custom = family?.trim();64- if (!custom) return DEFAULT_TERMINAL_FONT_FAMILY;78+ // Quote non-ident names ("3270 Nerd Font", "M+ 1m"): an unquoted one makes79+ // the whole canvas font string invalid and the assignment silently no-ops.80+ const custom = family === undefined ? "" : quoteTerminalFontFamilies(family);81+ if (custom.length === 0) return DEFAULT_TERMINAL_FONT_FAMILY;82+ // The grid places the cursor and selection on one cell advance, so a83+ // proportional face would draw its text narrower than its own cells. Refuse84+ // it here rather than render a ragged grid with a stranded cursor.85+ if (!isMonospaceFamily(custom)) return DEFAULT_TERMINAL_FONT_FAMILY;
StiensWout(GitHub profile, opens in a new tab) changed the title
- apps/web/src/components/settings/SettingsPanels.tsx lines 1282 to 1282OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -1111,0 +1262,21 @@1262+ <span className="text-muted-foreground">2</span>1263+ {" "}1264+ <span className="text-info">return</span>{" "}1265+ <span className="text-success">{"`${user.name} <${user.email}>`"}</span>{" "}1266+ <span className="text-muted-foreground">{"// 0O 1lI"}</span>1267+ {"\n"}1268+ <span className="text-muted-foreground">3</span>1269+ {" "}1270+ <span className="text-muted-foreground">{"}"}</span>1271+ </code>1272+ </pre>1273+ </FontPreviewCard>1274+ }1275+ />1276+ <FontFamilySettingsRow1277+ title="Terminal font"1278+ description="Terminal output."1279+ options={monoFontOptions}1280+ value={settings.fontFamilyTerminal}1281+ onValueChange={(fontFamilyTerminal) => updateSettings({ fontFamilyTerminal })}1282+ requireMonospace
- @@ -1014,5 +1015,12 @@1014101510151016 pre,10161017 code {1017- font-family:1018- "SF Mono", "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;1018+ font-family: var(--font-mono);1019+}1020+1021+/* Code text carries the size preference too. Block code and highlighted chat1022+ blocks take it directly; inline code stays relative to its sentence so it1023+ never towers over the prose around it. */1024+pre {1025+ font-size: var(--font-size-code, inherit);1026+}apps/web/src/components/settings/SettingsPanels.tsx line 1361OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -1115,0 +1341,21 @@1341+ if (!element) return;1342+ const handle = () => commitDraft();1343+ element.addEventListener("change", handle);1344+ return () => element.removeEventListener("change", handle);1345+ }, []);1346+ const ratio = (shown - min) / (max - min);1347+ const style = {1348+ "--settings-slider-progress": `${ratio * 100}%`,1349+ "--settings-slider-fill-offset": `${0.5 - ratio}rem`,1350+ } as CSSProperties;1351+ return (1352+ <div className="flex w-full items-center gap-3">1353+ <input1354+ ref={inputRef}1355+ aria-label={label}1356+ className="settings-slider min-w-0 flex-1"1357+ max={max}1358+ min={min}1359+ onChange={(event) => {1360+ const next = Number(event.currentTarget.value);1361+ if (Number.isInteger(next) && next >= min && next <= max) setDraft(next);apps/web/src/components/BranchToolbar.tsx line 285Resolvedby StiensWout(GitHub profile, opens in a new tab)@@ -216,0 +258,21 @@258+ const stripGap = Number.parseFloat(getComputedStyle(current).columnGap) || 0;259+ let needed = 0;260+ let groups = 0;261+ for (const child of current.children) {262+ if (!(child instanceof HTMLElement) || child.offsetWidth <= 1) continue;263+ needed += contentWidth(child);264+ groups += 1;265+ }266+ needed += stripGap * Math.max(0, groups - 1);267+ for (const label of current.querySelectorAll<HTMLElement>("[data-composer-label]")) {268+ if (compact) {269+ // Compact: the label is squeezed to zero width, but scrollWidth still270+ // reports the full text it would need when expanded.271+ needed += label.scrollWidth;272+ } else {273+ // Expanded: the label is in flow but truncates; only the clipped274+ // remainder is missing from the content sum.275+ needed += Math.max(0, label.scrollWidth - label.clientWidth);276+ }277+ }278+ setOverflows(compact ? needed > available - COMPACT_EXPAND_HYSTERESIS_PX : needed > available);
- apps/web/src/index.css lines 1082 to 1086OutdatedResolvedby StiensWout(GitHub profile, opens in a new tab)@@ -1049,3 +1069,18 @@10491069 background: var(--app-scrollbar-thumb-hover);10501070 }105110711072+/* Settings -> Appearance can point the composer at its own face (for example a1073+ mono font); default follows the sans stack. Applied on the surface wrapper so1074+ the editor and its placeholder inherit together. */1075+.composer-editor-surface {1076+ font-family: var(--font-composer, var(--font-sans));1077+ font-size: var(--font-size-prompt, 0.875rem);1078+}1079+1080+/* Phone browsers zoom the page when a focused field is under 16px, so keep the1081+ floor there regardless of the preference. */1082+@media (max-width: 39.999rem) {1083+ .composer-editor-surface {1084+ font-size: max(var(--font-size-prompt, 1rem), 16px);1085+ }1086+}
- apps/web/src/components/settings/SettingsFontPreviews.tsx line 216Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +169,21 @@169+ theme: terminalThemeFromApp(mount),170+ font: previewTerminalFont(fontRef.current.family, fontRef.current.size),171+ onData: echo,172+ onResize: noop,173+ onSelectionChange: noop,174+ onCopy: (text) => void navigator.clipboard?.writeText(text).catch(noop),175+ // Tab keeps walking the settings page instead of feeding the echo loop.176+ beforeKey: (event) => event.key !== "Tab",177+ onLinkActivate: noop,178+ }).then((surface) => {179+ if (cancelled) {180+ surface.dispose();181+ return;182+ }183+ surfaceRef.current = surface;184+ // The theme and font may both have changed while the WASM surface loaded.185+ surface.setTheme(terminalThemeFromApp(mount));186+ const font = fontRef.current;187+ void surface.setFont(previewTerminalFont(font.family, font.size));188+ surface.write(TERMINAL_PREVIEW_TRANSCRIPT);189+ });
- apps/web/src/components/settings/FontFamilyPicker.tsx line 163Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +104,21 @@104+ if (enumeration.status !== "granted") return [];105+ return requireMonospace ? enumeration.families.filter(isMonospaceFamily) : enumeration.families;106+ }, [enumeration, requireMonospace]);107+108+ const items = useMemo(() => {109+ const trimmedQuery = query.trim().toLowerCase();110+ const result: string[] = [];111+ if (trimmedQuery.length === 0) result.push(DEFAULT_FONT_VALUE);112+ result.push(113+ ...families.filter(114+ (family) => trimmedQuery.length === 0 || family.toLowerCase().includes(trimmedQuery),115+ ),116+ );117+ return result;118+ }, [query, families]);119+120+ const selectedValue = selectedFamily.length === 0 ? DEFAULT_FONT_VALUE : selectedFamily;121+122+ const handlePick = (value: string) => {123+ setOpen(false);124+ onSelect(value === DEFAULT_FONT_VALUE ? "" : value);
- apps/web/src/components/settings/FontFamilyPicker.tsx line 63OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +43,21 @@43+ return enumerationState;44+}45+46+let enumerationLoad: Promise<void> | null = null;47+48+/** Query installed fonts; call from a user gesture (the permission prompt needs one). */49+export function discoverInstalledFonts(): void {50+ if (enumerationState.status !== "unknown" || enumerationLoad !== null) return;51+ enumerationLoad = queryInstalledFontFamilies().then((result) => {52+ enumerationState =53+ result.status === "granted"54+ ? { status: "granted", families: result.families }55+ : { status: "unavailable" };56+ enumerationLoad = null;57+ for (const listener of enumerationListeners) listener();58+ });59+}60+61+/**62+ * Whether the engine can list installed fonts (Local Font Access API —63+ * Chromium and Electron). "unknown" until a row's input is focused andapps/desktop/src/preview/BrowserSession.ts lines 29 to 29OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -23,3 +23,7 @@2323 "clipboard-sanitized-write",2424 "notifications",2525 "geolocation",26+ // Local Font Access (queryLocalFonts). Both handlers again: the API27+ // consults the permission check before ever raising a request, and a28+ // denied check resolves with an empty font list rather than an error.29+ "local-fonts",
- @@ -0,0 +144,21 @@144+ <span className="text-[10px] text-muted-foreground/60">default</span>145+ ) : null}146+ {item === selectedValue ? (147+ <CheckIcon className="size-3.5 text-muted-foreground" />148+ ) : null}149+ </span>150+ </div>151+ </ComboboxItem>152+ );153+ };154+155+ return (156+ <Combobox157+ items={items}158+ filteredItems={items}159+ autoHighlight160+ virtualized161+ open={open}162+ onOpenChange={handleOpenChange}163+ value={selectedValue}164+ >
- @@ -0,0 +38,21 @@38+ enumerationListeners.add(listener);39+ return () => enumerationListeners.delete(listener);40+}41+42+function readEnumerationState(): FontEnumerationState {43+ return enumerationState;44+}45+46+let enumerationLoad: Promise<void> | null = null;47+48+/** Query installed fonts; call from a user gesture (the permission prompt needs one). */49+export function discoverInstalledFonts(): void {50+ if (enumerationState.status !== "unknown" || enumerationLoad !== null) return;51+ enumerationLoad = queryInstalledFontFamilies().then((result) => {52+ enumerationState =53+ result.status === "granted"54+ ? { status: "granted", families: result.families }55+ : { status: "unavailable" };56+ enumerationLoad = null;57+ for (const listener of enumerationListeners) listener();58+ });
- @@ -0,0 +6,21 @@6+ */7+8+import {9+ DEFAULT_CODE_FONT_SIZE,10+ DEFAULT_INTERFACE_FONT_SIZE,11+ DEFAULT_PROMPT_FONT_SIZE,12+ MAX_CODE_FONT_SIZE,13+ MAX_INTERFACE_FONT_SIZE,14+ MAX_PROMPT_FONT_SIZE,15+ MIN_CODE_FONT_SIZE,16+ MIN_INTERFACE_FONT_SIZE,17+ MIN_PROMPT_FONT_SIZE,18+} from "@t3tools/contracts";19+20+export const DEFAULT_SANS_FONT_STACK =21+ '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif';22+23+// Concrete names first: some engines alias `ui-monospace` to the24+// proportional system UI font, which would break every code surface.25+export const DEFAULT_CODE_FONT_STACK =26+ '"SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace';apps/web/src/components/composerInlineChip.ts line 11Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1,8 +1,11 @@1+// Chip metrics are in em so the pills scale with the text they sit in (the2+// composer honors the prompt font-size preference). The chat variant pins the3+// original 12px, where every em value resolves to the same pixels as before.14 const INLINE_CHIP_CLASS_NAME =2- "inline-flex max-w-full items-center gap-1 rounded-md border border-border/70 bg-accent/40 px-1.5 py-px font-medium text-[12px] leading-[1.1] text-foreground align-middle";5+ "inline-flex max-w-full items-center gap-[0.33em] rounded-[0.5em] border border-border/70 bg-accent/40 px-[0.5em] py-[0.08em] font-medium leading-[1.1] text-foreground align-middle";364-export const CHAT_INLINE_CHIP_CLASS_NAME = INLINE_CHIP_CLASS_NAME;7+export const CHAT_INLINE_CHIP_CLASS_NAME = `${INLINE_CHIP_CLASS_NAME} text-[12px]`;586-export const COMPOSER_INLINE_CHIP_CLASS_NAME = `${INLINE_CHIP_CLASS_NAME} select-none`;9+export const COMPOSER_INLINE_CHIP_CLASS_NAME = `${INLINE_CHIP_CLASS_NAME} text-[0.86em] select-none`;7108-export const COMPOSER_INLINE_CHIP_ICON_CLASS_NAME = "size-3.5 shrink-0 opacity-85";11+export const COMPOSER_INLINE_CHIP_ICON_CLASS_NAME = "size-[1.17em] shrink-0 opacity-85";
- @@ -1109 +1335,21 @@1335+1336+/**1337+ * The two-font view: one sans, one monospace. The prompt follows the1338+ * interface font and the terminal follows the monospace font, so the demos1339+ * under each row show every surface the choice reaches.1340+ */1341+function SimpleFontRows() {1342+ const settings = usePrimarySettings();1343+ return (1344+ <>1345+ <InterfaceFontRow preview={<PromptFontPreview />} />1346+ <CodeFontRow1347+ title="Monospace font"1348+ description="Code blocks, diffs, file previews, and the terminal."1349+ preview={1350+ <>1351+ <CodeFontPreview />1352+ <TerminalFontPreview1353+ family={settings.fontFamilyTerminal.trim() || settings.fontFamilyCode}1354+ size={settings.fontSizeTerminal}11091355 />
- @@ -1108,0 +1202,21 @@1202+ }}1203+ preview={<PromptFontPreview />}1204+ />1205+ );1206+}1207+1208+function CodeFontRow({1209+ title,1210+ description = "Code blocks, diffs, and file previews.",1211+ preview,1212+}: {1213+ title?: string;1214+ description?: string;1215+ preview?: ReactNode;1216+}) {1217+ const settings = usePrimarySettings();1218+ const updateSettings = useUpdatePrimarySettings();1219+ const defaults = useFontDefaultFamilies();1220+ return (1221+ <FontFamilySettingsRow1222+ {...(title === undefined ? searchableSetting("code-font") : { title })}@@ -1109,0 +1359,21 @@1359+ </>1360+ );1361+}1362+1363+const ADVANCED_TYPOGRAPHY_TARGET_IDS = new Set(["prompt-font", "terminal-font", "font-smoothing"]);1364+1365+/**1366+ * The two-font view by default - one sans, one monospace, each cascading to1367+ * every surface it reaches - with an Advanced switch in the section header1368+ * that reveals the per-surface override rows. The choice persists locally,1369+ * and a settings-search jump to an override row flips Advanced on so the1370+ * target exists to scroll to.1371+ */1372+function TypographySection() {1373+ const [advanced, setAdvanced] = useState(readTypographyAdvanced);1374+ const searchTargetId = useSettingsSearchTargetId();1375+ const searchWantsAdvancedRow =1376+ searchTargetId !== null && ADVANCED_TYPOGRAPHY_TARGET_IDS.has(searchTargetId);1377+ useEffect(() => {1378+ if (searchWantsAdvancedRow && !advanced) setAdvanced(true);1379+ }, [searchWantsAdvancedRow, advanced]);@@ -28,3 +28,21 @@2828 return lastEnabledMode === "repository_path" ? "repository_path" : "repository";2929 }303031+const TYPOGRAPHY_ADVANCED_KEY = "t3code:typography-advanced";32+33+/** Whether Settings -> Typography last showed the per-surface override rows. */34+export function readTypographyAdvanced(): boolean {35+ try {36+ return localStorage.getItem(TYPOGRAPHY_ADVANCED_KEY) === "true";37+ } catch {38+ return false;39+ }40+}41+42+export function rememberTypographyAdvanced(advanced: boolean): void {43+ try {44+ localStorage.setItem(TYPOGRAPHY_ADVANCED_KEY, String(advanced));45+ } catch {46+ // Storage can be unavailable in restricted browser contexts.47+ }48+}
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
8d549a6f-3824-4f8b-9a41-f675fb1ef973You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share