Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,33 @@ describe("GeneralTab language picker", () => {
expect(set).toHaveBeenLastCalledWith({ providerUsageThresholds: {} });
});
});


it("renders the theme picker with auto/light/dark options in general mode", () => {
render(<GeneralTab settings={settings} set={vi.fn()} saving={false} />);

const select = screen.getByRole("combobox", { name: "ThemeLabel" });
expect(select).toBeInTheDocument();
expect(select.querySelectorAll("option")).toHaveLength(3);
expect(select.querySelector('option[value="light"]')).not.toBeNull();
expect(select.querySelector('option[value="dark"]')).not.toBeNull();
expect(select.querySelector('option[value="auto"]')).not.toBeNull();
});

it("persists a light theme choice via updateSettings", () => {
const set = vi.fn();
render(<GeneralTab settings={settings} set={set} saving={false} />);

const select = screen.getByRole("combobox", { name: "ThemeLabel" });
fireEvent.change(select, { target: { value: "light" } });

expect(set).toHaveBeenCalledWith({ theme: "light" });
});

it("does not render the theme picker in notifications mode", () => {
render(
<GeneralTab mode="notifications" settings={settings} set={vi.fn()} saving={false} />,
);

expect(screen.queryByRole("combobox", { name: "ThemeLabel" })).toBeNull();
});
25 changes: 25 additions & 0 deletions apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
NotificationSoundEvent,
NotificationSoundPaths,
NotificationSoundTheme,
ThemePreference,
UsageThresholdOverride,
} from "../../../types/bridge";
import type { LocaleKey } from "../../../i18n/keys";
Expand Down Expand Up @@ -99,6 +100,13 @@ const NOTIFICATION_SOUND_EVENTS: {
const NOTIFICATION_SOUND_THEME_SELECT_MIN_WIDTH = 180;
const NOTIFICATION_SOUND_PREVIEW_DURATION_MS = 1500;


const THEME_OPTIONS: { value: ThemePreference; labelKey: LocaleKey }[] = [
{ value: "auto", labelKey: "ThemeAutoOption" },
{ value: "light", labelKey: "ThemeLightOption" },
{ value: "dark", labelKey: "ThemeDarkOption" },
]

function fileName(path: string): string {
return path.split(/[\\/]/).pop() ?? path;
}
Expand Down Expand Up @@ -261,6 +269,23 @@ export default function GeneralTab({
</div>
</section>}

{mode === "general" && <section className="settings-section">
<h3 className="settings-section__title">{t("SectionTheme")}</h3>
<div className="settings-section__group">
<Field label={t("ThemeLabel")} description={t("ThemeHelper")}>
<Select
value={settings.theme}
disabled={saving}
ariaLabel={t("ThemeLabel")}
options={THEME_OPTIONS.map((option) => ({
value: option.value,
label: t(option.labelKey),
}))}
onChange={(value) => set({ theme: value as ThemePreference })}
/>
</Field>
</div>
</section>}
{mode === "general" && <section className="settings-section">
<h3 className="settings-section__title">{t("StartupSettings")}</h3>
<div className="settings-section__group">
Expand Down
Loading