feat: improve terminal font compatibility across platforms (#342)

* feat: improve terminal compatibility with default fonts across platforms

Add cross-platform monospace font fallback chain (SF Mono, Menlo, Monaco,
Cascadia Mono, Consolas, DejaVu Sans Mono, Liberation Mono) so the terminal
renders correctly on macOS, Windows, and Linux out of the box.

- Platform-aware default font in settings (SF Mono / Cascadia Mono / DejaVu)
- buildFontFamily deduplicates user font against full fallback chain
- Error handling for pty spawn failures with user-facing error banner
- Zero-dimension diagnostic when terminal container has no layout
- WebGL context loss / unavailability logging for debugging

* feat: improve terminal font fallback and pty error handling

- Add cross-platform terminal font fallbacks
- Surface pty spawn errors to terminal UI
- Fix max-lines eslint error in TerminalPane
- Fix curly braces eslint error in constants.ts
This commit is contained in:
Jinjing
2026-04-06 14:33:33 -07:00
committed by GitHub
parent fb7ea89e7e
commit 6c423f15f0
9 changed files with 186 additions and 32 deletions
+15 -1
View File
@@ -9,6 +9,20 @@ import type {
import { DEFAULT_TERMINAL_FONT_WEIGHT } from './terminal-fonts'
export const SCHEMA_VERSION = 1
// Pick a default terminal font that is likely to exist on the current OS.
// buildFontFamily() adds the full cross-platform fallback chain, so this only
// affects what users see in Settings as the initial value.
function defaultTerminalFontFamily(): string {
const platform = typeof process !== 'undefined' ? process.platform : ''
if (platform === 'win32') {
return 'Cascadia Mono'
}
if (platform === 'linux') {
return 'DejaVu Sans Mono'
}
return 'SF Mono' // macOS default
}
export const DEFAULT_EDITOR_AUTO_SAVE_DELAY_MS = 1000
export const MIN_EDITOR_AUTO_SAVE_DELAY_MS = 250
export const MAX_EDITOR_AUTO_SAVE_DELAY_MS = 10_000
@@ -43,7 +57,7 @@ export function getDefaultSettings(homedir: string): GlobalSettings {
editorAutoSave: false,
editorAutoSaveDelayMs: DEFAULT_EDITOR_AUTO_SAVE_DELAY_MS,
terminalFontSize: 14,
terminalFontFamily: 'SF Mono',
terminalFontFamily: defaultTerminalFontFamily(),
terminalFontWeight: DEFAULT_TERMINAL_FONT_WEIGHT,
terminalCursorStyle: 'bar',
terminalCursorBlink: true,