Repository navigation
Normalize invalid terminal line height before xterm - #8050
Conversation
📝 WalkthroughWalkthroughAdds shared terminal line-height normalization with bounds of 1 through 3. Applies normalization to settings IPC updates, persisted settings loading and repair, terminal preview initialization and updates, terminal appearance application, and terminal lifecycle options. Adds tests covering normalization cases, IPC persistence, persisted-state repair, and preview behavior. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/terminal-line-height-settings.test.ts (1)
9-17: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding edge cases for
Infinityand non-number types.The current cases cover the primary paths well. Adding
Infinity(returnsMINvia!Number.isFinite) and a non-number type like'1.35'ornull(returnsMINvia thetypeofguard) would strengthen confidence in the two distinct rejection branches.♻️ Suggested additional test cases
it.each([ [undefined, MIN_TERMINAL_LINE_HEIGHT], [Number.NaN, MIN_TERMINAL_LINE_HEIGHT], + [Number.POSITIVE_INFINITY, MIN_TERMINAL_LINE_HEIGHT], + [Number.NEGATIVE_INFINITY, MIN_TERMINAL_LINE_HEIGHT], + [0, MIN_TERMINAL_LINE_HEIGHT], + [-5, MIN_TERMINAL_LINE_HEIGHT], + ['1.35', MIN_TERMINAL_LINE_HEIGHT], + [null, MIN_TERMINAL_LINE_HEIGHT], [0.85, MIN_TERMINAL_LINE_HEIGHT], [1, 1], [1.35, 1.35], [3, 3], [4, MAX_TERMINAL_LINE_HEIGHT] ])('normalizes %s to %s', (input, expected) => {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4f2d2050-3a72-4a0c-ab91-11522587140d
📒 Files selected for processing (10)
src/main/ipc/settings.test.tssrc/main/ipc/settings.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/renderer/src/components/settings/TerminalSettingsPreview.lifecycle.test.tsxsrc/renderer/src/components/settings/TerminalSettingsPreview.tsxsrc/renderer/src/components/terminal-pane/terminal-appearance.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/shared/terminal-line-height-settings.test.tssrc/shared/terminal-line-height-settings.ts
Description
Fixes crash reports
ebfaa501-de3f-4dea-a118-53939a4b531aande5f85f81-1bc4-4003-85e7-f9016ce1459b.Both reports contain the same xterm exception:
lineHeight cannot be less than 1, value: 0.85. The Settings control already clamps new input to[1, 3], but legacy/user-edited persisted state and renderer IPC updates bypassed that clamp. A stored0.85therefore reached both the terminal workbench and Settings preview and escaped through their React error boundaries.This PR adds one shared line-height normalizer, repairs invalid persisted values on load, normalizes renderer IPC updates before persistence, and defensively normalizes both xterm construction/mutation paths.
Clear, undeniable fix evidence
Before (exact live reproduction)
Using an isolated Orca dev profile on current
main:terminalLineHeight=0.85.TerminalSettingsPreview:Error: lineHeight cannot be less than 1, value: 0.85.The regression test was then added before the fix and failed:
After (same corrupted value)
With the renderer store deliberately left at
terminalLineHeight=0.85:xtermSurfaces=1, Appearance heading visible, 0 console errors.xtermSurfaces=1, terminal surface visible, 0 console errors.0.85to1.settings:set({ terminalLineHeight: 0.85 })persists1.Automated evidence:
pnpm exec vitest run --config config/vitest.config.ts src/shared/terminal-line-height-settings.test.ts src/main/ipc/settings.test.ts src/main/persistence.test.ts src/renderer/src/components/settings/TerminalSettingsPreview.lifecycle.test.tsx— 391 passedpnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/terminal-appearance.test.ts src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts— 39 passedxterm-addon.boundary-containmentreliability command — 41 passedpnpm typecheck— passedoxlint,git diff --check, andpnpm check:max-lines-ratchet— passedELI5
Orca's settings screen only lets users choose safe terminal line spacing, but an older settings file could still contain an unsafe number. Orca handed that number directly to the terminal library, and the library threw an error that removed the terminal/settings surface. Orca now checks the number whenever it loads, saves, or applies it, so old bad values become the nearest safe value before the terminal sees them.
Trade-offs
1now become1; values above3become3; non-finite values become1.1–3range.Reliability proof
xterm-addon.boundary-containment(existing experimental, partial gate; unchanged).[1,3]changes, if xterm surfaces diverge from the persisted normalized value, or if cross-platform Electron validation exposes a provider-specific settings path.