The View menu set WKWebView.magnification — the scroll-view scale used by
pinch gestures. It enlarges an already-laid-out page inside a viewport that
keeps its pre-zoom size, so ⌘+ pushed the composer below the window and ⌘−
left unused gutters on the right and bottom.
Zoom now goes through WKWebView.pageZoom, which changes the CSS viewport and
reflows the layout. The policy lives in a WebKit-free HermesAgentCore target
(0.1 steps, 0.5–3.0 clamp, integer-tenths quantization, validation and
migration of the stored key). allowsMagnification is disabled so the two
zoom mechanisms cannot compose.
Tests: ZoomLevelTests, ZoomPreferencesTests, PageZoomWiringTests.
Problem
⌘+ / ⌘− (View → Zoom In / Zoom Out / Actual Size) scale the window's contents
instead of the page: zooming in pushes the composer below the bottom of the
window, and zooming out leaves unused gutters on the right and at the bottom.
Lines never re-wrap and the layout never re-flows.
That also makes ⌘+/⌘− useless as a readability control on large displays. The
WebUI's Settings → Appearance → Font size scale tops out below what a 4K display
needs (Extra large is still small), so client-level page zoom is the practical
way to scale the UI. The two settings compose — page zoom scales the chosen font
size rather than replacing it — so ⌘+/⌘− has to do real page zoom to be useful.
Cause
AppDelegate.zoomIn/zoomOut/zoomResetsetWKWebView.magnification, thescroll-view scale used by pinch gestures. It enlarges an already-laid-out page
inside a viewport that keeps its pre-zoom size, so nothing re-flows: above 1 the
bottom-anchored composer lands outside the window, below 1 the scaled page sits
in the top-left with empty space on the right and bottom.
Two details kept the wrong state sticky:
magnificationinwebView(_:didFinish:),i.e. after every navigation, so a reload restored it;
allowsMagnification = truekept the trackpad pinch on the same non-reflowingpath, and magnification composes multiplicatively with page zoom.
Fix
WKWebView.pageZoom, which changes the CSS viewport,so text re-wraps and flex/grid layouts rearrange — Safari's ⌘+/⌘− behaviour.
HermesAgentCoretarget soswift testexercises the real type instead of a copy:exactly to 100% (plain
factor + 0.1drifts to 1.2000000000000002);ZoomLevel(restoring:)rejects the0thatUserDefaultsreports for amissing key, and anything outside the range;
webViewMagnificationtowebViewPageZoomon first read, so existing users keep their zoom level.
allowsMagnification = false: one zoom mechanism, no composition surprises.navigation (a recreated WebContent process starts at 100%).
Tests
swift testpasses on macOS 14 arm64 (87 tests, 0 failures), including 18 newones:
ZoomLevelTests— steps, drift, clamping, quantization, restore validation.ZoomPreferencesTests— round-trip, legacy-key migration, key precedence.PageZoomWiringTests— source-level guard that the View actions usepageZoomand native magnification stays off (no UI-test harness exists forthis app; same approach as
LongConversationCompatibilityTests).Manual check: ⌘+, ⌘−, ⌘0, ⌘R and relaunch, including with Appearance → Font size
set to Extra large.
Behaviour change
Pinch-to-zoom no longer magnifies. It was the same non-reflowing mechanism and
would compose with page zoom, leaving ⌘0 not actually at 100%. Listed under
Changed in the CHANGELOG; mapping pinch onto page-zoom steps is a possible
follow-up.
Alternatives considered
hermes-webui, is CSS-level,and still wouldn't make ⌘+/⌘− zoom.
magnification— no reflow; that's the bug.Checklist
main[Unreleased]Info.plistkeys added (build.sh / CI parity untouched)swift testgreen