summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/App.tsx
diff options
context:
space:
mode:
authorAmir Hardon <[email protected]>2025-05-08 20:56:46 -0700
committerN. Taylor Mullen <[email protected]>2025-05-08 22:33:46 -0700
commit1c486a40501baf7ab675383efe23c36508a9f24c (patch)
treec540832042d12e0061c46a874f36b9db21e0a5fb /packages/cli/src/ui/App.tsx
parent4741c9a6eb9d22545d490e3ed88251d2d9c508d8 (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/ui/App.tsx')
-rw-r--r--packages/cli/src/ui/App.tsx20
1 files changed, 14 insertions, 6 deletions
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx
index 9fe651b5..725a2012 100644
--- a/packages/cli/src/ui/App.tsx
+++ b/packages/cli/src/ui/App.tsx
@@ -39,12 +39,13 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
const { history, addItem, clearItems } = useHistory();
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
const [showHelp, setShowHelp] = useState<boolean>(false);
+ const [themeError, setThemeError] = useState<string | null>(null);
const {
isThemeDialogOpen,
openThemeDialog,
handleThemeSelect,
handleThemeHighlight,
- } = useThemeCommand(settings);
+ } = useThemeCommand(settings, setThemeError);
const [staticKey, setStaticKey] = useState(0);
const refreshStatic = useCallback(() => {
@@ -191,11 +192,18 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
)}
{isThemeDialogOpen ? (
- <ThemeDialog
- onSelect={handleThemeSelect}
- onHighlight={handleThemeHighlight}
- settings={settings}
- />
+ <Box flexDirection="column">
+ {themeError && (
+ <Box marginBottom={1}>
+ <Text color={Colors.AccentRed}>{themeError}</Text>
+ </Box>
+ )}
+ <ThemeDialog
+ onSelect={handleThemeSelect}
+ onHighlight={handleThemeHighlight}
+ settings={settings}
+ />
+ </Box>
) : (
<>
<LoadingIndicator