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;