Handle init failure surfacing and empty XDG_CONFIG_HOME

- Attach a rejection handler to the terminal WASM init so a load
  failure logs, shows a message in the viewport, and clears on retry
  instead of leaving a blank pane and an unhandled rejection
- Treat an empty XDG_CONFIG_HOME as unset per the XDG spec instead of
  resolving the Ghostty config relative to the server cwd
This commit is contained in:
Pixel Perfect authored and Julius Marminge committed 2026-07-20 18:05:01 +02:00
1 parent 7266fafbf6
commit c1caaa3520
2 files changed
+20 -5

No files matched your search

@@ -500,6 +500,8 @@ export function TerminalViewport({
let teardown: (() => void) | undefined;
const setUpTerminal = (mount: HTMLDivElement): (() => void) => {
// Clear any failure message left by an earlier init attempt.
mount.textContent = "";
const localApi = readLocalApi();
const style = readTerminalStyle();
@@ -887,10 +889,18 @@ export function TerminalViewport({
};
};
void ensureGhosttyReady().then(() => {
if (effectDisposed || containerRef.current !== mountElement) return;
teardown = setUpTerminal(mountElement);
});
void ensureGhosttyReady().then(
() => {
if (effectDisposed || containerRef.current !== mountElement) return;
teardown = setUpTerminal(mountElement);
},
(error: unknown) => {
if (effectDisposed || containerRef.current !== mountElement) return;
console.error("ghostty-web terminal failed to initialize", error);
mountElement.textContent =
"Terminal failed to initialize. Close and reopen the terminal to retry.";
},
);
return () => {
effectDisposed = true;