diff options
| author | Amir Hardon <[email protected]> | 2025-05-08 20:56:46 -0700 |
|---|---|---|
| committer | N. Taylor Mullen <[email protected]> | 2025-05-08 22:33:46 -0700 |
| commit | 1c486a40501baf7ab675383efe23c36508a9f24c (patch) | |
| tree | c540832042d12e0061c46a874f36b9db21e0a5fb /packages/cli/src/gemini.ts | |
| parent | 4741c9a6eb9d22545d490e3ed88251d2d9c508d8 (diff) | |
Fix: Prevent CLI from crashing when a configured theme is not found
Previously, if a theme specified in the user's settings was not found, the CLI would crash during startup. This was particularly affecting users upgrading from older versions as the "ANSI colors only" theme was renamed to "ANSI".
This commit adds error handling to catch the theme not found error during initial loading and when setting themes later. Instead of crashing, the application now logs a warning, displays an error message in the UI, and opens the theme selection dialog to allow the user to choose a valid theme.
Diffstat (limited to 'packages/cli/src/gemini.ts')
| -rw-r--r-- | packages/cli/src/gemini.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/cli/src/gemini.ts b/packages/cli/src/gemini.ts index 420f3242..32e34c20 100644 --- a/packages/cli/src/gemini.ts +++ b/packages/cli/src/gemini.ts @@ -24,7 +24,24 @@ async function main() { const settings = loadSettings(process.cwd()); const config = await loadCliConfig(settings.merged); if (settings.merged.theme) { - themeManager.setActiveTheme(settings.merged.theme); + try { + themeManager.setActiveTheme(settings.merged.theme); + } catch (error: unknown) { + // If the theme is not found during initial load, log a warning and continue. + // The useThemeCommand hook in App.tsx will handle opening the dialog. + if ( + error instanceof Error && + error.message.includes('Theme') && + error.message.includes('not found') + ) { + console.warn( + `Warning: ${error instanceof Error ? error.message : String(error)}`, + ); + } else { + // Re-throw other errors to be caught by the main catch block + throw error; + } + } } // hop into sandbox if we are outside and sandboxing is enabled |
