Add font-size/zoom control to the markdown viewer
Summary
- Adds font-size / zoom control to the cmux markdown viewer, which previously had no way to scale text. Cmd-+/-/0 only zoomed browser surfaces and there was no
--font-sizeflag or setting. - Font size is one "points" value rendered via
WKWebView.pageZoom(points / 15pxbody base), so it scales the whole rendered document (text, code, tables, diagrams, images) like browser zoom and mirrors the existingcmux diff --font-size. cmux markdown open --font-size <points>sets a viewer's size (validated to 8..96), sent throughmarkdown.open's newfont_sizeparam.Cmd-+/Cmd--/Cmd-0zoom the focused markdown viewer via newmarkdownZoomIn/markdownZoomOut/markdownZoomResetshortcuts in a dedicated.markdownPanelcontext (shares Cmd-=/-/0 with browser zoom but never collides; conflict detection also treats it as overlapping.nonBrowserPanel). Exposed through Settings > Keyboard Shortcuts,cmux.json, and the command palette. The View-menu Zoom items stay browser-only so a rebound markdown shortcut isn't overridden by the menu key equivalent.markdown.fontSizesetting (default 15) in Settings > App,cmux.json, the schema, and the settings catalog sets the size every new viewer starts at and thatCmd-0resets to.- Zoom is scoped to the rendered preview; the raw text-edit mode keeps the system editor font and does not surface the zoom commands.
Testing
./scripts/reload.sh --tag md-fontsizebuilds the Debug app cleanly.- Drove the real
handleCustomShortcutpath on the tagged build via the debug socket and screenshotted:--font-size 40rendered huge →Cmd-0reset to 15pt →Cmd-+×6 grew to ~21pt. Verified--font-sizerejects 3 and 97, accepts 8 and 96. - Added behavioral unit tests in
cmuxTests/MarkdownPanelTests.swift(clamp/pageZoom/resolvedDefault, zoom step/clamp/reset) andcmuxTests/KeyboardShortcutContextTests.swift(.markdownPanel scoping + overlap).testsCI green.
Dogfood
Open a markdown file in the viewer:
- Previous: rendered too large, no way to shrink;
Cmd--did nothing in a markdown panel. - Expected now: with the rendered preview focused,
Cmd--shrinks,Cmd-+grows,Cmd-0resets.cmux markdown open --font-size 11 <file>opens at 11pt. Settings > App > "Markdown Viewer Font Size" andmarkdown.fontSizein cmux.json change the default.
Issues
- Feature request (no GitHub issue): font-size / zoom control for the markdown viewer.
Summary by CodeRabbit
-
New Features
- Added
--font-sizeCLI option forcmux markdown open; per-panel font sizing and persisted "Markdown Viewer Font Size" preference (8–96 pt) - Keyboard shortcuts for markdown zoom: ⌘+=, ⌘+-, ⌘0; command palette entries and on-panel zoom controls
- Added
-
Documentation
- Settings UI, localization, and configuration schema updated to expose markdown font-size controls and docs
-
Tests
- Unit tests added/updated for markdown font-size behavior and shortcut scoping
[!NOTE]
Medium Risk
Touches global shortcut routing and WKWebView zoom alongside new settings/CLI params, but changes are scoped to the markdown preview path with validation and tests.
Overview
Adds font-size and zoom for the built-in markdown preview (not raw text edit mode).
cmux markdown open --font-size <points> validates 8–96 and sends font_size into the markdown-open path. markdown.fontSize (default 15) is a new markdown.* setting in App settings, cmux.json, schema, and docs.
Preview scaling uses WKWebView.pageZoom from a points value (MarkdownFontSizeSettings). MarkdownPanel supports per-panel zoom step/reset; the renderer reapplies zoom after shell reloads.
⌘= / ⌘- / ⌘0 get parallel markdownZoom* actions in a .markdownPanel shortcut context (same chords as browser zoom, routed by focus). Conflict detection treats markdown vs non-browser contexts as overlapping. Command palette, settings catalog, and localized strings are wired; View menu zoom stays browser-only.
Unit tests cover clamp/pageZoom, panel zoom behavior, and shortcut scoping.
Reviewed by Cursor Bugbot for commit 2990c1695b340297aca7e54df8ec4da667ba8114. Bugbot is set up for automated code reviews on this repo. Configure here.