From a1d2c31be932ccca9c4ee1b43d6eee1ffbfc8633 Mon Sep 17 00:00:00 2001 From: "LAPTOP-O016UC3M\\Qi Chen" <16399091+binaricat@users.noreply.github.com> Date: Tue, 9 Dec 2025 23:15:56 +0800 Subject: [PATCH] Updates terminal to ghostty-web 0.4.0 and improves font support Upgrades the terminal dependency for better compatibility and API alignment. Refactors initialization to match upstream changes, removing direct WASM loading. Expands the terminal font stack and adds extended Unicode font-face for improved box drawing and symbol rendering in the terminal interface. --- components/Terminal.tsx | 20 +++++++++++--------- index.html | 6 ++++++ package-lock.json | 9 ++++----- package.json | 4 ++-- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/components/Terminal.tsx b/components/Terminal.tsx index c5f504d39..cd1280022 100644 --- a/components/Terminal.tsx +++ b/components/Terminal.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useRef, useState, memo } from 'react'; -import { Ghostty, Terminal as GhosttyTerminal, FitAddon } from 'ghostty-web'; +import { init as initGhostty, Terminal as GhosttyTerminal, FitAddon } from 'ghostty-web'; import { Host, SSHKey, Snippet, TerminalSession, TerminalTheme } from '../types'; import { Zap, FolderInput, Loader2, AlertCircle, ShieldCheck, Clock, Play, X, Lock, Key, User, Eye, EyeOff, ChevronDown } from 'lucide-react'; import { DistroAvatar } from './DistroAvatar'; @@ -28,12 +28,15 @@ interface TerminalProps { onUpdateHost?: (host: Host) => void; } -let ghosttyPromise: Promise | null = null; -const ensureGhostty = () => { - if (!ghosttyPromise) { - ghosttyPromise = Ghostty.load('ghostty-vt.wasm'); +let ghosttyInitialized = false; +let ghosttyInitPromise: Promise | null = null; +const ensureGhostty = async () => { + if (ghosttyInitialized) return; + if (!ghosttyInitPromise) { + ghosttyInitPromise = initGhostty(); } - return ghosttyPromise; + await ghosttyInitPromise; + ghosttyInitialized = true; }; const TerminalComponent: React.FC = ({ @@ -149,18 +152,17 @@ const TerminalComponent: React.FC = ({ const boot = async () => { try { - const ghostty = await ensureGhostty(); + await ensureGhostty(); if (disposed || !containerRef.current) return; const term = new GhosttyTerminal({ cursorBlink: true, fontSize, - fontFamily: '"JetBrains Mono", monospace', + fontFamily: '"JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono", "Menlo", "DejaVu Sans Mono", monospace', theme: { ...terminalTheme.colors, selectionBackground: terminalTheme.colors.selection, }, - ghostty, }); const fitAddon = new FitAddon(); diff --git a/index.html b/index.html index c90ca9a35..c9ceb345d 100755 --- a/index.html +++ b/index.html @@ -8,6 +8,12 @@