Skip to content

fix(terminal): apply configured font size on startup - #146

Open
maartengoet wants to merge 1 commit into
InbarR:mainfrom
maartengoet:fix/startup-font-size
Open

fix(terminal): apply configured font size on startup#146
maartengoet wants to merge 1 commit into
InbarR:mainfrom
maartengoet:fix/startup-font-size

Conversation

@maartengoet

Copy link
Copy Markdown

The bug

A terminal font size other than 14 does not survive a restart. On every launch the terminal renders at 14px regardless of terminal.fontSize, and the status-bar zoom badge shows a wrong percentage.

This affects the Settings font-size control just as much as editing tmax-config.json directly — the Settings change applies to the running session and is silently lost on the next start.

Repro: quit tmax, set terminal.fontSize to 17.5 (any value ≠ 14 reproduces), start tmax.

Expected: terminal renders at 17.5px, badge reads 100%.
Actual: terminal renders at 14px, badge reads 80% — exactly 14 / 17.5.

Root cause

loadConfig (src/renderer/state/terminal-store.ts) seeds tabBarPosition, hideTabTitles, hideTabCloseButtons, confirmOnCloseSession, terminalOpacity and the AI session limits from config into the store — but never terminal.fontSize. The store keeps its hardcoded initial fontSize: 14.

TerminalPanel does construct xterm with the configured size, but the effect that reacts to the store's fontSize writes the stale 14 straight back over the instance on mount, so the configured value never survives.

The store's fontSize was only ever reconciled with config in two places, neither of which runs at startup:

  • updateConfig — runtime config changes, i.e. the Settings dialog
  • zoomResetCtrl+0

That also explains the misleading badge: its numerator is the stale store value while its denominator is the freshly loaded config baseline.

The fix

Seed fontSize from config.terminal.fontSize in loadConfig, alongside the fields it already copies. Guarded on a positive number so a malformed value falls back to the default rather than rendering an unusable terminal.

Ctrl+0 keeps working unchanged — it reads the same baseline, which the store now already matches at startup.

Testing

New unit suite tests/unit/renderer/load-config-font-size.test.ts (6 cases): seeding from config, a configured value equal to the default, config without a terminal section, non-numeric input, zero/negative input, and config still being stored alongside the seeded size.

Verified red/green — reverting the one-line seed fails 2 of the 6, applying it passes all 6.

npm test locally: 171 passed. Two failures in telemetry-ping are pre-existing on macOS and unrelated — they assert hardcoded C:\Users\... paths and fail identically on a clean checkout of main.

No cross-platform surface: no modifier keys, shortcut text, paths or shell assumptions involved.

🤖 Generated with Claude Code

loadConfig seeds tabBarPosition, hideTabTitles, terminalOpacity and the AI
session limits from config, but never terminal.fontSize, so the store kept
its hardcoded initial 14. TerminalPanel does construct xterm with the
configured size, but its fontSize effect immediately writes the stale store
value back over it on mount. Any configured size other than 14 was therefore
lost on every launch - through the Settings control just as much as through
the config file - and only came back via updateConfig or zoomReset (Ctrl+0).

The status-bar zoom badge divides the store value by the configured
baseline, so the mismatch also surfaced as a wrong percentage: a configured
17.5 rendered at 14px and displayed 80%.

Seed fontSize from config.terminal.fontSize in loadConfig, guarded on a
positive number so a malformed value falls back to the default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant