Repository navigation
feat(editor): give the file editor its own font weight and line height - #20188
PedroOsnaghi wants to merge 4 commits into
Conversation
Orca already lets the editor opt out of the terminal font family and size, but never passed fontWeight to Monaco, so code was locked to the terminal weight. Add `editorFontWeight`, opt-in and defaulting to 0 so an unset value keeps following `terminalFontWeight` exactly as before. Resolution reuses normalizeTerminalFontWeight, so the editor shares the terminal's 100-900 clamp instead of duplicating validation. Family and weight now resolve together through resolveEditorFontOptions() because every Monaco surface sets both. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H2vx5fRYojVWDseDMtzPgV
…ht field The unset state reached NumberField as NaN, and its render-phase sync compares with `!==`, where `NaN !== NaN` is always true — so it set state on every render and tripped React's re-render limit as soon as Settings opened. NumberField already documents `undefined` as its empty sentinel; use that instead of inventing one. Pass the live terminal weight as `defaultValue` so the row reads like the terminal's own weight field. This setting has no fixed default of its own — empty inherits — so showing the resolved number beats leaving the user to guess what "same as terminal" currently is. Add es/fr/ja/ko/zh entries, reusing each locale's existing wording for "font weight" and for the sibling editor font family setting. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H2vx5fRYojVWDseDMtzPgV
The greyed number in the empty field already says what the editor resolves to, so the "Default: 500" hint underneath repeated it. Drop the hint and let the placeholder carry it, which also reads closer to the terminal's own weight field. Removes the now-unused placeholder string from all six catalogs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H2vx5fRYojVWDseDMtzPgV
Fixes the second half of Monaco never receiving the terminal's typography: Orca passes fontSize and fontFamily but no lineHeight, so the file view always uses Monaco's platform ratio (1.5 on macOS, 1.35 elsewhere) and reads ~25% airier than a terminal pane at Line Height 1. Add `editorLineHeight` as a multiplier of the font size, defaulting to 0 — which Monaco reads as "compute from the font size", so existing profiles keep the exact spacing they have today instead of re-flowing every open file on upgrade. Scoped to the file editor on purpose: diff views size their virtualized rows from a fixed DIFF_LINE_HEIGHT in diff-section-layout.ts, so making their line height configurable would desync the height estimates from what Monaco actually renders. That belongs in its own change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H2vx5fRYojVWDseDMtzPgV
There was a problem hiding this comment.
Important
The new default editorFontWeight: 0 is not inert. Before this PR Monaco was never given a fontWeight, so it rendered at its own default normal (400); with this default the resolver now returns the terminal weight, which defaults to 500. Existing users' file-editor and diff text therefore changes weight on upgrade even though they never touch the setting — contrary to the "nothing changes until opt-in" contract in the PR body.
Reviewed changes
- Weight + line-height settings —
editorFontWeightandeditorLineHeightadded to the shared settings type and defaults, with resolvers ineditor-font-zoom.tsthat reusenormalizeTerminalFontWeightand clamp line height to a 1–3 multiplier. - Monaco wiring — weight reaches the file editor (
MonacoEditor.tsx), diff views (DiffViewer.tsx,DiffSectionBody.tsx), code excerpts (MonacoCodeExcerpt.tsx,AutomationEditorPromptEditor.tsx) and notebooks (IpynbCellEditor.tsx); line height reaches only the file editor, with diff views deliberately excluded. - Settings UI + i18n — two
NumberFieldrows beside Editor Font Family, showing the inherited weight / automatic ratio as the placeholder, plus search entries, labels, and en/es/fr/ja/ko/zh strings. - Tests — resolver, settings-render, and mocked-Monaco options coverage for both knobs; all pass locally along with the localization and default-settings suites.
<!--
Pullfrog review metadata. These findings were written against ab2ca94;
if commits have landed on feat/editor-font-weight since, treat every specific bug, file, or
line callout as POTENTIALLY STALE and re-diff before acting on it.
- Mode: Review (initial)
- Files reviewed: 29
- Commits reviewed: 4
- Base: main (556a777)
- Head: feat/editor-font-weight (ab2ca94)
- Reviewed commits:
- 3fe3cdc191 — feat(settings): give the code editor its own font weight
- 0c76f0ae7e — fix(settings): show the inherited weight and localize the editor weight field
- c7ef520658 — refactor(settings): show the inherited editor weight as the placeholder
- ab2ca944df — feat(editor): let the file editor set its own line height
- Prior pullfrog review: none
-->
ℹ️ Nitpicks
- The
## Visual Proofsection still contains only the<!-- BEFORE / AFTER -->placeholder; a screenshot of General → Editor with a pinned and an inheriting row would make the UI change reviewable at a glance.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| // Why empty: the editor keeps following the terminal font unless the user opts in. | ||
| editorFontFamily: '', | ||
| // Why zero: the editor keeps following the terminal font weight unless the user opts in. | ||
| editorFontWeight: 0, |
There was a problem hiding this comment.
This default is documented as keeping the editor following the terminal, but the base editor never received a fontWeight option — Monaco rendered at its own default normal (400). With editorFontWeight: 0, resolveEditorFontWeight() now returns the terminal weight (default 500), so every existing user's editor and diff text silently changes weight on upgrade. Please confirm that is intended (and correct the PR body's "nothing changes" claim), or have the resolver preserve normal when editorFontWeight is 0.
Technical details
# `editorFontWeight: 0` is not an inert default
## Affected sites
- `src/shared/default-global-settings.ts:56` — `editorFontWeight: 0`, commented as "keeps following the terminal font weight".
- `src/renderer/src/lib/editor-font-zoom.ts:67-75` — `0`/unset falls through to `settings.terminalFontWeight`, then `normalizeTerminalFontWeight`.
- `src/shared/terminal-fonts.ts:1` — `DEFAULT_TERMINAL_FONT_WEIGHT = 500`.
- `node_modules/monaco-editor/esm/vs/editor/common/config/fontInfo.js:166` — absent option defaults to `fontWeight: 'normal'` (400).
- `src/renderer/src/components/editor/MonacoEditor.font-weight.test.tsx:73-82` — asserts `'600'` for `editorFontWeight: 0, terminalFontWeight: 600`, encoding the changed default.
## Required outcome
- Decide whether the editor should inherit the terminal weight by default. If yes, the behavior change is fine but the PR/issue "invisible until opt-in" framing must be corrected, because users with `terminalFontWeight !== 400` see a different editor on upgrade.
- If the change is meant to be strictly opt-in, resolve to `'normal'` when `editorFontWeight` is `0`/unset and inherit only for a positive/opted-in value.| ariaLabel: 'Prompt', | ||
| fontFamily: 'Geist', | ||
| fontSize: 14, | ||
| fontWeight: '500', |
There was a problem hiding this comment.
fontWeight is now a required option, but the test only supplies the argument — it never asserts options.fontWeight, so it would still pass if buildAutomationPromptEditorOptions dropped the field. Add expect(options.fontWeight).toBe('500').
📝 WalkthroughWalkthroughThe change adds optional editor font-weight and line-height settings with defaults that preserve terminal font-weight inheritance and Monaco automatic spacing. Shared resolvers normalize these values and expose combined font options. Settings controls, search entries, labels, and translations expose both settings. Monaco editors, diff editors, notebook cells, code excerpts, and automation prompt editors receive the resolved typography options. Tests cover normalization, settings behavior, and editor integration. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to Users who set editor line height can receive a 1–3px editor row height instead of the selected multiplier, making the file editor difficult to use. Compute and consistently use an effective pixel height before merge. 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
Full details: Linked Issues checkExplanation The implementation satisfies Resolution Keep the setting value as a multiplier, but convert an opted-in value to the corresponding pixel line height before assigning Monaco's Full details: Out of Scope Changes checkExplanation Most changes support Full details: Docstring CoverageExplanation Docstring coverage is 20.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 23 files. (6 skipped: 6 unsupported.)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/renderer/src/components/automations/automation-editor-prompt-options.test.ts (1)
11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the
fontWeightpass-through.This test supplies
fontWeight: '500', but does not verify the returned value. Add the assertion below so a regression that drops this pass-through does not leave the test green.♻️ Proposed fix
expect(options.fontFamily).toBe('Geist') expect(options.fontSize).toBe(14) + expect(options.fontWeight).toBe('500') expect(options.placeholder).toBe('Run the weekly dependency audit')src/renderer/src/components/editor/MonacoEditor.font-weight.test.tsx (1)
5-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCentralize the MonacoEditor test fixture.
AGENTS.mdrequires reusing or generalizing existing implementations instead of creating parallel copies. Four MonacoEditor tests duplicate the same mocks and render setup. Extract a named fixture such asmonaco-editor-test-fixture.tsxwith settings overrides, then migrate all four tests to it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 12b14c9a-5ced-475f-ac6c-3db790ecdf62
📒 Files selected for processing (29)
src/renderer/src/components/automations/AutomationEditorPromptEditor.tsxsrc/renderer/src/components/automations/automation-editor-prompt-options.test.tssrc/renderer/src/components/automations/automation-editor-prompt-options.tssrc/renderer/src/components/editor/DiffSectionBody.tsxsrc/renderer/src/components/editor/DiffSectionItem.tsxsrc/renderer/src/components/editor/DiffViewer.tsxsrc/renderer/src/components/editor/IpynbCellEditor.tsxsrc/renderer/src/components/editor/MonacoCodeExcerpt.tsxsrc/renderer/src/components/editor/MonacoEditor.font-weight.test.tsxsrc/renderer/src/components/editor/MonacoEditor.line-height.test.tsxsrc/renderer/src/components/editor/MonacoEditor.tsxsrc/renderer/src/components/editor/diff-section-item-props.tssrc/renderer/src/components/settings/EditorFontWeightSetting.test.tsxsrc/renderer/src/components/settings/EditorFontWeightSetting.tsxsrc/renderer/src/components/settings/EditorLineHeightSetting.test.tsxsrc/renderer/src/components/settings/EditorLineHeightSetting.tsxsrc/renderer/src/components/settings/GeneralEditorSettingsSection.tsxsrc/renderer/src/components/settings/general-editor-search.tssrc/renderer/src/components/settings/setting-labels.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/editor-font-zoom.test.tssrc/renderer/src/lib/editor-font-zoom.tssrc/shared/default-global-settings.tssrc/shared/global-settings-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| fontSize: editorFontSize, | ||
| fontFamily: editorFontFamily, | ||
| fontWeight: editorFontWeight, | ||
| lineHeight: editorLineHeight, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Pass one effective pixel line height to Monaco and auto-height calculations.
resolveEditorLineHeight returns a 0–3 multiplier, but Monaco's lineHeight option uses pixels. Passing 3 therefore sets a 3px line height. Compute editorLineHeight === 0 ? Math.ceil(editorFontSize * 1.45) : Math.ceil(editorFontSize * editorLineHeight) once. Use it for both Monaco lineHeight assignments and all auto-height calculations, including the memo dependencies.
|
Closing as superseded by #36577: every editor surface now shares one typography setup, with opt-in font size, weight, line height, ligatures and macOS smoothing. Thank you for this PR, it shaped the design. |

ELI5
The file editor could already borrow the terminal's font and font size, but not its weight, and it had no say over its line spacing at all. So a file open in the editor could look lighter and airier than the exact same text in a terminal pane right next to it, with no setting anywhere to fix it. This adds those two knobs. Leave them empty and nothing changes — the weight keeps following the terminal, and the spacing stays exactly where Monaco had it.
What Changed
Two new opt-in settings under General → Editor, next to Editor Font Family:
terminalFontWeight, or pin 100–900. Resolution reuses the terminal's existingnormalizeTerminalFontWeight, so the two settings share one clamp instead of duplicating validation.Both are wired the same way
editorFontFamilyalready is. Family and weight now resolve together through a smallresolveEditorFontOptions()helper, because every Monaco surface sets them as a pair.The empty field shows the value it resolves to today — the live terminal weight, or Monaco's own ratio (1.5 on macOS, 1.35 elsewhere) — so "inheriting" is never a guess.
Why
fontFamilyandfontSizewere the only typography options reaching Monaco. Everything else fell back to Monaco's defaults regardless of what the terminal was set to, and there was no editor-side setting to compensate — the only lever was moving the terminal, which is backwards if you want the terminal compact.Defaults were chosen so this change is invisible until someone opts in:
editorFontFamilyalready behaves. A fixed default would have pinned the editor and quietly broken that inheritance for everyone.0, which Monaco reads as "compute from the font size" — byte-for-byte today's behavior. File editor ignores line height: Monaco lineHeight is never set, so file view can't match terminal spacing #14257 also proposed inheriting the terminal's Line Height instead, but the terminal defaults to 1 against Monaco's 1.5, so that would have recompressed every existing user's editor by a third on upgrade.Line height is scoped to the file editor on purpose. Diff views size their virtualized rows from a fixed
DIFF_LINE_HEIGHTindiff-section-layout.ts, so making their line height configurable would desync the virtualizer's height estimates from what Monaco actually renders. That belongs in its own change. Font weight has no such coupling and applies to every surface that already honors the editor font.Linked Issue
Fixes #20183
Fixes #14257
Visual Proof
Testing
Verified on macOS (darwin arm64) in a dev build: setting weight 600 and line height 1.2 changes the file editor only — terminal panes, chat, and the shell prompt are untouched. Clearing either field returns it to inheriting.
pnpm lint,pnpm typecheckandpnpm buildall exit 0. New tests:editor-font-zoom.test.ts— inheritance, opt-in override, clamping, and the per-platform Monaco ratioEditorFontWeightSetting.test.tsx/EditorLineHeightSetting.test.tsx— the four states each row can be inMonacoEditor.font-weight.test.tsx/MonacoEditor.line-height.test.tsx— the options actually reaching MonacoThe setting render tests are not redundant coverage: an earlier revision passed
NaNas NumberField's unset value, and sinceNaN !== NaNits render-phase sync set state on every render and tripped React's re-render limit the moment Settings opened. Resolver tests and mocked-editor tests both passed through that bug — only rendering the row caught it. I re-introduced the bug to confirm these tests fail against it before keeping them.pnpm testreports 15 pre-existing failures incross-version-wire,claude-real-cli,relayandcodex-pty, all from my shallow clone (release-checkoutneeds release tags locally). Confirmed identical on a clean checkout of the base commit with none of these changes applied.Author
X: @prosnaghi
AI Disclosure
Written with Claude Opus 5 (Claude Code), reviewed and directed by me.
Review
Agent review summary:
monacoAutomaticLineHeightRatio(), which mirrors Monaco's ownisMacintosh ? 1.5 : 1.35and exists only to label the placeholder. It takes the platform as a parameter and is unit-tested for darwin/linux/win32. No paths, shells or shortcuts touched.updateOptionseffect rather than creating a new one.editorFontFamilyrow it sits beside; usesNumberFieldandSearchableSettingrather than custom controls, no hardcoded colors. Verified in dark mode on macOS.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Localization: English plus es/fr/ja/ko/zh, reusing each catalog's existing wording for "font weight" and the sibling editor font setting. Added via
pnpm run sync:localization-catalog, not hand-edited.Both rows live in General → Editor because that is where Editor Font Family already is. Grouping the editor's typography under Appearance next to IDE Font would arguably suit it better — #14257 assumes it is already there — but moving existing settings is a product call, so I kept these next to their sibling rather than deciding it inside a feature PR.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)