From 8434701bd5dc919fd3228cc5db98005964ec1918 Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 19 Mar 2026 07:38:40 -0400 Subject: [PATCH] fix(ci): handle missing homedir in ThemeManager for CI environments Wrap os.homedir() in try/catch and guard against undefined return value in ThemeManager.getConfigPath(). In CI environments, os.homedir() may be undefined, causing path.join() to throw and preventing SessionReplay from being constructed. When homedir is unavailable, theme persistence is gracefully skipped and the default dark theme is used. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/tui/utils/theme.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tui/utils/theme.ts b/src/tui/utils/theme.ts index 1779334..57daa78 100644 --- a/src/tui/utils/theme.ts +++ b/src/tui/utils/theme.ts @@ -189,11 +189,20 @@ export class ThemeManager { * Get the config file path for theme persistence */ private getConfigPath(): string { - const configDir = path.join(os.homedir(), '.fabric'); - if (!fs.existsSync(configDir)) { - fs.mkdirSync(configDir, { recursive: true }); + try { + const home = os.homedir(); + if (!home) { + return ''; + } + const configDir = path.join(home, '.fabric'); + if (!fs.existsSync(configDir)) { + fs.mkdirSync(configDir, { recursive: true }); + } + return path.join(configDir, 'theme.json'); + } catch { + // In CI or environments without a home directory, skip config persistence + return ''; } - return path.join(configDir, 'theme.json'); } /** @@ -201,7 +210,7 @@ export class ThemeManager { */ private loadTheme(): ThemeName { try { - if (fs.existsSync(this.configPath)) { + if (this.configPath && fs.existsSync(this.configPath)) { const content = fs.readFileSync(this.configPath, 'utf-8'); const config = JSON.parse(content); if (config.theme === 'dark' || config.theme === 'light') { @@ -218,6 +227,7 @@ export class ThemeManager { * Save theme to config file */ private saveTheme(): void { + if (!this.configPath) return; try { const config = { theme: this.currentTheme }; fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2), 'utf-8');