Skip to content

fix(terminal): persist Ctrl+/- font zoom so it survives option refreshes - #1399

Open
tcezarl wants to merge 1 commit into
Termix-SSH:mainfrom
tcezarl:persist-terminal-font-zoom
Open

fix(terminal): persist Ctrl+/- font zoom so it survives option refreshes#1399
tcezarl wants to merge 1 commit into
Termix-SSH:mainfrom
tcezarl:persist-terminal-font-zoom

Conversation

@tcezarl

@tcezarl tcezarl commented Sep 6, 2026

Copy link
Copy Markdown

Persist terminal font zoom (Ctrl +/- / Ctrl+wheel) so it survives option refreshes

Problem

Zooming the terminal with Ctrl +/- or Ctrl+wheel changes the font size for
~30–60 s and then snaps back to the configured size.

changeTerminalFontSize() only mutates terminal.options.fontSize and
terminalFontSizeRef.current; it never persists. The "update terminal options
individually" effect in Terminal.tsx (deps include isFitted,
terminalDefaults, hostConfig.terminalConfig) re-runs on the WebSocket
keepalive / 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 existing
terminal_theme_host_<hostId> pattern) and have the terminal-option effects
prefer that override:

  • changeTerminalFontSize() writes the new size to localStorage.
  • The creation effect and the "update options" effect read the override and
    apply it instead of config.fontSize.
  • If the configured font size itself changes (user edits it in Settings /
    host config), the override is cleared so the new configured value wins.

All storage access is wrapped in try/catch (private mode / disabled storage
falls back to the configured size).

Testing

  • Zoom in, wait past the keepalive interval — size holds.
  • Reload — size persists.
  • Change Font Size in Connection Defaults — override is dropped, new value applies.
  • Storage disabled — no errors, behaves as before (transient zoom only).

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 ZacharyZcR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants