Skip to content

feat(editor): give the file editor its own font weight and line height - #20188

Closed
PedroOsnaghi wants to merge 4 commits into
stablyai:mainfrom
PedroOsnaghi:feat/editor-font-weight
Closed

PedroOsnaghi wants to merge 4 commits into
stablyai:mainfrom
PedroOsnaghi:feat/editor-font-weight

Conversation

@PedroOsnaghi

Copy link
Copy Markdown

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:

  • Editor Font Weight — empty follows terminalFontWeight, or pin 100–900. Resolution reuses the terminal's existing normalizeTerminalFontWeight, so the two settings share one clamp instead of duplicating validation.
  • Editor Line Height — empty keeps Monaco's automatic spacing, or pin a 1–3 multiple of the font size.

Both are wired the same way editorFontFamily already is. Family and weight now resolve together through a small resolveEditorFontOptions() 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

fontFamily and fontSize were 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:

  • Font weight defaults to following the terminal, matching how editorFontFamily already behaves. A fixed default would have pinned the editor and quietly broken that inheritance for everyone.
  • Line height defaults to 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_HEIGHT in diff-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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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 typecheck and pnpm build all exit 0. New tests:

  • editor-font-zoom.test.ts — inheritance, opt-in override, clamping, and the per-platform Monaco ratio
  • EditorFontWeightSetting.test.tsx / EditorLineHeightSetting.test.tsx — the four states each row can be in
  • MonacoEditor.font-weight.test.tsx / MonacoEditor.line-height.test.tsx — the options actually reaching Monaco

The setting render tests are not redundant coverage: an earlier revision passed NaN as NumberField's unset value, and since NaN !== NaN its 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 test reports 15 pre-existing failures in cross-version-wire, claude-real-cli, relay and codex-pty, all from my shallow clone (release-checkout needs 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:

  • Cross-platform — no platform branches except monacoAutomaticLineHeightRatio(), which mirrors Monaco's own isMacintosh ? 1.5 : 1.35 and 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.
  • Remote/SSH/local — settings-only; no process, filesystem or network assumptions. Values travel through the existing global-settings pipeline.
  • Agents and integrations — none touched; nothing here is provider-specific.
  • Backwards compatibility — both settings are optional and default to today's behavior. Profiles saved before this change deserialize with the field absent, which the resolvers read as "inherit". No migration needed.
  • Performance — two arithmetic resolvers per render, no allocation in a hot path. The line-height dependency was added to the existing updateOptions effect rather than creating a new one.
  • UI quality — follows the editorFontFamily row it sits beside; uses NumberField and SearchableSetting rather than custom controls, no hardcoded colors. Verified in dark mode on macOS.
  • Security — no new inputs, IPC, or file access. Both values are clamped before use.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

PedroOsnaghi and others added 4 commits September 11, 2026 21:43
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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — editorFontWeight and editorLineHeight added to the shared settings type and defaults, with resolvers in editor-font-zoom.ts that reuse normalizeTerminalFontWeight and 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 NumberField rows 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 Proof section 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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').

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The 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 ab2ca

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)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The implementation satisfies #20183: it adds an opt-in editor weight, reuses normalizeTerminalFontWeight, resolves the terminal weight when the editor value is unset, applies fontWeight to the fil… Keep the setting value as a multiplier, but convert an opted-in value to the corresponding pixel line height before assigning Monaco's lineHeight in MonacoEditor.tsx. Keep 0 for automatic spacing. Update the component tests to assert …
Out of Scope Changes check ⚠️ Warning Most changes support #20183 and #14257, including the new settings, shared resolution helpers, Monaco options, tests, and translations. The diff also adds an unrelated pin-sidebar close localization… Remove the unrelated pin-sidebar and external-worktrees localization changes, or provide a directly linked coding requirement that includes them.
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding independent editor font weight and line height settings.
Description check ✅ Passed The description is detailed, on-topic, and covers the required change summary, rationale, linked issues, testing, compatibility review, AI disclosure, and checklist. The Visual Proof section does not …
Full details: Linked Issues check

Explanation

The implementation satisfies #20183: it adds an opt-in editor weight, reuses normalizeTerminalFontWeight, resolves the terminal weight when the editor value is unset, applies fontWeight to the file editor, diff editor, notebook editor, automation prompt editor, and code excerpt, and adds tests. The implementation does not satisfy #14257. normalizeEditorLineHeight returns a 1–3 multiplier, but MonacoEditor.tsx passes that multiplier directly as Monaco's lineHeight. The linked issue requires a multiplier to be converted to the editor font size or an equivalent pixel value. The new test also asserts the incorrect direct value of 1.2.

Resolution

Keep the setting value as a multiplier, but convert an opted-in value to the corresponding pixel line height before assigning Monaco's lineHeight in MonacoEditor.tsx. Keep 0 for automatic spacing. Update the component tests to assert the converted value and retain coverage for automatic spacing.

Full details: Out of Scope Changes check

Explanation

Most changes support #20183 and #14257, including the new settings, shared resolution helpers, Monaco options, tests, and translations. The diff also adds an unrelated pin-sidebar close localization label in en.json and unrelated external-worktrees localization changes in locale files. These changes do not implement editor font weight or editor line height.

Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Assert the fontWeight pass-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 win

Centralize the MonacoEditor test fixture. AGENTS.md requires 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 as monaco-editor-test-fixture.tsx with 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

📥 Commits

Reviewing files that changed from the base of the PR and between 556a777 and ab2ca94.

📒 Files selected for processing (29)
  • src/renderer/src/components/automations/AutomationEditorPromptEditor.tsx
  • src/renderer/src/components/automations/automation-editor-prompt-options.test.ts
  • src/renderer/src/components/automations/automation-editor-prompt-options.ts
  • src/renderer/src/components/editor/DiffSectionBody.tsx
  • src/renderer/src/components/editor/DiffSectionItem.tsx
  • src/renderer/src/components/editor/DiffViewer.tsx
  • src/renderer/src/components/editor/IpynbCellEditor.tsx
  • src/renderer/src/components/editor/MonacoCodeExcerpt.tsx
  • src/renderer/src/components/editor/MonacoEditor.font-weight.test.tsx
  • src/renderer/src/components/editor/MonacoEditor.line-height.test.tsx
  • src/renderer/src/components/editor/MonacoEditor.tsx
  • src/renderer/src/components/editor/diff-section-item-props.ts
  • src/renderer/src/components/settings/EditorFontWeightSetting.test.tsx
  • src/renderer/src/components/settings/EditorFontWeightSetting.tsx
  • src/renderer/src/components/settings/EditorLineHeightSetting.test.tsx
  • src/renderer/src/components/settings/EditorLineHeightSetting.tsx
  • src/renderer/src/components/settings/GeneralEditorSettingsSection.tsx
  • src/renderer/src/components/settings/general-editor-search.ts
  • src/renderer/src/components/settings/setting-labels.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/editor-font-zoom.test.ts
  • src/renderer/src/lib/editor-font-zoom.ts
  • src/shared/default-global-settings.ts
  • src/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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@nwparker

nwparker commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

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.

@nwparker nwparker closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants