Repository navigation
feat: add interface, monospace, and code font preferences - #4666
Conversation
| @@ -0,0 +1,169 @@ | |||
| <script lang="ts"> | |||
| import { browser } from '$app/env'; | |||
There was a problem hiding this comment.
$app/env is not a SvelteKit module. The current module is $app/environment, and $app/env was removed long ago. This import will fail to resolve, which breaks the Vite build and the account preferences page that imports the picker.
import { browser } from '$app/environment';| import { browser } from '$app/env'; | |
| import { browser } from '$app/environment'; |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
5b92a91 to
f9f71ff
Compare
| if (/^(['"])[^'"]+\1$/.test(name) || GENERIC_FONT_FAMILIES.has(name.toLowerCase())) { | ||
| return name; | ||
| } | ||
|
|
||
| if (/['"]/.test(name)) { | ||
| return null; |
There was a problem hiding this comment.
Fonts with apostrophes are rejected
quoteFontFamily rejects names containing an apostrophe even when enclosed in double quotes. For example, "O'Brien" is a valid quoted family, but the picker shows an error. The same check also filters these fonts out of the installed-font list.
Allow the other quote character inside a quoted family, and safely quote raw installed names.
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/lib/utils/theme.svelte.ts
Line: 368-373
Comment:
**Fonts with apostrophes are rejected**
`quoteFontFamily` rejects names containing an apostrophe even when enclosed in double quotes. For example, `"O'Brien"` is a valid quoted family, but the picker shows an error. The same check also filters these fonts out of the installed-font list.
Allow the other quote character inside a quoted family, and safely quote raw installed names.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.- Add font pickers for interface, monospace, and code text in account preferences - Accept installed font names, validated on the client and in the user API - Fall back to CJK system fonts, ordered by the document language - Apply fonts through CSS variables; the terminal picks up the code font on reopen
- Validate custom and installed font names, and accept comma-separated font stacks - Quote multi-word family names and pass generic families (serif, monospace, etc.) through unquoted - Localize the Montserrat and Geist Mono preset labels - Keep the bundled Montserrat and Geist Mono as fallbacks ahead of CJK fonts when a custom font is set - Cover setting, persisting, and resetting the interface font in the account e2e spec
28c48db to
d399dd9
Compare
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Checklist
mainbranchm.*())What This PR Implements
Adds per-user font preferences for interface text, monospace/headings, and the code editor and terminal. Also adds locale-ordered system font fallbacks so Chinese, Japanese, and Korean text uses a matching system font.
Addresses: #4604 (discussion)
Changes Made
interfaceFont,monospaceFont, andcodeFontonUserPreferences(types/user.go,frontend/src/lib/types/user.ts). They are stored in the existing JSON column, so no migration is needed. Values are limited to 128 characters from letters, digits, spaces, and_ ' " , -, which keeps them from injecting CSS.applyFontsintheme.svelte.tssets--font-sans-user,--font-mono-user, and--font-code-useron:rootand writes them to the appearance cache. Theapp.htmlpre-paint script restores them before first paint.user-store.svelte.tsapplies them on load and clears them on logout.layout.cssputs the user font first, then the bundled font, then a CJK fallback. The CJK order follows<html lang>, which now tracks the active locale.var(--font-code). The terminal reads--font-codewhen it mounts, so a change takes effect the next time the terminal opens.font-family-picker.svelteappears on the account preferences panel. Options are Default, System UI, Montserrat, Geist Mono, and Custom. Custom accepts any typed font name. Where the browser supportsqueryLocalFonts, it also offers a searchable list of installed fonts.Testing Done
Ran:
just format alljust lint frontend: svelte-check reports 0 errors and 0 warningsAdded:
TestUserProfileValidationAndPersistenceinbackend/internal/user/service_test.gonow round-trips the three font fields throughUpdateUserandToUserResponseDto.Not yet run:
just test backendjust lint allNot yet verified manually:
AI Tool Used (if applicable)
N/A
Additional Context
--font-codestill names'Mona Sans Mono', which is not bundled. This predates the PR, and the fallback stack covers it. Left unchanged.queryLocalFontsis Chromium-only. The browse button is hidden elsewhere, but typed font names still work.Disclaimer Greptiles Reviews use AI, make sure to check over its work.
To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike
To have Greptile Re-Review the changes, mention
greptileai.

Confidence Score: 5/5 
The PR appears safe to merge, with a non-blocking fix needed for font names containing apostrophes.Fix with agent prompt
Summary
Adds per-user interface, monospace, and code fonts.
kmendell intentionally limits terminal font updates to reopening and leaves the existing unbundled
Mona Sans Monofallback unchanged.Verification was limited to source review. Tests and browser captures were not run; frontend dependencies were absent, and no development stack was started.
Reviews (2) · Last reviewed commit: "feat: allow custom interface font with v..." · Reviewed by Greptile