mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
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.
This commit is contained in:
committed by
N. Taylor Mullen
parent
4741c9a6eb
commit
1c486a4050
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user