fix(terminal): persist Ctrl+/- font zoom so it survives option refreshes - #1399
fix(terminal): persist Ctrl+/- font zoom so it survives option refreshes#1399tcezarl wants to merge 1 commit into
Conversation
changeTerminalFontSize only mutated terminal.options.fontSize and a ref; the terminal-options effect re-runs on the keepalive/refit/reconnect cycle and reassigned terminal.options.fontSize = config.fontSize, snapping the zoom back after ~30-60s. Persist the zoom per host in localStorage (terminal_fontsize_host_<id>, mirroring terminal_theme_host_<id>) and have the creation effect and the options-update effect prefer that override. Clear it when the configured font size itself changes so Settings still wins. All storage access is guarded with try/catch.
ZacharyZcR
left a comment
There was a problem hiding this comment.
This needs changes before merge. The persisted value stores only the zoomed font size, not the configured size it was derived from. If a user zooms a host, closes the terminal, changes Connection Defaults while that terminal is unmounted, and reopens it, lastConfiguredFontSizeRef initializes to the new configured value and the old localStorage override still wins forever. The claimed “configured font size change clears the override” only works while this component remains mounted. Store the configured/base size alongside the override (or use another design that can invalidate stale overrides on mount) and add a regression test for that closed-terminal settings-change path.
Also avoid terminal_fontsize_host_undefined: quick-connect terminals do not necessarily have a host id, so unrelated quick-connect sessions currently share one persisted override. Finally, please retarget/rebase this onto the active dev-2.8.0 branch; the current main base produces an unrelated multi-file diff against development.
Persist terminal font zoom (Ctrl +/- / Ctrl+wheel) so it survives option refreshes
Problem
Zooming the terminal with
Ctrl+/-orCtrl+wheel changes the font size for~30–60 s and then snaps back to the configured size.
changeTerminalFontSize()only mutatesterminal.options.fontSizeandterminalFontSizeRef.current; it never persists. The "update terminal optionsindividually" effect in
Terminal.tsx(deps includeisFitted,terminalDefaults,hostConfig.terminalConfig) re-runs on the WebSocketkeepalive / refit / reconnect cycle and unconditionally reassigns
terminal.options.fontSize = config.fontSize, discarding the zoom.Fix
Persist the zoom level per host in
localStorage(
terminal_fontsize_host_<hostId>, mirroring the existingterminal_theme_host_<hostId>pattern) and have the terminal-option effectsprefer that override:
changeTerminalFontSize()writes the new size tolocalStorage.apply it instead of
config.fontSize.host config), the override is cleared so the new configured value wins.
All storage access is wrapped in
try/catch(private mode / disabled storagefalls back to the configured size).
Testing