From 36d1cc65788233499afab16f63ec0a98d7eee4e8 Mon Sep 17 00:00:00 2001 From: Pixel Perfect Date: Wed, 8 Jul 2026 23:07:52 -0700 Subject: [PATCH] Re-run session sync after WASM init and merge Ghostty config files - Bump a terminal epoch when the deferred WASM setup finishes so the session sync effect re-runs against the live terminal even when no session field changed during the load, completing the exited-at-mount handling - Read config.ghostty as an alternate config file name and merge the XDG and macOS Application Support configs in Ghostty's load order instead of stopping at the first existing file --- apps/server/src/terminal/ghosttyStyle.ts | 24 ++++++++++++++----- .../src/components/ThreadTerminalDrawer.tsx | 7 +++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/server/src/terminal/ghosttyStyle.ts b/apps/server/src/terminal/ghosttyStyle.ts index ed20287410..9299bbf398 100644 --- a/apps/server/src/terminal/ghosttyStyle.ts +++ b/apps/server/src/terminal/ghosttyStyle.ts @@ -207,13 +207,25 @@ export const loadGhosttyTerminalStyle: Effect.Effect< return undefined; }); - const configSource = yield* readFirstExisting([ - path.join(xdgConfigHome, "ghostty", "config"), - path.join(home, "Library", "Application Support", "com.mitchellh.ghostty", "config"), - ]); - if (configSource === undefined) return undefined; + // Ghostty reads the XDG config first and the macOS Application Support + // config after it, so later files override earlier values. It also accepts + // config.ghostty as the file name. Merge every location that exists instead + // of stopping at the first match. + const configDirs = [ + path.join(xdgConfigHome, "ghostty"), + path.join(home, "Library", "Application Support", "com.mitchellh.ghostty"), + ]; + const configSources: Array = []; + for (const dir of configDirs) { + const source = yield* readFirstExisting([ + path.join(dir, "config"), + path.join(dir, "config.ghostty"), + ]); + if (source !== undefined) configSources.push(source); + } + if (configSources.length === 0) return undefined; - const config = parseGhosttyConfig(configSource); + const config = parseGhosttyConfig(configSources.join("\n")); const loadThemeColors = (themeName: string) => Effect.gen(function* () { diff --git a/apps/web/src/components/ThreadTerminalDrawer.tsx b/apps/web/src/components/ThreadTerminalDrawer.tsx index 9ef033ffa6..5495d5dc75 100644 --- a/apps/web/src/components/ThreadTerminalDrawer.tsx +++ b/apps/web/src/components/ThreadTerminalDrawer.tsx @@ -434,6 +434,10 @@ export function TerminalViewport({ reportFailure: false, }); const hasHandledExitRef = useRef(false); + // Bumped when the async WASM gate finishes creating a terminal, so the + // session sync effect re-runs against the live terminal even when no + // session field changed while the WASM module was loading. + const [terminalEpoch, setTerminalEpoch] = useState(0); const selectionPointerRef = useRef<{ x: number; y: number } | null>(null); const selectionGestureActiveRef = useRef(false); const selectionActionRequestIdRef = useRef(0); @@ -549,6 +553,7 @@ export function TerminalViewport({ status: "closed", version: 0, }; + setTerminalEpoch((value) => value + 1); const clearSelectionAction = () => { selectionActionRequestIdRef.current += 1; @@ -970,7 +975,7 @@ export function TerminalViewport({ }); } previousSessionRef.current = current; - }, [autoFocus, terminalBuffer, terminalError, terminalStatus, terminalVersion]); + }, [autoFocus, terminalBuffer, terminalEpoch, terminalError, terminalStatus, terminalVersion]); useEffect(() => { if (!autoFocus) return;