From d3e5d010e2c007657e75a4eb195037cc399e1483 Mon Sep 17 00:00:00 2001 From: one Date: Thu, 22 May 2025 14:45:36 +0800 Subject: [PATCH] fix: Use effective theme for code style in SettingsTab (#6305) * Fix: Use effective theme for code style in SettingsTab The SettingsTab component was previously using the theme setting directly from useSettings to determine whether to apply the light or dark code style. This caused an issue when the theme was set to 'auto', as it wouldn't correctly reflect the actual system theme (light or dark). This commit modifies SettingsTab.tsx to use the `theme` from the `useTheme` hook (which provides the effective theme) for the logic that determines the code editor and preview styles. This ensures that the code style accurately reflects your current effective theme, including when 'auto' theme is selected and the OS theme changes. * Refactor: Remove unnecessary comments in SettingsTab This commit removes non-essential comments that were added during a previous refactoring of `SettingsTab.tsx`. The core logic for using the effective theme for code style selection remains unchanged. This change is purely for code cleanliness. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- src/renderer/src/pages/home/Tabs/SettingsTab.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/pages/home/Tabs/SettingsTab.tsx b/src/renderer/src/pages/home/Tabs/SettingsTab.tsx index a5950451a8..9654d8320e 100644 --- a/src/renderer/src/pages/home/Tabs/SettingsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/SettingsTab.tsx @@ -14,6 +14,7 @@ import { isSupportedReasoningEffortOpenAIModel } from '@renderer/config/models' import { useCodeStyle } from '@renderer/context/CodeStyleProvider' +import { useTheme } from '@renderer/context/ThemeProvider' import { useAssistant } from '@renderer/hooks/useAssistant' import { useProvider } from '@renderer/hooks/useProvider' import { useSettings } from '@renderer/hooks/useSettings' @@ -73,7 +74,8 @@ const SettingsTab: FC = (props) => { const { assistant, updateAssistantSettings, updateAssistant } = useAssistant(props.assistant.id) const { provider } = useProvider(assistant.model.provider) - const { messageStyle, fontSize, language, theme } = useSettings() + const { messageStyle, fontSize, language } = useSettings() + const { theme } = useTheme() const { themeNames } = useCodeStyle() const [temperature, setTemperature] = useState(assistant?.settings?.temperature ?? DEFAULT_TEMPERATURE)